| 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; | 5 library dart2js.ir_builder; |
| 6 | 6 |
| 7 import '../constants/expressions.dart'; | 7 import '../constants/expressions.dart'; |
| 8 import '../constants/values.dart' show PrimitiveConstantValue; | 8 import '../constants/values.dart' show PrimitiveConstantValue; |
| 9 import '../dart_types.dart'; | 9 import '../dart_types.dart'; |
| 10 import '../dart2jslib.dart'; | 10 import '../dart2jslib.dart'; |
| 11 import '../elements/elements.dart'; | 11 import '../elements/elements.dart'; |
| 12 import '../io/source_information.dart'; | 12 import '../io/source_information.dart'; |
| 13 import '../tree/tree.dart' as ast; | 13 import '../tree/tree.dart' as ast; |
| 14 import '../closure.dart' hide ClosureScope; | 14 import '../closure.dart' hide ClosureScope; |
| 15 import '../universe/universe.dart' show SelectorKind; |
| 15 import 'cps_ir_nodes.dart' as ir; | 16 import 'cps_ir_nodes.dart' as ir; |
| 16 import 'cps_ir_builder_task.dart' show DartCapturedVariables, | 17 import 'cps_ir_builder_task.dart' show DartCapturedVariables, |
| 17 GlobalProgramInformation; | 18 GlobalProgramInformation; |
| 18 | 19 |
| 19 /// A mapping from variable elements to their compile-time values. | 20 /// A mapping from variable elements to their compile-time values. |
| 20 /// | 21 /// |
| 21 /// Map elements denoted by parameters and local variables to the | 22 /// Map elements denoted by parameters and local variables to the |
| 22 /// [ir.Primitive] that is their value. Parameters and locals are | 23 /// [ir.Primitive] that is their value. Parameters and locals are |
| 23 /// assigned indexes which can be used to refer to them. | 24 /// assigned indexes which can be used to refer to them. |
| 24 class Environment { | 25 class Environment { |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 Selector selector, | 641 Selector selector, |
| 641 List<ir.Primitive> arguments, | 642 List<ir.Primitive> arguments, |
| 642 {SourceInformation sourceInformation}) { | 643 {SourceInformation sourceInformation}) { |
| 643 assert(isOpen); | 644 assert(isOpen); |
| 644 return _continueWithExpression( | 645 return _continueWithExpression( |
| 645 (k) => new ir.InvokeMethod(receiver, selector, k, arguments, | 646 (k) => new ir.InvokeMethod(receiver, selector, k, arguments, |
| 646 sourceInformation: sourceInformation)); | 647 sourceInformation: sourceInformation)); |
| 647 } | 648 } |
| 648 | 649 |
| 649 ir.Primitive _buildInvokeCall(ir.Primitive target, | 650 ir.Primitive _buildInvokeCall(ir.Primitive target, |
| 650 Selector selector, | 651 CallStructure callStructure, |
| 651 List<ir.Definition> arguments, | 652 List<ir.Definition> arguments, |
| 652 {SourceInformation sourceInformation}) { | 653 {SourceInformation sourceInformation}) { |
| 653 Selector callSelector = new Selector.callClosureFrom(selector); | 654 Selector selector = callStructure.callSelector; |
| 654 return _buildInvokeDynamic(target, callSelector, arguments, | 655 return _buildInvokeDynamic(target, selector, arguments, |
| 655 sourceInformation: sourceInformation); | 656 sourceInformation: sourceInformation); |
| 656 } | 657 } |
| 657 | 658 |
| 658 | 659 |
| 659 /// Create a constant literal from [constant]. | 660 /// Create a constant literal from [constant]. |
| 660 ir.Constant buildConstantLiteral(ConstantExpression constant) { | 661 ir.Constant buildConstantLiteral(ConstantExpression constant) { |
| 661 assert(isOpen); | 662 assert(isOpen); |
| 662 return addPrimitive(new ir.Constant(constant)); | 663 return addPrimitive(new ir.Constant(constant)); |
| 663 } | 664 } |
| 664 | 665 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 ir.ConstructorDefinition makeConstructorDefinition( | 862 ir.ConstructorDefinition makeConstructorDefinition( |
| 862 List<ConstantExpression> defaults, List<ir.Initializer> initializers) { | 863 List<ConstantExpression> defaults, List<ir.Initializer> initializers) { |
| 863 FunctionElement element = state.currentElement; | 864 FunctionElement element = state.currentElement; |
| 864 ir.Body body = makeBody(); | 865 ir.Body body = makeBody(); |
| 865 return new ir.ConstructorDefinition( | 866 return new ir.ConstructorDefinition( |
| 866 element, state.thisParameter, state.functionParameters, body, initialize
rs, | 867 element, state.thisParameter, state.functionParameters, body, initialize
rs, |
| 867 state.localConstants, defaults); | 868 state.localConstants, defaults); |
| 868 } | 869 } |
| 869 | 870 |
| 870 /// Create a invocation of the [method] on the super class where the call | 871 /// Create a invocation of the [method] on the super class where the call |
| 871 /// structure is defined [selector] and the argument values are defined by | 872 /// structure is defined [callStructure] and the argument values are defined |
| 872 /// [arguments]. | 873 /// by [arguments]. |
| 873 ir.Primitive buildSuperMethodInvocation(MethodElement method, | 874 ir.Primitive buildSuperMethodInvocation(MethodElement method, |
| 874 Selector selector, | 875 CallStructure callStructure, |
| 875 List<ir.Primitive> arguments) { | 876 List<ir.Primitive> arguments) { |
| 877 // TODO(johnniwinther): This shouldn't be necessary. |
| 878 SelectorKind kind = Elements.isOperatorName(method.name) |
| 879 ? SelectorKind.OPERATOR : SelectorKind.CALL; |
| 880 Selector selector = |
| 881 new Selector(kind, method.memberName, callStructure); |
| 876 return _buildInvokeSuper(method, selector, arguments); | 882 return _buildInvokeSuper(method, selector, arguments); |
| 877 } | 883 } |
| 878 | 884 |
| 879 /// Create a call invocation on the value of [field] on the super class where | 885 /// Create a call invocation on the value of [field] on the super class where |
| 880 /// the call structure is defined [selector] and the argument values are | 886 /// the call structure is defined [callStructure] and the argument values are |
| 881 /// defined by [arguments]. | 887 /// defined by [arguments]. |
| 882 ir.Primitive buildSuperFieldInvocation(FieldElement field, | 888 ir.Primitive buildSuperFieldInvocation(FieldElement field, |
| 883 Selector selector, | 889 CallStructure callStructure, |
| 884 List<ir.Primitive> arguments) { | 890 List<ir.Primitive> arguments) { |
| 885 // TODO(johnniwinther): Maybe this should have its own ir node. | 891 // TODO(johnniwinther): Maybe this should have its own ir node. |
| 886 return buildCallInvocation( | 892 return buildCallInvocation( |
| 887 buildSuperFieldGet(field), | 893 buildSuperFieldGet(field), |
| 888 selector, | 894 callStructure, |
| 889 arguments); | 895 arguments); |
| 890 } | 896 } |
| 891 | 897 |
| 892 /// Create a call invocation on the value returned from the [getter] on the | 898 /// Create a call invocation on the value returned from the [getter] on the |
| 893 /// super class where the call structure is defined [selector] and the | 899 /// super class where the call structure is defined [selector] and the |
| 894 /// argument values are defined by [arguments]. | 900 /// argument values are defined by [arguments]. |
| 895 ir.Primitive buildSuperGetterInvocation(MethodElement getter, | 901 ir.Primitive buildSuperGetterInvocation(MethodElement getter, |
| 896 Selector selector, | 902 CallStructure callStructure, |
| 897 List<ir.Primitive> arguments) { | 903 List<ir.Primitive> arguments) { |
| 898 // TODO(johnniwinther): Maybe this should have its own ir node. | 904 // TODO(johnniwinther): Maybe this should have its own ir node. |
| 899 return buildCallInvocation( | 905 return buildCallInvocation( |
| 900 buildSuperGetterGet(getter), | 906 buildSuperGetterGet(getter), |
| 901 selector, | 907 callStructure, |
| 902 arguments); | 908 arguments); |
| 903 } | 909 } |
| 904 | 910 |
| 905 /// Create a read access of the [field] on the super class. | 911 /// Create a read access of the [field] on the super class. |
| 906 ir.Primitive buildSuperFieldGet(FieldElement field) { | 912 ir.Primitive buildSuperFieldGet(FieldElement field) { |
| 907 // TODO(johnniwinther): This should have its own ir node. | 913 // TODO(johnniwinther): This should have its own ir node. |
| 908 return _buildInvokeSuper( | 914 return _buildInvokeSuper( |
| 909 field, | 915 field, |
| 910 new Selector.getter(field.name, field.library), | 916 new Selector.getter(field.name, field.library), |
| 911 const <ir.Primitive>[]); | 917 const <ir.Primitive>[]); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 ir.Primitive buildSuperSetterSet(MethodElement setter, | 951 ir.Primitive buildSuperSetterSet(MethodElement setter, |
| 946 ir.Primitive value) { | 952 ir.Primitive value) { |
| 947 // TODO(johnniwinther): This should have its own ir node. | 953 // TODO(johnniwinther): This should have its own ir node. |
| 948 _buildInvokeSuper( | 954 _buildInvokeSuper( |
| 949 setter, | 955 setter, |
| 950 new Selector.setter(setter.name, setter.library), | 956 new Selector.setter(setter.name, setter.library), |
| 951 <ir.Primitive>[value]); | 957 <ir.Primitive>[value]); |
| 952 return value; | 958 return value; |
| 953 } | 959 } |
| 954 | 960 |
| 961 /// Create an invocation of the index [method] on the super class with |
| 962 /// the provided [index]. |
| 963 ir.Primitive buildSuperIndex(MethodElement method, |
| 964 ir.Primitive index) { |
| 965 return _buildInvokeSuper( |
| 966 method, new Selector.index(), <ir.Primitive>[index]); |
| 967 } |
| 968 |
| 955 /// Create an invocation of the index set [method] on the super class with | 969 /// Create an invocation of the index set [method] on the super class with |
| 956 /// the provided [index] and [value]. | 970 /// the provided [index] and [value]. |
| 957 ir.Primitive buildSuperIndexSet(MethodElement method, | 971 ir.Primitive buildSuperIndexSet(MethodElement method, |
| 958 ir.Primitive index, | 972 ir.Primitive index, |
| 959 ir.Primitive value) { | 973 ir.Primitive value) { |
| 960 _buildInvokeSuper(method, new Selector.indexSet(), | 974 _buildInvokeSuper(method, new Selector.indexSet(), |
| 961 <ir.Primitive>[index, value]); | 975 <ir.Primitive>[index, value]); |
| 962 return value; | 976 return value; |
| 963 } | 977 } |
| 964 | 978 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 ir.Primitive buildLocalFunctionGet(LocalFunctionElement function) { | 1025 ir.Primitive buildLocalFunctionGet(LocalFunctionElement function) { |
| 1012 // TODO(johnniwinther): Separate function access from variable access. | 1026 // TODO(johnniwinther): Separate function access from variable access. |
| 1013 return _buildLocalGet(function); | 1027 return _buildLocalGet(function); |
| 1014 } | 1028 } |
| 1015 | 1029 |
| 1016 /// Create a write access to the [local] variable or parameter with the | 1030 /// Create a write access to the [local] variable or parameter with the |
| 1017 /// provided [value]. | 1031 /// provided [value]. |
| 1018 ir.Primitive buildLocalVariableSet(LocalElement local, ir.Primitive value); | 1032 ir.Primitive buildLocalVariableSet(LocalElement local, ir.Primitive value); |
| 1019 | 1033 |
| 1020 /// Create an invocation of the the [local] variable or parameter where | 1034 /// Create an invocation of the the [local] variable or parameter where |
| 1021 /// argument structure is defined by [selector] and the argument values are | 1035 /// argument structure is defined by [callStructure] and the argument values |
| 1022 /// defined by [arguments]. | 1036 /// are defined by [arguments]. |
| 1023 ir.Primitive buildLocalVariableInvocation(LocalVariableElement local, | 1037 ir.Primitive buildLocalVariableInvocation(LocalVariableElement local, |
| 1024 Selector selector, | 1038 CallStructure callStructure, |
| 1025 List<ir.Primitive> arguments) { | 1039 List<ir.Primitive> arguments) { |
| 1026 return buildCallInvocation( | 1040 return buildCallInvocation( |
| 1027 buildLocalVariableGet(local), selector, arguments); | 1041 buildLocalVariableGet(local), callStructure, arguments); |
| 1028 } | 1042 } |
| 1029 | 1043 |
| 1030 /// Create an invocation of the local [function] where argument structure is | 1044 /// Create an invocation of the local [function] where argument structure is |
| 1031 /// defined by [selector] and the argument values are defined by [arguments]. | 1045 /// defined by [callStructure] and the argument values are defined by |
| 1046 /// [arguments]. |
| 1032 ir.Primitive buildLocalFunctionInvocation( | 1047 ir.Primitive buildLocalFunctionInvocation( |
| 1033 LocalFunctionElement function, | 1048 LocalFunctionElement function, |
| 1034 Selector selector, | 1049 CallStructure callStructure, |
| 1035 List<ir.Primitive> arguments) { | 1050 List<ir.Primitive> arguments) { |
| 1036 // TODO(johnniwinther): Maybe this should have its own ir node. | 1051 // TODO(johnniwinther): Maybe this should have its own ir node. |
| 1037 return buildCallInvocation( | 1052 return buildCallInvocation( |
| 1038 buildLocalFunctionGet(function), selector, arguments); | 1053 buildLocalFunctionGet(function), callStructure, arguments); |
| 1039 } | 1054 } |
| 1040 | 1055 |
| 1041 /// Create a static invocation of [function] where argument structure is | 1056 /// Create a static invocation of [function] where argument structure is |
| 1042 /// defined by [selector] and the argument values are defined by [arguments]. | 1057 /// defined by [callStructure] and the argument values are defined by |
| 1058 /// [arguments]. |
| 1043 ir.Primitive buildStaticFunctionInvocation( | 1059 ir.Primitive buildStaticFunctionInvocation( |
| 1044 MethodElement function, | 1060 MethodElement function, |
| 1045 Selector selector, | 1061 CallStructure callStructure, |
| 1046 List<ir.Primitive> arguments, | 1062 List<ir.Primitive> arguments, |
| 1047 {SourceInformation sourceInformation}) { | 1063 {SourceInformation sourceInformation}) { |
| 1048 return _buildInvokeStatic(function, selector, arguments, sourceInformation); | 1064 Selector selector = |
| 1065 new Selector(SelectorKind.CALL, function.memberName, callStructure); |
| 1066 return _buildInvokeStatic( |
| 1067 function, selector, arguments, sourceInformation); |
| 1049 } | 1068 } |
| 1050 | 1069 |
| 1051 /// Create a call invocation of the value of the static [field] where argument | 1070 /// Create a call invocation of the value of the static [field] where argument |
| 1052 /// structure is defined by [selector] and the argument values are defined by | 1071 /// structure is defined by [callStructure] and the argument values are |
| 1053 /// [arguments]. | 1072 /// defined by [arguments]. |
| 1054 ir.Primitive buildStaticFieldInvocation( | 1073 ir.Primitive buildStaticFieldInvocation( |
| 1055 FieldElement field, | 1074 FieldElement field, |
| 1056 Selector selector, | 1075 CallStructure callStructure, |
| 1057 List<ir.Primitive> arguments, | 1076 List<ir.Primitive> arguments, |
| 1058 {SourceInformation sourceInformation}) { | 1077 {SourceInformation sourceInformation}) { |
| 1059 // TODO(johnniwinther): Maybe this should have its own node. | 1078 // TODO(johnniwinther): Maybe this should have its own node. |
| 1060 return buildCallInvocation( | 1079 return buildCallInvocation( |
| 1061 buildStaticFieldGet(field), | 1080 buildStaticFieldGet(field), |
| 1062 selector, | 1081 callStructure, |
| 1063 arguments, | 1082 arguments, |
| 1064 sourceInformation: sourceInformation); | 1083 sourceInformation: sourceInformation); |
| 1065 } | 1084 } |
| 1066 | 1085 |
| 1067 /// Create a call invocation of the result of calling the static [getter] | 1086 /// Create a call invocation of the result of calling the static [getter] |
| 1068 /// where argument structure is defined by [selector] and the argument values | 1087 /// where argument structure is defined by [callStructure] and the argument |
| 1069 /// are defined by [arguments]. | 1088 /// values are defined by [arguments]. |
| 1070 ir.Primitive buildStaticGetterInvocation( | 1089 ir.Primitive buildStaticGetterInvocation( |
| 1071 MethodElement getter, | 1090 MethodElement getter, |
| 1072 Selector selector, | 1091 CallStructure callStructure, |
| 1073 List<ir.Primitive> arguments, | 1092 List<ir.Primitive> arguments, |
| 1074 {SourceInformation sourceInformation}) { | 1093 {SourceInformation sourceInformation}) { |
| 1075 // TODO(johnniwinther): Maybe this should have its own node. | 1094 // TODO(johnniwinther): Maybe this should have its own node. |
| 1076 return buildCallInvocation( | 1095 return buildCallInvocation( |
| 1077 buildStaticGetterGet(getter), | 1096 buildStaticGetterGet(getter), |
| 1078 selector, | 1097 callStructure, |
| 1079 arguments, | 1098 arguments, |
| 1080 sourceInformation: sourceInformation); | 1099 sourceInformation: sourceInformation); |
| 1081 } | 1100 } |
| 1082 | 1101 |
| 1083 /// Create a read access of the static [field]. | 1102 /// Create a read access of the static [field]. |
| 1084 ir.Primitive buildStaticFieldGet(FieldElement field, | 1103 ir.Primitive buildStaticFieldGet(FieldElement field, |
| 1085 {SourceInformation sourceInformation}) { | 1104 {SourceInformation sourceInformation}) { |
| 1086 Selector selector = new Selector.getter(field.name, field.library); | 1105 Selector selector = new Selector.getter(field.name, field.library); |
| 1087 // TODO(karlklose,sigurdm): build different nodes for getters. | 1106 // TODO(karlklose,sigurdm): build different nodes for getters. |
| 1088 return _buildInvokeStatic( | 1107 return _buildInvokeStatic( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 } | 1151 } |
| 1133 | 1152 |
| 1134 /// Create an erroneous invocation where argument structure is defined by | 1153 /// Create an erroneous invocation where argument structure is defined by |
| 1135 /// [selector] and the argument values are defined by [arguments]. | 1154 /// [selector] and the argument values are defined by [arguments]. |
| 1136 // TODO(johnniwinther): Make this more fine-grained. | 1155 // TODO(johnniwinther): Make this more fine-grained. |
| 1137 ir.Primitive buildErroneousInvocation( | 1156 ir.Primitive buildErroneousInvocation( |
| 1138 Element element, | 1157 Element element, |
| 1139 Selector selector, | 1158 Selector selector, |
| 1140 List<ir.Primitive> arguments) { | 1159 List<ir.Primitive> arguments) { |
| 1141 // TODO(johnniwinther): This should have its own ir node. | 1160 // TODO(johnniwinther): This should have its own ir node. |
| 1142 return _buildInvokeStatic( element, selector, arguments, null); | 1161 return _buildInvokeStatic(element, selector, arguments, null); |
| 1143 } | 1162 } |
| 1144 | 1163 |
| 1145 /// Create a constructor invocation of [element] on [type] where the | 1164 /// Create a constructor invocation of [element] on [type] where the |
| 1146 /// constructor name and argument structure are defined by [selector] and the | 1165 /// constructor name and argument structure are defined by [callStructure] and |
| 1147 /// argument values are defined by [arguments]. | 1166 /// the argument values are defined by [arguments]. |
| 1148 ir.Primitive buildConstructorInvocation(FunctionElement element, | 1167 ir.Primitive buildConstructorInvocation(FunctionElement element, |
| 1149 Selector selector, | 1168 CallStructure callStructure, |
| 1150 DartType type, | 1169 DartType type, |
| 1151 List<ir.Primitive> arguments); | 1170 List<ir.Primitive> arguments); |
| 1152 | 1171 |
| 1153 /// Create a string concatenation of the [arguments]. | 1172 /// Create a string concatenation of the [arguments]. |
| 1154 ir.Primitive buildStringConcatenation(List<ir.Primitive> arguments) { | 1173 ir.Primitive buildStringConcatenation(List<ir.Primitive> arguments) { |
| 1155 assert(isOpen); | 1174 assert(isOpen); |
| 1156 return _continueWithExpression( | 1175 return _continueWithExpression( |
| 1157 (k) => new ir.ConcatenateStrings(k, arguments)); | 1176 (k) => new ir.ConcatenateStrings(k, arguments)); |
| 1158 } | 1177 } |
| 1159 | 1178 |
| 1160 /// Create an invocation of the `call` method of [functionExpression], where | 1179 /// Create an invocation of the `call` method of [functionExpression], where |
| 1161 /// the named arguments are given by [selector]. | 1180 /// the structure of arguments are given by [callStructure]. |
| 1162 ir.Primitive buildCallInvocation( | 1181 ir.Primitive buildCallInvocation( |
| 1163 ir.Primitive functionExpression, | 1182 ir.Primitive functionExpression, |
| 1164 Selector selector, | 1183 CallStructure callStructure, |
| 1165 List<ir.Definition> arguments, | 1184 List<ir.Definition> arguments, |
| 1166 {SourceInformation sourceInformation}) { | 1185 {SourceInformation sourceInformation}) { |
| 1167 return _buildInvokeCall(functionExpression, selector, arguments, | 1186 return _buildInvokeCall(functionExpression, callStructure, arguments, |
| 1168 sourceInformation: sourceInformation); | 1187 sourceInformation: sourceInformation); |
| 1169 } | 1188 } |
| 1170 | 1189 |
| 1171 /// Creates an if-then-else statement with the provided [condition] where the | 1190 /// Creates an if-then-else statement with the provided [condition] where the |
| 1172 /// then and else branches are created through the [buildThenPart] and | 1191 /// then and else branches are created through the [buildThenPart] and |
| 1173 /// [buildElsePart] functions, respectively. | 1192 /// [buildElsePart] functions, respectively. |
| 1174 /// | 1193 /// |
| 1175 /// An if-then statement is created if [buildElsePart] is a no-op. | 1194 /// An if-then statement is created if [buildElsePart] is a no-op. |
| 1176 // TODO(johnniwinther): Unify implementation with [buildConditional] and | 1195 // TODO(johnniwinther): Unify implementation with [buildConditional] and |
| 1177 // [_buildLogicalOperator]. | 1196 // [_buildLogicalOperator]. |
| (...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2258 environment.update(local, value); | 2277 environment.update(local, value); |
| 2259 } | 2278 } |
| 2260 return value; | 2279 return value; |
| 2261 } | 2280 } |
| 2262 | 2281 |
| 2263 ir.Primitive buildThis() { | 2282 ir.Primitive buildThis() { |
| 2264 return state.enclosingMethodThisParameter; | 2283 return state.enclosingMethodThisParameter; |
| 2265 } | 2284 } |
| 2266 | 2285 |
| 2267 @override | 2286 @override |
| 2268 ir.Primitive buildConstructorInvocation(FunctionElement element, | 2287 ir.Primitive buildConstructorInvocation(ConstructorElement element, |
| 2269 Selector selector, | 2288 CallStructure callStructure, |
| 2270 DartType type, | 2289 DartType type, |
| 2271 List<ir.Primitive> arguments) { | 2290 List<ir.Primitive> arguments) { |
| 2272 assert(isOpen); | 2291 assert(isOpen); |
| 2292 Selector selector = |
| 2293 new Selector(SelectorKind.CALL, element.memberName, callStructure); |
| 2273 return _continueWithExpression( | 2294 return _continueWithExpression( |
| 2274 (k) => new ir.InvokeConstructor(type, element, selector, k, | 2295 (k) => new ir.InvokeConstructor(type, element, selector, k, |
| 2275 arguments)); | 2296 arguments)); |
| 2276 } | 2297 } |
| 2277 } | 2298 } |
| 2278 | 2299 |
| 2279 /// State shared between JsIrBuilders within the same function. | 2300 /// State shared between JsIrBuilders within the same function. |
| 2280 /// | 2301 /// |
| 2281 /// Note that this is not shared between builders of nested functions. | 2302 /// Note that this is not shared between builders of nested functions. |
| 2282 class JsIrBuilderSharedState { | 2303 class JsIrBuilderSharedState { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2541 ir.Parameter parameter = createLocalParameter(param); | 2562 ir.Parameter parameter = createLocalParameter(param); |
| 2542 state.functionParameters.add(parameter); | 2563 state.functionParameters.add(parameter); |
| 2543 } | 2564 } |
| 2544 if (closureScope != null) { | 2565 if (closureScope != null) { |
| 2545 jsState.boxedVariables.addAll(closureScope.capturedVariables); | 2566 jsState.boxedVariables.addAll(closureScope.capturedVariables); |
| 2546 } | 2567 } |
| 2547 } | 2568 } |
| 2548 | 2569 |
| 2549 @override | 2570 @override |
| 2550 ir.Primitive buildConstructorInvocation(ConstructorElement element, | 2571 ir.Primitive buildConstructorInvocation(ConstructorElement element, |
| 2551 Selector selector, | 2572 CallStructure callStructure, |
| 2552 DartType type, | 2573 DartType type, |
| 2553 List<ir.Primitive> arguments) { | 2574 List<ir.Primitive> arguments) { |
| 2554 assert(isOpen); | 2575 assert(isOpen); |
| 2555 | 2576 Selector selector = |
| 2577 new Selector(SelectorKind.CALL, element.memberName, callStructure); |
| 2556 ClassElement cls = element.enclosingClass; | 2578 ClassElement cls = element.enclosingClass; |
| 2557 if (program.requiresRuntimeTypesFor(cls)) { | 2579 if (program.requiresRuntimeTypesFor(cls)) { |
| 2558 InterfaceType interface = type; | 2580 InterfaceType interface = type; |
| 2559 Iterable<ir.Primitive> typeArguments = | 2581 Iterable<ir.Primitive> typeArguments = |
| 2560 interface.typeArguments.map((DartType argument) { | 2582 interface.typeArguments.map((DartType argument) { |
| 2561 return type.treatAsRaw | 2583 return type.treatAsRaw |
| 2562 ? buildNullLiteral() | 2584 ? buildNullLiteral() |
| 2563 : buildTypeExpression(argument); | 2585 : buildTypeExpression(argument); |
| 2564 }); | 2586 }); |
| 2565 arguments = new List<ir.Primitive>.from(arguments) | 2587 arguments = new List<ir.Primitive>.from(arguments) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2676 } | 2698 } |
| 2677 | 2699 |
| 2678 /// Synthetic parameter to a JavaScript factory method that takes the type | 2700 /// Synthetic parameter to a JavaScript factory method that takes the type |
| 2679 /// argument given for the type variable [variable]. | 2701 /// argument given for the type variable [variable]. |
| 2680 class TypeInformationParameter implements Local { | 2702 class TypeInformationParameter implements Local { |
| 2681 final TypeVariableElement variable; | 2703 final TypeVariableElement variable; |
| 2682 final ExecutableElement executableContext; | 2704 final ExecutableElement executableContext; |
| 2683 TypeInformationParameter(this.variable, this.executableContext); | 2705 TypeInformationParameter(this.variable, this.executableContext); |
| 2684 String get name => variable.name; | 2706 String get name => variable.name; |
| 2685 } | 2707 } |
| OLD | NEW |