Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.ir_builder_task; | 5 library dart2js.ir_builder_task; |
| 6 | 6 |
| 7 import '../closure.dart' as closurelib; | 7 import '../closure.dart' as closurelib; |
| 8 import '../closure.dart' hide ClosureScope; | 8 import '../closure.dart' hide ClosureScope; |
| 9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
| 10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 // TODO(johnniwinther): Implement [SemanticDeclVisitor]. | 133 // TODO(johnniwinther): Implement [SemanticDeclVisitor]. |
| 134 abstract class IrBuilderVisitor extends ast.Visitor<ir.Primitive> | 134 abstract class IrBuilderVisitor extends ast.Visitor<ir.Primitive> |
| 135 with IrBuilderMixin<ast.Node>, | 135 with IrBuilderMixin<ast.Node>, |
| 136 SemanticSendResolvedMixin<ir.Primitive, dynamic>, | 136 SemanticSendResolvedMixin<ir.Primitive, dynamic>, |
| 137 SendResolverMixin, | 137 SendResolverMixin, |
| 138 BaseImplementationOfStaticsMixin<ir.Primitive, dynamic>, | 138 BaseImplementationOfStaticsMixin<ir.Primitive, dynamic>, |
| 139 BaseImplementationOfLocalsMixin<ir.Primitive, dynamic>, | 139 BaseImplementationOfLocalsMixin<ir.Primitive, dynamic>, |
| 140 BaseImplementationOfDynamicsMixin<ir.Primitive, dynamic>, | 140 BaseImplementationOfDynamicsMixin<ir.Primitive, dynamic>, |
| 141 BaseImplementationOfConstantsMixin<ir.Primitive, dynamic>, | 141 BaseImplementationOfConstantsMixin<ir.Primitive, dynamic>, |
| 142 BaseImplementationOfSuperIncDecsMixin<ir.Primitive, dynamic>, | 142 BaseImplementationOfSuperIncDecsMixin<ir.Primitive, dynamic>, |
| 143 BaseImplementationOfNewMixin<ir.Primitive, dynamic>, | 143 BaseImplementationOfNewMixin<ir.Primitive, dynamic> |
| 144 ErrorBulkMixin<ir.Primitive, dynamic> | |
| 145 implements SemanticSendVisitor<ir.Primitive, dynamic> { | 144 implements SemanticSendVisitor<ir.Primitive, dynamic> { |
| 146 final TreeElements elements; | 145 final TreeElements elements; |
| 147 final Compiler compiler; | 146 final Compiler compiler; |
| 148 final SourceInformationBuilder sourceInformationBuilder; | 147 final SourceInformationBuilder sourceInformationBuilder; |
| 149 | 148 |
| 150 /// A map from try statements in the source to analysis information about | 149 /// A map from try statements in the source to analysis information about |
| 151 /// them. | 150 /// them. |
| 152 /// | 151 /// |
| 153 /// The analysis information includes the set of variables that must be | 152 /// The analysis information includes the set of variables that must be |
| 154 /// copied into [ir.MutableVariable]s on entry to the try and copied out on | 153 /// copied into [ir.MutableVariable]s on entry to the try and copied out on |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 171 // assigned in the delimited subexpression to their reaching definition --- | 170 // assigned in the delimited subexpression to their reaching definition --- |
| 172 // that is, the definition in effect at the hole in 'current'. These are | 171 // that is, the definition in effect at the hole in 'current'. These are |
| 173 // used to determine if a join-point continuation needs to be passed | 172 // used to determine if a join-point continuation needs to be passed |
| 174 // arguments, and what the arguments are. | 173 // arguments, and what the arguments are. |
| 175 | 174 |
| 176 /// Construct a top-level visitor. | 175 /// Construct a top-level visitor. |
| 177 IrBuilderVisitor(this.elements, | 176 IrBuilderVisitor(this.elements, |
| 178 this.compiler, | 177 this.compiler, |
| 179 this.sourceInformationBuilder); | 178 this.sourceInformationBuilder); |
| 180 | 179 |
| 181 @override | |
| 182 bulkHandleNode(ast.Node node, String message, _) { | |
| 183 giveup(node, message.replaceFirst('#', '$node')); | |
| 184 } | |
| 185 | |
| 186 String bailoutMessage = null; | 180 String bailoutMessage = null; |
| 187 | 181 |
| 188 @override | 182 @override |
| 189 ir.Primitive apply(ast.Node node, _) => node.accept(this); | 183 ir.Primitive apply(ast.Node node, _) => node.accept(this); |
| 190 | 184 |
| 191 @override | 185 @override |
| 192 SemanticSendVisitor get sendVisitor => this; | 186 SemanticSendVisitor get sendVisitor => this; |
| 193 | 187 |
| 194 /** | 188 /** |
| 195 * Builds the [ir.RootNode] for an executable element. In case the | 189 * Builds the [ir.RootNode] for an executable element. In case the |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 216 /// Normalizes the argument list of a dynamic invocation (i.e. where the | 210 /// Normalizes the argument list of a dynamic invocation (i.e. where the |
| 217 /// target element is unknown). | 211 /// target element is unknown). |
| 218 /// | 212 /// |
| 219 /// For the JS backend, normalizes order of named arguments. | 213 /// For the JS backend, normalizes order of named arguments. |
| 220 /// | 214 /// |
| 221 /// For the Dart backend, returns [arguments]. | 215 /// For the Dart backend, returns [arguments]. |
| 222 List<ir.Primitive> normalizeDynamicArguments( | 216 List<ir.Primitive> normalizeDynamicArguments( |
| 223 CallStructure callStructure, | 217 CallStructure callStructure, |
| 224 List<ir.Primitive> arguments); | 218 List<ir.Primitive> arguments); |
| 225 | 219 |
| 220 /// Creates a [TypedSelector] variant of [newSelector] using the type of | |
| 221 /// [oldSelector], if available. | |
| 222 /// | |
| 223 /// This is needed to preserve inferred receiver types when creating new | |
| 224 /// selectors. | |
| 225 Selector useSelectorType(Selector newSelector, Selector oldSelector) { | |
| 226 // TODO(asgerf,johnniwinther): This works but it is brittle. | |
| 227 // We should decouple selectors from inferred receiver type masks. | |
| 228 // TODO(asgerf): Use this whenever we create a selector for a dynamic call. | |
| 229 if (oldSelector is TypedSelector) { | |
| 230 return new TypedSelector(oldSelector.mask, newSelector, compiler.world); | |
| 231 } else { | |
| 232 return newSelector; | |
| 233 } | |
| 234 } | |
| 235 | |
| 236 /// Like [useSelectorType], except the original typed selector is obtained | |
| 237 /// from the [node]. | |
| 238 Selector useSelectorTypeOfNode(Selector newSelector, ast.Send node) { | |
| 239 return useSelectorType(newSelector, elements.getSelector(node)); | |
| 240 } | |
| 241 | |
| 226 ir.RootNode _makeFunctionBody(FunctionElement element, | 242 ir.RootNode _makeFunctionBody(FunctionElement element, |
| 227 ast.FunctionExpression node) { | 243 ast.FunctionExpression node) { |
| 228 FunctionSignature signature = element.functionSignature; | 244 FunctionSignature signature = element.functionSignature; |
| 229 List<ParameterElement> parameters = []; | 245 List<ParameterElement> parameters = []; |
| 230 signature.orderedForEachParameter(parameters.add); | 246 signature.orderedForEachParameter(parameters.add); |
| 231 | 247 |
| 232 irBuilder.buildFunctionHeader(parameters, | 248 irBuilder.buildFunctionHeader(parameters, |
| 233 closureScope: getClosureScopeForNode(node), | 249 closureScope: getClosureScopeForNode(node), |
| 234 env: getClosureEnvironment()); | 250 env: getClosureEnvironment()); |
| 235 | 251 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 node.entries.nodes.map((e) => e.key), | 623 node.entries.nodes.map((e) => e.key), |
| 608 node.entries.nodes.map((e) => e.value), | 624 node.entries.nodes.map((e) => e.value), |
| 609 build); | 625 build); |
| 610 } | 626 } |
| 611 | 627 |
| 612 ir.Primitive visitLiteralSymbol(ast.LiteralSymbol node) { | 628 ir.Primitive visitLiteralSymbol(ast.LiteralSymbol node) { |
| 613 assert(irBuilder.isOpen); | 629 assert(irBuilder.isOpen); |
| 614 return translateConstant(node); | 630 return translateConstant(node); |
| 615 } | 631 } |
| 616 | 632 |
| 617 ir.Primitive visitIdentifier(ast.Identifier node) { | |
| 618 // "this" is the only identifier that should be met by the visitor. | |
| 619 assert(node.isThis()); | |
| 620 return irBuilder.buildThis(); | |
| 621 } | |
| 622 | |
| 623 ir.Primitive visitParenthesizedExpression( | 633 ir.Primitive visitParenthesizedExpression( |
| 624 ast.ParenthesizedExpression node) { | 634 ast.ParenthesizedExpression node) { |
| 625 assert(irBuilder.isOpen); | 635 assert(irBuilder.isOpen); |
| 626 return visit(node.expression); | 636 return visit(node.expression); |
| 627 } | 637 } |
| 628 | 638 |
| 629 // Stores the result of visiting a CascadeReceiver, so we can return it from | 639 // Stores the result of visiting a CascadeReceiver, so we can return it from |
| 630 // its enclosing Cascade. | 640 // its enclosing Cascade. |
| 631 ir.Primitive _currentCascadeReceiver; | 641 ir.Primitive _currentCascadeReceiver; |
| 632 | 642 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 788 | 798 |
| 789 @override | 799 @override |
| 790 ir.Primitive visitSuperMethodGet( | 800 ir.Primitive visitSuperMethodGet( |
| 791 ast.Send node, | 801 ast.Send node, |
| 792 MethodElement method, | 802 MethodElement method, |
| 793 _) { | 803 _) { |
| 794 return irBuilder.buildSuperMethodGet(method); | 804 return irBuilder.buildSuperMethodGet(method); |
| 795 } | 805 } |
| 796 | 806 |
| 797 @override | 807 @override |
| 798 ir.Primitive visitUnresolvedGet( | |
| 799 ast.Send node, | |
| 800 Element element, | |
| 801 _) { | |
| 802 return giveup(node, 'visitUnresolvedGet'); | |
| 803 } | |
| 804 | |
| 805 @override | |
| 806 ir.Primitive visitUnresolvedSuperGet( | 808 ir.Primitive visitUnresolvedSuperGet( |
| 807 ast.Send node, | 809 ast.Send node, |
| 808 Element element, | 810 Element element, _) { |
| 809 _) { | 811 return buildInstanceNoSuchMethod(elements.getSelector(node), []); |
| 810 return giveup(node, 'visitUnresolvedSuperGet'); | |
| 811 } | 812 } |
| 812 | 813 |
| 813 @override | 814 @override |
| 814 ir.Primitive visitThisGet(ast.Identifier node, _) { | 815 ir.Primitive visitThisGet(ast.Identifier node, _) { |
| 816 if (irBuilder.state.thisParameter == null) { | |
| 817 // TODO(asgerf,johnniwinther): Should be in a visitInvalidThis method. | |
| 818 // 'this' in static context. Just translate to null. | |
| 819 assert(compiler.compilationFailed); | |
| 820 return irBuilder.buildNullConstant(); | |
| 821 } | |
| 815 return irBuilder.buildThis(); | 822 return irBuilder.buildThis(); |
| 816 } | 823 } |
| 817 | 824 |
| 818 ir.Primitive translateTypeVariableTypeLiteral(TypeVariableElement element) { | 825 ir.Primitive translateTypeVariableTypeLiteral(TypeVariableElement element) { |
| 819 return buildReifyTypeVariable(irBuilder.buildThis(), element.type); | 826 return buildReifyTypeVariable(irBuilder.buildThis(), element.type); |
| 820 } | 827 } |
| 821 | 828 |
| 822 @override | 829 @override |
| 823 ir.Primitive visitTypeVariableTypeLiteralGet(ast.Send node, | 830 ir.Primitive visitTypeVariableTypeLiteralGet(ast.Send node, |
| 824 TypeVariableElement element, _) { | 831 TypeVariableElement element, _) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 926 ir.Primitive visitSuperBinary( | 933 ir.Primitive visitSuperBinary( |
| 927 ast.Send node, | 934 ast.Send node, |
| 928 FunctionElement function, | 935 FunctionElement function, |
| 929 op.BinaryOperator operator, | 936 op.BinaryOperator operator, |
| 930 ast.Node argument, | 937 ast.Node argument, |
| 931 _) { | 938 _) { |
| 932 return translateSuperBinary(function, operator, argument); | 939 return translateSuperBinary(function, operator, argument); |
| 933 } | 940 } |
| 934 | 941 |
| 935 @override | 942 @override |
| 936 ir.Primitive visitUnresolvedSuperBinary( | |
| 937 ast.Send node, | |
| 938 Element element, | |
| 939 op.BinaryOperator operator, | |
| 940 ast.Node argument, | |
| 941 _) { | |
| 942 return giveup(node, 'visitUnresolvedSuperBinary'); | |
| 943 } | |
| 944 | |
| 945 @override | |
| 946 ir.Primitive visitSuperIndex( | 943 ir.Primitive visitSuperIndex( |
| 947 ast.Send node, | 944 ast.Send node, |
| 948 FunctionElement function, | 945 FunctionElement function, |
| 949 ast.Node index, | 946 ast.Node index, |
| 950 _) { | 947 _) { |
| 951 return irBuilder.buildSuperIndex(function, visit(index)); | 948 return irBuilder.buildSuperIndex(function, visit(index)); |
| 952 } | 949 } |
| 953 | 950 |
| 954 @override | 951 @override |
| 955 ir.Primitive visitUnresolvedSuperIndex( | |
| 956 ast.Send node, | |
| 957 Element element, | |
| 958 ast.Node index, | |
| 959 _) { | |
| 960 return giveup(node, 'visitUnresolvedSuperIndex'); | |
| 961 } | |
| 962 | |
| 963 @override | |
| 964 ir.Primitive visitEquals( | 952 ir.Primitive visitEquals( |
| 965 ast.Send node, | 953 ast.Send node, |
| 966 ast.Node left, | 954 ast.Node left, |
| 967 ast.Node right, | 955 ast.Node right, |
| 968 _) { | 956 _) { |
| 969 return translateBinary(left, op.BinaryOperator.EQ, right); | 957 return translateBinary(left, op.BinaryOperator.EQ, right); |
| 970 } | 958 } |
| 971 | 959 |
| 972 @override | 960 @override |
| 973 ir.Primitive visitSuperEquals( | 961 ir.Primitive visitSuperEquals( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1021 @override | 1009 @override |
| 1022 ir.Primitive visitSuperUnary( | 1010 ir.Primitive visitSuperUnary( |
| 1023 ast.Send node, | 1011 ast.Send node, |
| 1024 op.UnaryOperator operator, | 1012 op.UnaryOperator operator, |
| 1025 FunctionElement function, | 1013 FunctionElement function, |
| 1026 _) { | 1014 _) { |
| 1027 return irBuilder.buildSuperMethodInvocation( | 1015 return irBuilder.buildSuperMethodInvocation( |
| 1028 function, CallStructure.NO_ARGS, const []); | 1016 function, CallStructure.NO_ARGS, const []); |
| 1029 } | 1017 } |
| 1030 | 1018 |
| 1031 @override | |
| 1032 ir.Primitive visitUnresolvedSuperUnary( | |
| 1033 ast.Send node, | |
| 1034 op.UnaryOperator operator, | |
| 1035 Element element, | |
| 1036 _) { | |
| 1037 return giveup(node, 'visitUnresolvedSuperUnary'); | |
| 1038 } | |
| 1039 | |
| 1040 // TODO(johnniwinther): Handle this in the [IrBuilder] to ensure the correct | 1019 // TODO(johnniwinther): Handle this in the [IrBuilder] to ensure the correct |
| 1041 // semantic correlation between arguments and invocation. | 1020 // semantic correlation between arguments and invocation. |
| 1042 List<ir.Primitive> translateDynamicArguments(ast.NodeList nodeList, | 1021 List<ir.Primitive> translateDynamicArguments(ast.NodeList nodeList, |
| 1043 CallStructure callStructure) { | 1022 CallStructure callStructure) { |
| 1044 List<ir.Primitive> arguments = nodeList.nodes.mapToList(visit); | 1023 List<ir.Primitive> arguments = nodeList.nodes.mapToList(visit); |
| 1045 return normalizeDynamicArguments(callStructure, arguments); | 1024 return normalizeDynamicArguments(callStructure, arguments); |
| 1046 } | 1025 } |
| 1047 | 1026 |
| 1048 // TODO(johnniwinther): Handle this in the [IrBuilder] to ensure the correct | 1027 // TODO(johnniwinther): Handle this in the [IrBuilder] to ensure the correct |
| 1049 // semantic correlation between arguments and invocation. | 1028 // semantic correlation between arguments and invocation. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1133 return irBuilder.buildStaticFunctionInvocation(function, callStructure, | 1112 return irBuilder.buildStaticFunctionInvocation(function, callStructure, |
| 1134 translateStaticArguments(arguments, function, callStructure), | 1113 translateStaticArguments(arguments, function, callStructure), |
| 1135 sourceInformation: sourceInformationBuilder.buildCall(node)); | 1114 sourceInformation: sourceInformationBuilder.buildCall(node)); |
| 1136 } | 1115 } |
| 1137 | 1116 |
| 1138 @override | 1117 @override |
| 1139 ir.Primitive handleStaticFunctionIncompatibleInvoke( | 1118 ir.Primitive handleStaticFunctionIncompatibleInvoke( |
| 1140 ast.Send node, | 1119 ast.Send node, |
| 1141 MethodElement function, | 1120 MethodElement function, |
| 1142 ast.NodeList arguments, | 1121 ast.NodeList arguments, |
| 1143 CallStructure callStructure, | 1122 CallStructure callStructure, _) { |
|
Kevin Millikin (Google)
2015/05/08 08:30:06
I liked the old indentation better. I can't extra
asgerf
2015/05/08 09:38:57
It's a judgement call. Irrelevant details can turn
| |
| 1144 _) { | 1123 return buildStaticNoSuchMethod( |
| 1145 return giveup(node, 'handleStaticFunctionIncompatibleInvoke'); | 1124 elements.getSelector(node), |
| 1125 arguments.nodes.mapToList(visit)); | |
| 1146 } | 1126 } |
| 1147 | 1127 |
| 1148 @override | 1128 @override |
| 1149 ir.Primitive handleStaticGetterInvoke( | 1129 ir.Primitive handleStaticGetterInvoke( |
| 1150 ast.Send node, | 1130 ast.Send node, |
| 1151 FunctionElement getter, | 1131 FunctionElement getter, |
| 1152 ast.NodeList arguments, | 1132 ast.NodeList arguments, |
| 1153 CallStructure callStructure, | 1133 CallStructure callStructure, |
| 1154 _) { | 1134 _) { |
| 1155 if (getter.isForeign(compiler.backend)) { | 1135 if (getter.isForeign(compiler.backend)) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1196 _) { | 1176 _) { |
| 1197 return irBuilder.buildSuperMethodInvocation(method, callStructure, | 1177 return irBuilder.buildSuperMethodInvocation(method, callStructure, |
| 1198 translateDynamicArguments(arguments, callStructure)); | 1178 translateDynamicArguments(arguments, callStructure)); |
| 1199 } | 1179 } |
| 1200 | 1180 |
| 1201 @override | 1181 @override |
| 1202 ir.Primitive visitSuperMethodIncompatibleInvoke( | 1182 ir.Primitive visitSuperMethodIncompatibleInvoke( |
| 1203 ast.Send node, | 1183 ast.Send node, |
| 1204 MethodElement method, | 1184 MethodElement method, |
| 1205 ast.NodeList arguments, | 1185 ast.NodeList arguments, |
| 1206 CallStructure callStructure, | 1186 CallStructure callStructure, _) { |
| 1207 _) { | 1187 return buildInstanceNoSuchMethod( |
| 1208 return giveup(node, 'visitSuperMethodIncompatibleInvoke'); | 1188 elements.getSelector(node), |
| 1189 translateDynamicArguments(arguments, callStructure)); | |
| 1209 } | 1190 } |
| 1210 | 1191 |
| 1211 @override | 1192 @override |
| 1212 ir.Primitive visitUnresolvedInvoke( | |
| 1213 ast.Send node, | |
| 1214 Element element, | |
| 1215 ast.NodeList arguments, | |
| 1216 Selector selector, | |
| 1217 _) { | |
| 1218 return giveup(node, 'visitUnresolvedInvoke'); | |
| 1219 } | |
| 1220 | |
| 1221 @override | |
| 1222 ir.Primitive visitUnresolvedSuperInvoke( | 1193 ir.Primitive visitUnresolvedSuperInvoke( |
| 1223 ast.Send node, | 1194 ast.Send node, |
| 1224 Element element, | 1195 Element element, |
| 1225 ast.NodeList arguments, | 1196 ast.NodeList arguments, |
| 1226 Selector selector, | 1197 Selector selector, _) { |
| 1227 _) { | 1198 return buildInstanceNoSuchMethod( |
| 1228 return giveup(node, 'visitUnresolvedSuperInvoke'); | 1199 elements.getSelector(node), |
| 1200 translateDynamicArguments(arguments, selector.callStructure)); | |
| 1229 } | 1201 } |
| 1230 | 1202 |
| 1231 @override | 1203 @override |
| 1232 ir.Primitive visitThisInvoke( | 1204 ir.Primitive visitThisInvoke( |
| 1233 ast.Send node, | 1205 ast.Send node, |
| 1234 ast.NodeList arguments, | 1206 ast.NodeList arguments, |
| 1235 CallStructure callStructure, | 1207 CallStructure callStructure, |
| 1236 _) { | 1208 _) { |
| 1237 return translateCallInvoke(irBuilder.buildThis(), arguments, callStructure); | 1209 return translateCallInvoke(irBuilder.buildThis(), arguments, callStructure); |
| 1238 } | 1210 } |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1860 return irBuilder.buildConstant(getConstantForNode(node)); | 1832 return irBuilder.buildConstant(getConstantForNode(node)); |
| 1861 } | 1833 } |
| 1862 | 1834 |
| 1863 ir.Primitive visitThrow(ast.Throw node) { | 1835 ir.Primitive visitThrow(ast.Throw node) { |
| 1864 assert(irBuilder.isOpen); | 1836 assert(irBuilder.isOpen); |
| 1865 // This function is not called for throw expressions occurring as | 1837 // This function is not called for throw expressions occurring as |
| 1866 // statements. | 1838 // statements. |
| 1867 return irBuilder.buildNonTailThrow(visit(node.expression)); | 1839 return irBuilder.buildNonTailThrow(visit(node.expression)); |
| 1868 } | 1840 } |
| 1869 | 1841 |
| 1842 ir.Primitive buildStaticNoSuchMethod( | |
| 1843 Selector selector, | |
| 1844 List<ir.Primitive> arguments); | |
| 1845 | |
| 1846 ir.Primitive buildInstanceNoSuchMethod( | |
| 1847 Selector selector, | |
| 1848 List<ir.Primitive> arguments); | |
| 1849 | |
| 1850 ir.Primitive buildRuntimeError(String message); | |
| 1851 | |
| 1852 ir.Primitive buildAbstractClassInstantiationError(ClassElement element); | |
| 1853 | |
| 1854 @override | |
| 1855 ir.Primitive errorInvalidAssert( | |
| 1856 ast.Send node, | |
| 1857 ast.NodeList arguments, _) { | |
| 1858 if (compiler.enableUserAssertions) { | |
| 1859 return giveup(node, 'Assert'); | |
| 1860 } else { | |
| 1861 return irBuilder.buildNullConstant(); | |
| 1862 } | |
| 1863 } | |
| 1864 | |
| 1865 @override | |
| 1866 ir.Primitive errorUnresolvedCompound( | |
| 1867 ast.Send node, | |
| 1868 Element element, | |
| 1869 op.AssignmentOperator operator, | |
| 1870 ast.Node rhs, _) { | |
| 1871 // TODO(asgerf): What is unresolved? The getter and/or the setter? | |
| 1872 // If it was th setter, we must evaluate right-hand side. | |
|
floitsch
2015/05/08 03:03:40
was th*e* setter, we must evaluate *the* right-han
asgerf
2015/05/08 08:17:58
Done.
| |
| 1873 return buildStaticNoSuchMethod(elements.getSelector(node), []); | |
| 1874 } | |
| 1875 | |
| 1876 @override | |
| 1877 ir.Primitive visitUnresolvedClassConstructorInvoke( | |
| 1878 ast.NewExpression node, | |
| 1879 Element element, | |
| 1880 DartType type, | |
| 1881 ast.NodeList arguments, | |
| 1882 Selector selector, _) { | |
| 1883 // If the class is missing it's a runtime error. | |
| 1884 return buildRuntimeError("Unresolved class: '${element.name}'"); | |
| 1885 } | |
| 1886 | |
| 1887 @override | |
| 1888 ir.Primitive visitUnresolvedConstructorInvoke( | |
| 1889 ast.NewExpression node, | |
| 1890 Element constructor, | |
| 1891 DartType type, | |
| 1892 ast.NodeList arguments, | |
| 1893 Selector selector, _) { | |
| 1894 // If the class is there but the constructor is missing, it's an NSM error. | |
| 1895 return buildStaticNoSuchMethod(selector, | |
| 1896 translateDynamicArguments(arguments, selector.callStructure)); | |
| 1897 } | |
| 1898 | |
| 1899 @override | |
| 1900 ir.Primitive errorNonConstantConstructorInvoke( | |
| 1901 ast.NewExpression node, | |
| 1902 Element element, | |
| 1903 InterfaceType type, | |
| 1904 ast.NodeList arguments, | |
| 1905 CallStructure callStructure, _) { | |
| 1906 assert(compiler.compilationFailed); | |
| 1907 return irBuilder.buildNullConstant(); | |
| 1908 } | |
| 1909 | |
| 1910 @override | |
| 1911 ir.Primitive visitUnresolvedGet( | |
| 1912 ast.Send node, | |
| 1913 Element element, _) { | |
| 1914 return buildStaticNoSuchMethod(elements.getSelector(node), []); | |
| 1915 } | |
| 1916 | |
| 1917 @override | |
| 1918 ir.Primitive visitUnresolvedInvoke( | |
| 1919 ast.Send node, | |
| 1920 Element element, | |
| 1921 ast.NodeList arguments, | |
| 1922 Selector selector, _) { | |
| 1923 return buildStaticNoSuchMethod(elements.getSelector(node), | |
| 1924 arguments.nodes.mapToList(visit)); | |
| 1925 } | |
| 1926 | |
| 1927 @override | |
| 1928 ir.Primitive errorUnresolvedPostfix( | |
| 1929 ast.Send node, | |
| 1930 Element element, | |
| 1931 op.IncDecOperator operator, _) { | |
| 1932 // TODO(asgerf): Which ones are missing? The getter and/or the setter? | |
| 1933 return buildStaticNoSuchMethod(elements.getSelector(node), []); | |
| 1934 } | |
| 1935 | |
| 1936 @override | |
| 1937 ir.Primitive errorUnresolvedPrefix( | |
| 1938 ast.Send node, | |
| 1939 Element element, | |
| 1940 op.IncDecOperator operator, _) { | |
| 1941 // TODO(asgerf): Which ones are missing? The getter and/or the setter? | |
| 1942 return buildStaticNoSuchMethod(elements.getSelector(node), []); | |
| 1943 } | |
| 1944 | |
| 1945 @override | |
| 1946 ir.Primitive visitUnresolvedRedirectingFactoryConstructorInvoke( | |
| 1947 ast.NewExpression node, | |
| 1948 ConstructorElement constructor, | |
| 1949 InterfaceType type, | |
| 1950 ast.NodeList arguments, | |
| 1951 CallStructure callStructure, _) { | |
| 1952 String nameString = Elements.reconstructConstructorName(constructor); | |
| 1953 Name name = new Name(nameString, constructor.library); | |
| 1954 return buildStaticNoSuchMethod( | |
| 1955 new Selector(SelectorKind.CALL, name, callStructure), | |
| 1956 translateDynamicArguments(arguments, callStructure)); | |
| 1957 } | |
| 1958 | |
| 1959 @override | |
| 1960 ir.Primitive errorUnresolvedSet( | |
| 1961 ast.Send node, | |
| 1962 Element element, | |
| 1963 ast.Node rhs, _) { | |
| 1964 return buildStaticNoSuchMethod(elements.getSelector(node), [visit(rhs)]); | |
|
Kevin Millikin (Google)
2015/05/08 08:30:06
I'd rather name the value of visit(rhs). I'm alle
asgerf
2015/05/08 09:38:57
The real problem is the repetitive code. If we wer
| |
| 1965 } | |
| 1966 | |
| 1967 @override | |
| 1968 ir.Primitive errorUnresolvedSuperCompoundIndexSet( | |
| 1969 ast.SendSet node, | |
| 1970 Element element, | |
| 1971 ast.Node index, | |
| 1972 op.AssignmentOperator operator, | |
| 1973 ast.Node rhs, _) { | |
| 1974 // Assume the index getter is missing. | |
| 1975 Selector selector = useSelectorTypeOfNode(new Selector.index(), node); | |
| 1976 return buildInstanceNoSuchMethod(selector, [visit(index)]); | |
| 1977 } | |
| 1978 | |
| 1979 @override | |
| 1980 ir.Primitive visitUnresolvedSuperIndex( | |
| 1981 ast.Send node, | |
| 1982 Element function, | |
| 1983 ast.Node index, _) { | |
| 1984 // Assume the index getter is missing. | |
| 1985 Selector selector = useSelectorTypeOfNode(new Selector.index(), node); | |
| 1986 return buildInstanceNoSuchMethod(selector, [visit(index)]); | |
| 1987 } | |
| 1988 | |
| 1989 @override | |
| 1990 ir.Primitive errorUnresolvedSuperIndexPostfix( | |
| 1991 ast.Send node, | |
| 1992 Element function, | |
| 1993 ast.Node index, | |
| 1994 op.IncDecOperator operator, _) { | |
| 1995 // Assume the index getter is missing. | |
| 1996 Selector selector = useSelectorTypeOfNode(new Selector.index(), node); | |
| 1997 return buildInstanceNoSuchMethod(selector, [visit(index)]); | |
| 1998 } | |
| 1999 | |
| 2000 @override | |
| 2001 ir.Primitive errorUnresolvedSuperIndexPrefix( | |
| 2002 ast.Send node, | |
| 2003 Element function, | |
| 2004 ast.Node index, | |
| 2005 op.IncDecOperator operator, _) { | |
| 2006 // Assume the index getter is missing. | |
| 2007 Selector selector = useSelectorTypeOfNode(new Selector.index(), node); | |
| 2008 return buildInstanceNoSuchMethod(selector, [visit(index)]); | |
| 2009 } | |
| 2010 | |
| 2011 @override | |
| 2012 ir.Primitive errorUnresolvedSuperIndexSet( | |
| 2013 ast.SendSet node, | |
| 2014 Element element, | |
| 2015 ast.Node index, | |
| 2016 ast.Node rhs, _) { | |
| 2017 Selector selector = useSelectorTypeOfNode(new Selector.index(), node); | |
| 2018 return buildInstanceNoSuchMethod( | |
| 2019 selector, | |
| 2020 [visit(index), visit(rhs)]); | |
| 2021 } | |
| 2022 | |
| 2023 @override | |
| 2024 ir.Primitive visitUnresolvedSuperBinary( | |
| 2025 ast.Send node, | |
| 2026 Element element, | |
| 2027 op.BinaryOperator operator, | |
| 2028 ast.Node argument, _) { | |
| 2029 return buildInstanceNoSuchMethod( | |
| 2030 elements.getSelector(node), | |
| 2031 [visit(argument)]); | |
| 2032 } | |
| 2033 | |
| 2034 @override | |
| 2035 ir.Primitive visitUnresolvedSuperUnary( | |
| 2036 ast.Send node, | |
| 2037 op.UnaryOperator operator, | |
| 2038 Element element, _) { | |
| 2039 return buildInstanceNoSuchMethod(elements.getSelector(node), []); | |
| 2040 } | |
| 2041 | |
| 2042 @override | |
| 2043 ir.Primitive errorUndefinedBinaryExpression( | |
| 2044 ast.Send node, | |
| 2045 ast.Node left, | |
| 2046 ast.Operator operator, | |
| 2047 ast.Node right, _) { | |
| 2048 assert(compiler.compilationFailed); | |
| 2049 return irBuilder.buildNullConstant(); | |
| 2050 } | |
| 2051 | |
| 2052 @override | |
| 2053 ir.Primitive errorUndefinedUnaryExpression( | |
| 2054 ast.Send node, | |
| 2055 ast.Operator operator, | |
| 2056 ast.Node expression, _) { | |
| 2057 assert(compiler.compilationFailed); | |
| 2058 return irBuilder.buildNullConstant(); | |
| 2059 } | |
| 2060 | |
| 2061 @override | |
| 2062 ir.Primitive errorTopLevelFunctionSet( | |
| 2063 ast.Send node, | |
| 2064 MethodElement function, | |
| 2065 ast.Node rhs, _) { | |
| 2066 return buildStaticNoSuchMethod( | |
| 2067 new Selector.setter(function.name, function.library), | |
| 2068 [visit(rhs)]); | |
| 2069 } | |
| 2070 | |
| 2071 @override | |
| 2072 ir.Primitive errorTopLevelSetterGet( | |
| 2073 ast.Send node, | |
| 2074 FunctionElement setter, _) { | |
| 2075 return buildStaticNoSuchMethod( | |
| 2076 new Selector.getter(setter.name, setter.library), []); | |
| 2077 } | |
| 2078 | |
| 2079 @override | |
| 2080 ir.Primitive errorTopLevelGetterSet( | |
| 2081 ast.SendSet node, | |
| 2082 FunctionElement getter, | |
| 2083 ast.Node rhs, _) { | |
| 2084 return buildStaticNoSuchMethod( | |
| 2085 new Selector.setter(getter.name, getter.library), | |
| 2086 [visit(rhs)]); | |
| 2087 } | |
| 2088 | |
| 2089 @override | |
| 2090 ir.Primitive errorTopLevelSetterInvoke( | |
| 2091 ast.Send node, | |
| 2092 FunctionElement setter, | |
| 2093 ast.NodeList arguments, | |
| 2094 CallStructure callStructure, _) { | |
| 2095 return buildStaticNoSuchMethod( | |
| 2096 new Selector.getter(setter.name, setter.library), []); | |
| 2097 } | |
| 2098 | |
| 2099 @override | |
| 2100 ir.Primitive errorClassTypeLiteralSet( | |
| 2101 ast.SendSet node, | |
| 2102 TypeConstantExpression constant, | |
| 2103 ast.Node rhs, _) { | |
| 2104 InterfaceType type = constant.type; | |
| 2105 ClassElement element = type.element; | |
| 2106 return buildStaticNoSuchMethod( | |
| 2107 new Selector.setter(element.name, element.library), [visit(rhs)]); | |
| 2108 } | |
| 2109 | |
| 2110 @override | |
| 2111 ir.Primitive errorTypedefTypeLiteralSet( | |
| 2112 ast.SendSet node, | |
| 2113 TypeConstantExpression constant, | |
| 2114 ast.Node rhs, _) { | |
| 2115 TypedefType type = constant.type; | |
| 2116 TypedefElement element = type.element; | |
| 2117 return buildStaticNoSuchMethod( | |
| 2118 new Selector.setter(element.name, element.library), [visit(rhs)]); | |
| 2119 } | |
| 2120 | |
| 2121 @override | |
| 2122 ir.Primitive errorTypeVariableTypeLiteralSet( | |
| 2123 ast.SendSet node, | |
| 2124 TypeVariableElement element, | |
| 2125 ast.Node rhs, _) { | |
| 2126 return buildStaticNoSuchMethod( | |
| 2127 new Selector.setter(element.name, element.library), [visit(rhs)]); | |
| 2128 } | |
| 2129 | |
| 2130 @override | |
| 2131 ir.Primitive errorDynamicTypeLiteralSet( | |
| 2132 ast.SendSet node, | |
| 2133 ConstantExpression constant, | |
| 2134 ast.Node rhs, _) { | |
| 2135 return buildStaticNoSuchMethod( | |
| 2136 new Selector.setter('dynamic', null), [visit(rhs)]); | |
| 2137 } | |
| 2138 | |
| 2139 @override | |
| 2140 ir.Primitive visitAbstractClassConstructorInvoke( | |
| 2141 ast.NewExpression node, | |
| 2142 ConstructorElement element, | |
| 2143 InterfaceType type, | |
| 2144 ast.NodeList arguments, | |
| 2145 CallStructure callStructure, _) { | |
| 2146 return buildAbstractClassInstantiationError(element.enclosingClass); | |
| 2147 } | |
| 2148 | |
| 2149 @override | |
| 2150 ir.Primitive errorClassTypeLiteralCompound( | |
| 2151 ast.Send node, | |
| 2152 ConstantExpression constant, | |
| 2153 op.AssignmentOperator operator, | |
| 2154 ast.Node rhs, _) { | |
| 2155 return translateCompound( | |
| 2156 getValue: () => irBuilder.buildConstant(constant), | |
| 2157 operator: operator, | |
| 2158 rhs: rhs, | |
| 2159 setValue: (value) {}); // The binary operator will throw before this. | |
| 2160 } | |
| 2161 | |
| 2162 @override | |
| 2163 ir.Primitive errorClassTypeLiteralPostfix( | |
| 2164 ast.Send node, | |
| 2165 ConstantExpression constant, | |
| 2166 op.IncDecOperator operator, _) { | |
| 2167 String text = constant.getText(); | |
|
floitsch
2015/05/08 03:03:40
unused
asgerf
2015/05/08 08:17:59
Thanks.
| |
| 2168 return translatePrefixPostfix( | |
| 2169 getValue: () => irBuilder.buildConstant(constant), | |
| 2170 operator: operator, | |
| 2171 setValue: (value) {}, // The binary operator will throw before this. | |
| 2172 isPrefix: false); | |
| 2173 } | |
| 2174 | |
| 2175 @override | |
| 2176 ir.Primitive errorClassTypeLiteralPrefix( | |
| 2177 ast.Send node, | |
| 2178 ConstantExpression constant, | |
| 2179 op.IncDecOperator operator, _) { | |
| 2180 String text = constant.getText(); | |
|
floitsch
2015/05/08 03:03:40
unused.
asgerf
2015/05/08 08:17:59
Done.
| |
| 2181 return translatePrefixPostfix( | |
| 2182 getValue: () => irBuilder.buildConstant(constant), | |
| 2183 operator: operator, | |
| 2184 setValue: (value) {}, // The binary operator will throw before this. | |
| 2185 isPrefix: true); | |
| 2186 } | |
| 2187 | |
| 2188 @override | |
| 2189 ir.Primitive errorDynamicTypeLiteralCompound( | |
| 2190 ast.Send node, | |
| 2191 ConstantExpression constant, | |
| 2192 op.AssignmentOperator operator, | |
| 2193 ast.Node rhs, _) { | |
| 2194 return translateCompound( | |
| 2195 getValue: () => irBuilder.buildConstant(constant), | |
| 2196 operator: operator, | |
| 2197 rhs: rhs, | |
| 2198 setValue: (value) {}); // The binary operator will throw before this. | |
| 2199 } | |
| 2200 | |
| 2201 @override | |
| 2202 ir.Primitive errorDynamicTypeLiteralPostfix( | |
| 2203 ast.Send node, | |
| 2204 ConstantExpression constant, | |
| 2205 op.IncDecOperator operator, _) { | |
| 2206 return translatePrefixPostfix( | |
| 2207 getValue: () => irBuilder.buildConstant(constant), | |
| 2208 operator: operator, | |
| 2209 setValue: (value) {}, // The binary operator will throw before this. | |
| 2210 isPrefix: false); | |
| 2211 } | |
| 2212 | |
| 2213 @override | |
| 2214 ir.Primitive errorDynamicTypeLiteralPrefix( | |
| 2215 ast.Send node, | |
| 2216 ConstantExpression constant, | |
| 2217 op.IncDecOperator operator, _) { | |
| 2218 return translatePrefixPostfix( | |
| 2219 getValue: () => irBuilder.buildConstant(constant), | |
| 2220 operator: operator, | |
| 2221 setValue: (value) {}, // The binary operator will throw before this. | |
| 2222 isPrefix: true); | |
| 2223 } | |
| 2224 | |
| 2225 @override | |
| 2226 ir.Primitive errorFinalLocalVariableCompound( | |
| 2227 ast.Send node, | |
| 2228 LocalVariableElement variable, | |
| 2229 op.AssignmentOperator operator, | |
| 2230 ast.Node rhs, _) { | |
| 2231 Selector selector = new Selector.setter(variable.name, null); | |
| 2232 return translateCompound( | |
| 2233 getValue: () => irBuilder.buildLocalVariableGet(variable), | |
| 2234 operator: operator, | |
| 2235 rhs: rhs, | |
| 2236 setValue: (value) => buildStaticNoSuchMethod(selector, [value])); | |
| 2237 } | |
| 2238 | |
| 2239 @override | |
| 2240 ir.Primitive errorFinalLocalVariableSet( | |
| 2241 ast.SendSet node, | |
| 2242 LocalVariableElement variable, | |
| 2243 ast.Node rhs, _) { | |
| 2244 Selector selector = new Selector.setter(variable.name, null); | |
| 2245 return buildStaticNoSuchMethod(selector, [visit(rhs)]); | |
| 2246 } | |
| 2247 | |
| 2248 @override | |
| 2249 ir.Primitive errorFinalParameterCompound( | |
| 2250 ast.Send node, | |
| 2251 ParameterElement parameter, | |
| 2252 op.AssignmentOperator operator, | |
| 2253 ast.Node rhs, _) { | |
| 2254 Selector selector = new Selector.setter(parameter.name, null); | |
| 2255 return translateCompound( | |
| 2256 getValue: () => irBuilder.buildLocalVariableGet(parameter), | |
| 2257 operator: operator, | |
| 2258 rhs: rhs, | |
| 2259 setValue: (value) => buildStaticNoSuchMethod(selector, [value])); | |
| 2260 } | |
| 2261 | |
| 2262 @override | |
| 2263 ir.Primitive errorFinalParameterSet( | |
| 2264 ast.SendSet node, | |
| 2265 ParameterElement parameter, | |
| 2266 ast.Node rhs, _) { | |
| 2267 Selector selector = new Selector.setter(parameter.name, null); | |
| 2268 return buildStaticNoSuchMethod(selector, [visit(rhs)]); | |
| 2269 } | |
| 2270 | |
| 2271 @override | |
| 2272 ir.Primitive errorFinalStaticFieldCompound( | |
| 2273 ast.Send node, | |
| 2274 FieldElement field, | |
| 2275 op.AssignmentOperator operator, | |
| 2276 ast.Node rhs, _) { | |
| 2277 return translateCompound( | |
| 2278 getValue: () => irBuilder.buildStaticFieldGet(field), | |
| 2279 operator: operator, | |
| 2280 rhs: rhs, | |
| 2281 setValue: (value) => buildStaticNoSuchMethod( | |
| 2282 new Selector.setter(field.name, field.library), [value])); | |
| 2283 } | |
| 2284 | |
| 2285 @override | |
| 2286 ir.Primitive errorFinalStaticFieldSet( | |
| 2287 ast.SendSet node, | |
| 2288 FieldElement field, | |
| 2289 ast.Node rhs, _) { | |
| 2290 // TODO(asgerf): Include class name somehow? | |
| 2291 return buildStaticNoSuchMethod( | |
| 2292 new Selector.setter(field.name, field.library), | |
| 2293 [visit(rhs)]); | |
| 2294 } | |
| 2295 | |
| 2296 @override | |
| 2297 ir.Primitive errorFinalSuperFieldCompound( | |
| 2298 ast.Send node, | |
| 2299 FieldElement field, | |
| 2300 op.AssignmentOperator operator, | |
| 2301 ast.Node rhs, _) { | |
| 2302 Selector selector = useSelectorTypeOfNode( | |
| 2303 new Selector.setter(field.name, field.library), | |
| 2304 node); | |
| 2305 return translateCompound( | |
| 2306 getValue: () => irBuilder.buildSuperFieldGet(field), | |
| 2307 operator: operator, | |
| 2308 rhs: rhs, | |
| 2309 setValue: (value) => buildInstanceNoSuchMethod(selector, [value])); | |
| 2310 } | |
| 2311 | |
| 2312 @override | |
| 2313 ir.Primitive errorFinalSuperFieldSet( | |
| 2314 ast.SendSet node, | |
| 2315 FieldElement field, | |
| 2316 ast.Node rhs, _) { | |
| 2317 Selector selector = useSelectorTypeOfNode( | |
| 2318 new Selector.setter(field.name, field.library), | |
| 2319 node); | |
| 2320 return buildInstanceNoSuchMethod(selector, [visit(rhs)]); | |
| 2321 } | |
| 2322 | |
| 2323 @override | |
| 2324 ir.Primitive errorFinalTopLevelFieldCompound( | |
| 2325 ast.Send node, | |
| 2326 FieldElement field, | |
| 2327 op.AssignmentOperator operator, | |
| 2328 ast.Node rhs, _) { | |
| 2329 return translateCompound( | |
| 2330 getValue: () => irBuilder.buildStaticFieldGet(field), | |
| 2331 operator: operator, | |
| 2332 rhs: rhs, | |
| 2333 setValue: (value) => buildStaticNoSuchMethod( | |
| 2334 new Selector.setter(field.name, field.library), [value])); | |
| 2335 } | |
| 2336 | |
| 2337 @override | |
| 2338 ir.Primitive errorFinalTopLevelFieldSet( | |
| 2339 ast.SendSet node, | |
| 2340 FieldElement field, | |
| 2341 ast.Node rhs, _) { | |
| 2342 return buildStaticNoSuchMethod( | |
| 2343 new Selector.setter(field.name, field.library), | |
| 2344 [visit(rhs)]); | |
| 2345 } | |
| 2346 | |
| 2347 @override | |
| 2348 ir.Primitive errorLocalFunctionCompound( | |
| 2349 ast.Send node, | |
| 2350 LocalFunctionElement function, | |
| 2351 op.AssignmentOperator operator, | |
| 2352 ast.Node rhs, _) { | |
| 2353 return translateCompound( | |
| 2354 getValue: () => irBuilder.buildLocalFunctionGet(function), | |
| 2355 operator: operator, | |
| 2356 rhs: rhs, | |
| 2357 setValue: (value) {}); // Binary operator will throw before this. | |
| 2358 } | |
| 2359 | |
| 2360 @override | |
| 2361 ir.Primitive errorLocalFunctionPostfix( | |
| 2362 ast.Send node, | |
| 2363 LocalFunctionElement function, | |
| 2364 op.IncDecOperator operator, | |
| 2365 _) { | |
| 2366 return translatePrefixPostfix( | |
| 2367 getValue: () => irBuilder.buildLocalFunctionGet(function), | |
| 2368 operator: operator, | |
| 2369 setValue: (value) {}, // Binary operator will throw before this. | |
| 2370 isPrefix: false); | |
| 2371 } | |
| 2372 | |
| 2373 @override | |
| 2374 ir.Primitive errorLocalFunctionPrefix( | |
| 2375 ast.Send node, | |
| 2376 LocalFunctionElement function, | |
| 2377 op.IncDecOperator operator, | |
| 2378 _) { | |
| 2379 return translatePrefixPostfix( | |
| 2380 getValue: () => irBuilder.buildLocalFunctionGet(function), | |
| 2381 operator: operator, | |
| 2382 setValue: (value) {}, // Binary operator will throw before this. | |
| 2383 isPrefix: true); | |
| 2384 } | |
| 2385 | |
| 2386 @override | |
| 2387 ir.Primitive errorLocalFunctionSet( | |
| 2388 ast.SendSet node, | |
| 2389 LocalFunctionElement function, | |
| 2390 ast.Node rhs, _) { | |
| 2391 return buildStaticNoSuchMethod( | |
| 2392 new Selector.setter(function.name, null), | |
| 2393 [visit(rhs)]); | |
| 2394 } | |
| 2395 | |
| 2396 @override | |
| 2397 ir.Primitive errorStaticFunctionSet( | |
| 2398 ast.Send node, | |
| 2399 MethodElement function, | |
| 2400 ast.Node rhs, | |
| 2401 _) { | |
| 2402 return buildStaticNoSuchMethod( | |
| 2403 new Selector.setter(function.name, function.library), | |
| 2404 [visit(rhs)]); | |
| 2405 } | |
| 2406 | |
| 2407 @override | |
| 2408 ir.Primitive errorStaticGetterSet( | |
| 2409 ast.SendSet node, | |
| 2410 FunctionElement getter, | |
| 2411 ast.Node rhs, | |
| 2412 _) { | |
| 2413 return buildStaticNoSuchMethod( | |
| 2414 new Selector.setter(getter.name, getter.library), | |
| 2415 [visit(rhs)]); | |
| 2416 } | |
| 2417 | |
| 2418 @override | |
| 2419 ir.Primitive errorStaticSetterGet( | |
| 2420 ast.Send node, | |
| 2421 FunctionElement setter, | |
| 2422 _) { | |
| 2423 return buildStaticNoSuchMethod( | |
| 2424 new Selector.getter(setter.name, setter.library), | |
| 2425 []); | |
| 2426 } | |
| 2427 | |
| 2428 @override | |
| 2429 ir.Primitive errorStaticSetterInvoke( | |
| 2430 ast.Send node, | |
| 2431 FunctionElement setter, | |
| 2432 ast.NodeList arguments, | |
| 2433 CallStructure callStructure, _) { | |
| 2434 // Translate as a method call. | |
| 2435 List<ir.Primitive> args = arguments.nodes.mapToList(visit); | |
| 2436 Name name = new Name(setter.name, setter.library); | |
| 2437 return buildStaticNoSuchMethod( | |
| 2438 new Selector(SelectorKind.CALL, name, callStructure), | |
| 2439 args); | |
| 2440 } | |
| 2441 | |
| 2442 @override | |
| 2443 ir.Primitive errorSuperGetterSet( | |
| 2444 ast.SendSet node, | |
| 2445 FunctionElement getter, | |
| 2446 ast.Node rhs, | |
| 2447 _) { | |
| 2448 Selector selector = useSelectorTypeOfNode( | |
| 2449 new Selector.setter(getter.name, getter.library), | |
| 2450 node); | |
| 2451 return buildInstanceNoSuchMethod(selector, [visit(rhs)]); | |
| 2452 } | |
| 2453 | |
| 2454 @override | |
| 2455 ir.Primitive errorSuperMethodSet( | |
| 2456 ast.Send node, | |
| 2457 MethodElement method, | |
| 2458 ast.Node rhs, | |
| 2459 _) { | |
| 2460 Selector selector = useSelectorTypeOfNode( | |
| 2461 new Selector.setter(method.name, method.library), | |
| 2462 node); | |
| 2463 return buildInstanceNoSuchMethod(selector, [visit(rhs)]); | |
| 2464 } | |
| 2465 | |
| 2466 @override | |
| 2467 ir.Primitive errorSuperSetterGet( | |
| 2468 ast.Send node, | |
| 2469 FunctionElement setter, _) { | |
| 2470 Selector selector = useSelectorTypeOfNode( | |
| 2471 new Selector.setter(setter.name, setter.library), | |
| 2472 node); | |
| 2473 return buildInstanceNoSuchMethod(selector, []); | |
| 2474 } | |
| 2475 | |
| 2476 @override | |
| 2477 ir.Primitive errorSuperSetterInvoke( | |
| 2478 ast.Send node, | |
| 2479 FunctionElement setter, | |
| 2480 ast.NodeList arguments, | |
| 2481 CallStructure callStructure, _) { | |
| 2482 List<ir.Primitive> args = | |
| 2483 translateDynamicArguments(arguments, callStructure); | |
| 2484 Name name = new Name(setter.name, setter.library); | |
| 2485 Selector selector = useSelectorTypeOfNode( | |
| 2486 new Selector(SelectorKind.CALL, name, callStructure), | |
| 2487 node); | |
| 2488 return buildInstanceNoSuchMethod(selector, args); | |
| 2489 } | |
| 2490 | |
| 2491 @override | |
| 2492 ir.Primitive errorTypeVariableTypeLiteralCompound( | |
| 2493 ast.Send node, | |
| 2494 TypeVariableElement element, | |
| 2495 op.AssignmentOperator operator, | |
| 2496 ast.Node rhs, _) { | |
| 2497 ir.Primitive receiver = irBuilder.buildThis(); | |
| 2498 return translateCompound( | |
| 2499 getValue: () => buildReifyTypeVariable(receiver, element.type), | |
| 2500 operator: operator, | |
| 2501 rhs: rhs, | |
| 2502 setValue: (value) {}); // The binary operator will throw before this. | |
| 2503 } | |
| 2504 | |
| 2505 @override | |
| 2506 ir.Primitive errorTypeVariableTypeLiteralPostfix( | |
| 2507 ast.Send node, | |
| 2508 TypeVariableElement element, | |
| 2509 op.IncDecOperator operator, _) { | |
| 2510 ir.Primitive receiver = irBuilder.buildThis(); | |
| 2511 String message = 'Cannot assign to type variable ${element.name}'; | |
|
floitsch
2015/05/08 03:03:40
unused.
asgerf
2015/05/08 08:17:59
Done.
| |
| 2512 return translatePrefixPostfix( | |
| 2513 getValue: () => buildReifyTypeVariable(receiver, element.type), | |
| 2514 operator: operator, | |
| 2515 setValue: (value) {}, // The binary operator will throw before this. | |
| 2516 isPrefix: false); | |
| 2517 } | |
| 2518 | |
| 2519 @override | |
| 2520 ir.Primitive errorTypeVariableTypeLiteralPrefix( | |
| 2521 ast.Send node, | |
| 2522 TypeVariableElement element, | |
| 2523 op.IncDecOperator operator, _) { | |
| 2524 ir.Primitive receiver = irBuilder.buildThis(); | |
| 2525 return translatePrefixPostfix( | |
| 2526 getValue: () => buildReifyTypeVariable(receiver, element.type), | |
| 2527 operator: operator, | |
| 2528 setValue: (value) {}, // The binary operator will throw before this. | |
| 2529 isPrefix: true); | |
| 2530 } | |
| 2531 | |
| 2532 @override | |
| 2533 ir.Primitive errorTypedefTypeLiteralCompound( | |
| 2534 ast.Send node, | |
| 2535 ConstantExpression constant, | |
| 2536 op.AssignmentOperator operator, | |
| 2537 ast.Node rhs, _) { | |
| 2538 return translateCompound( | |
| 2539 getValue: () => irBuilder.buildConstant(constant), | |
| 2540 operator: operator, | |
| 2541 rhs: rhs, | |
| 2542 setValue: (value) {}); // The binary operator will throw before this. | |
| 2543 } | |
| 2544 | |
| 2545 @override | |
| 2546 ir.Primitive errorTypedefTypeLiteralPostfix( | |
| 2547 ast.Send node, | |
| 2548 ConstantExpression constant, | |
| 2549 op.IncDecOperator operator, _) { | |
| 2550 return translatePrefixPostfix( | |
| 2551 getValue: () => irBuilder.buildConstant(constant), | |
| 2552 operator: operator, | |
| 2553 setValue: (value) {}, // The binary operator will throw before this. | |
| 2554 isPrefix: false); | |
| 2555 } | |
| 2556 | |
| 2557 @override | |
| 2558 ir.Primitive errorTypedefTypeLiteralPrefix( | |
| 2559 ast.Send node, | |
| 2560 TypeConstantExpression constant, | |
| 2561 op.IncDecOperator operator, _) { | |
| 2562 return translatePrefixPostfix( | |
| 2563 getValue: () => irBuilder.buildConstant(constant), | |
| 2564 operator: operator, | |
| 2565 setValue: (value) {}, // The binary operator will throw before this. | |
| 2566 isPrefix: true); | |
| 2567 } | |
| 2568 | |
| 1870 ir.RootNode nullIfGiveup(ir.RootNode action()) { | 2569 ir.RootNode nullIfGiveup(ir.RootNode action()) { |
| 1871 try { | 2570 try { |
| 1872 return action(); | 2571 return action(); |
| 1873 } catch(e) { | 2572 } catch(e) { |
| 1874 if (e == ABORT_IRNODE_BUILDER) { | 2573 if (e == ABORT_IRNODE_BUILDER) { |
| 1875 return null; | 2574 return null; |
| 1876 } | 2575 } |
| 1877 rethrow; | 2576 rethrow; |
| 1878 } | 2577 } |
| 1879 } | 2578 } |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2206 ast.NodeList arguments, | 2905 ast.NodeList arguments, |
| 2207 CallStructure callStructure, _) { | 2906 CallStructure callStructure, _) { |
| 2208 List<ir.Primitive> arguments = | 2907 List<ir.Primitive> arguments = |
| 2209 node.send.arguments.mapToList(visit, growable:false); | 2908 node.send.arguments.mapToList(visit, growable:false); |
| 2210 return irBuilder.buildConstructorInvocation( | 2909 return irBuilder.buildConstructorInvocation( |
| 2211 constructor, | 2910 constructor, |
| 2212 callStructure, | 2911 callStructure, |
| 2213 type, | 2912 type, |
| 2214 arguments); | 2913 arguments); |
| 2215 } | 2914 } |
| 2915 | |
| 2916 @override | |
| 2917 ir.Primitive buildStaticNoSuchMethod(Selector selector, | |
| 2918 List<ir.Primitive> arguments) { | |
| 2919 return giveup(null, 'Static noSuchMethod'); | |
| 2920 } | |
| 2921 | |
| 2922 @override | |
| 2923 ir.Primitive buildInstanceNoSuchMethod(Selector selector, | |
| 2924 List<ir.Primitive> arguments) { | |
| 2925 return giveup(null, 'Instance noSuchMethod'); | |
| 2926 } | |
| 2927 | |
| 2928 @override | |
| 2929 ir.Primitive buildRuntimeError(String message) { | |
| 2930 return giveup(null, 'Build runtime error: $message'); | |
| 2931 } | |
| 2932 | |
| 2933 @override | |
| 2934 ir.Primitive buildAbstractClassInstantiationError(ClassElement element) { | |
| 2935 return giveup(null, 'Abstract class instantiation: ${element.name}'); | |
| 2936 } | |
| 2216 } | 2937 } |
| 2217 | 2938 |
| 2218 /// The [IrBuilder]s view on the information about the program that has been | 2939 /// The [IrBuilder]s view on the information about the program that has been |
| 2219 /// computed in resolution and and type interence. | 2940 /// computed in resolution and and type interence. |
| 2220 class GlobalProgramInformation { | 2941 class GlobalProgramInformation { |
| 2221 final Compiler _compiler; | 2942 final Compiler _compiler; |
| 2222 JavaScriptBackend get _backend => _compiler.backend; | 2943 JavaScriptBackend get _backend => _compiler.backend; |
| 2223 | 2944 |
| 2224 GlobalProgramInformation(this._compiler); | 2945 GlobalProgramInformation(this._compiler); |
| 2225 | 2946 |
| 2226 /// Returns [true], if the analysis could not determine that the type | 2947 /// Returns [true], if the analysis could not determine that the type |
| 2227 /// arguments for the class [cls] are never used in the program. | 2948 /// arguments for the class [cls] are never used in the program. |
| 2228 bool requiresRuntimeTypesFor(ClassElement cls) { | 2949 bool requiresRuntimeTypesFor(ClassElement cls) { |
| 2229 return cls.typeVariables.isNotEmpty && _backend.classNeedsRti(cls); | 2950 return cls.typeVariables.isNotEmpty && _backend.classNeedsRti(cls); |
| 2230 } | 2951 } |
| 2231 } | 2952 } |
| 2232 | 2953 |
| 2233 /// IR builder specific to the JavaScript backend, coupled to the [JsIrBuilder]. | 2954 /// IR builder specific to the JavaScript backend, coupled to the [JsIrBuilder]. |
| 2234 class JsIrBuilderVisitor extends IrBuilderVisitor { | 2955 class JsIrBuilderVisitor extends IrBuilderVisitor { |
| 2235 /// Promote the type of [irBuilder] to [JsIrBuilder]. | 2956 /// Promote the type of [irBuilder] to [JsIrBuilder]. |
| 2236 JsIrBuilder get irBuilder => super.irBuilder; | 2957 JsIrBuilder get irBuilder => super.irBuilder; |
| 2237 | 2958 |
| 2959 JavaScriptBackend get backend => compiler.backend; | |
| 2960 | |
| 2238 /// Result of closure conversion for the current body of code. | 2961 /// Result of closure conversion for the current body of code. |
| 2239 /// | 2962 /// |
| 2240 /// Will be initialized upon entering the body of a function. | 2963 /// Will be initialized upon entering the body of a function. |
| 2241 /// It is computed by the [ClosureTranslator]. | 2964 /// It is computed by the [ClosureTranslator]. |
| 2242 ClosureClassMap closureMap; | 2965 ClosureClassMap closureMap; |
| 2243 | 2966 |
| 2244 /// During construction of a constructor factory, [fieldValues] maps fields | 2967 /// During construction of a constructor factory, [fieldValues] maps fields |
| 2245 /// to the primitive containing their initial value. | 2968 /// to the primitive containing their initial value. |
| 2246 Map<FieldElement, ir.Primitive> fieldValues = <FieldElement, ir.Primitive>{}; | 2969 Map<FieldElement, ir.Primitive> fieldValues = <FieldElement, ir.Primitive>{}; |
| 2247 | 2970 |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2838 List<ir.Primitive> arguments = | 3561 List<ir.Primitive> arguments = |
| 2839 node.send.arguments.mapToList(visit, growable:false); | 3562 node.send.arguments.mapToList(visit, growable:false); |
| 2840 arguments = normalizeStaticArguments( | 3563 arguments = normalizeStaticArguments( |
| 2841 callStructure, constructor, arguments); | 3564 callStructure, constructor, arguments); |
| 2842 return irBuilder.buildConstructorInvocation( | 3565 return irBuilder.buildConstructorInvocation( |
| 2843 constructor.effectiveTarget, | 3566 constructor.effectiveTarget, |
| 2844 callStructure, | 3567 callStructure, |
| 2845 constructor.computeEffectiveTargetType(type), | 3568 constructor.computeEffectiveTargetType(type), |
| 2846 arguments); | 3569 arguments); |
| 2847 } | 3570 } |
| 3571 | |
| 3572 @override | |
| 3573 ir.Primitive buildStaticNoSuchMethod(Selector selector, | |
| 3574 List<ir.Primitive> arguments) { | |
| 3575 Element thrower = backend.getThrowNoSuchMethod(); | |
| 3576 ir.Primitive receiver = irBuilder.buildStringConstant(''); | |
| 3577 ir.Primitive name = irBuilder.buildStringConstant(selector.name); | |
| 3578 ir.Primitive argumentList = irBuilder.buildListLiteral(null, arguments); | |
| 3579 ir.Primitive expectedArgumentNames = irBuilder.buildNullConstant(); | |
| 3580 return irBuilder.buildStaticFunctionInvocation( | |
| 3581 thrower, | |
| 3582 new CallStructure.unnamed(4), | |
| 3583 [receiver, name, argumentList, expectedArgumentNames]); | |
| 3584 } | |
| 3585 | |
| 3586 @override | |
| 3587 ir.Primitive buildInstanceNoSuchMethod(Selector selector, | |
| 3588 List<ir.Primitive> arguments) { | |
| 3589 return irBuilder.buildDynamicInvocation( | |
| 3590 irBuilder.buildThis(), | |
| 3591 useSelectorType(compiler.noSuchMethodSelector, selector), | |
| 3592 [irBuilder.buildInvocationMirror(selector, arguments)]); | |
| 3593 } | |
| 3594 | |
| 3595 @override | |
| 3596 ir.Primitive buildRuntimeError(String message) { | |
| 3597 return irBuilder.buildStaticFunctionInvocation( | |
| 3598 backend.getThrowRuntimeError(), | |
| 3599 new CallStructure.unnamed(1), | |
| 3600 [irBuilder.buildStringConstant(message)]); | |
| 3601 } | |
| 3602 | |
| 3603 @override | |
| 3604 ir.Primitive buildAbstractClassInstantiationError(ClassElement element) { | |
| 3605 return irBuilder.buildStaticFunctionInvocation( | |
| 3606 backend.getThrowAbstractClassInstantiationError(), | |
| 3607 new CallStructure.unnamed(1), | |
| 3608 [irBuilder.buildStringConstant(element.name)]); | |
| 3609 } | |
| 2848 } | 3610 } |
| 2849 | 3611 |
| 2850 /// Perform simple post-processing on the initial CPS-translated root term. | 3612 /// Perform simple post-processing on the initial CPS-translated root term. |
| 2851 /// | 3613 /// |
| 2852 /// This pass performs backend-independent post-processing on the translated | 3614 /// This pass performs backend-independent post-processing on the translated |
| 2853 /// term. It is implemented separately from the optimization passes because | 3615 /// term. It is implemented separately from the optimization passes because |
| 2854 /// it is required for correctness of the implementation. | 3616 /// it is required for correctness of the implementation. |
| 2855 /// | 3617 /// |
| 2856 /// It performs the following translations: | 3618 /// It performs the following translations: |
| 2857 /// - Replace [ir.LetPrim] binding a [ir.NonTailThrow] with a [ir.Throw] | 3619 /// - Replace [ir.LetPrim] binding a [ir.NonTailThrow] with a [ir.Throw] |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2906 node.body = replacementFor(node.body); | 3668 node.body = replacementFor(node.body); |
| 2907 } | 3669 } |
| 2908 } | 3670 } |
| 2909 | 3671 |
| 2910 /// Visit a just-deleted subterm and unlink all [Reference]s in it. | 3672 /// Visit a just-deleted subterm and unlink all [Reference]s in it. |
| 2911 class RemovalVisitor extends ir.RecursiveVisitor { | 3673 class RemovalVisitor extends ir.RecursiveVisitor { |
| 2912 processReference(ir.Reference reference) { | 3674 processReference(ir.Reference reference) { |
| 2913 reference.unlink(); | 3675 reference.unlink(); |
| 2914 } | 3676 } |
| 2915 } | 3677 } |
| OLD | NEW |