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/constant_system.dart'; | 7 import '../constants/constant_system.dart'; |
8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
9 import '../constants/values.dart' show PrimitiveConstantValue; | 9 import '../constants/values.dart' show PrimitiveConstantValue; |
10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 | 902 |
903 ir.ConstructorDefinition makeConstructorDefinition( | 903 ir.ConstructorDefinition makeConstructorDefinition( |
904 List<ConstantExpression> defaults, List<ir.Initializer> initializers) { | 904 List<ConstantExpression> defaults, List<ir.Initializer> initializers) { |
905 FunctionElement element = state.currentElement; | 905 FunctionElement element = state.currentElement; |
906 ir.Body body = makeBody(); | 906 ir.Body body = makeBody(); |
907 return new ir.ConstructorDefinition( | 907 return new ir.ConstructorDefinition( |
908 element, state.thisParameter, state.functionParameters, body, initialize
rs, | 908 element, state.thisParameter, state.functionParameters, body, initialize
rs, |
909 state.localConstants, defaults); | 909 state.localConstants, defaults); |
910 } | 910 } |
911 | 911 |
| 912 ir.FunctionDefinition makeLazyFieldInitializer() { |
| 913 ir.Body body = makeBody(); |
| 914 FieldElement element = state.currentElement; |
| 915 return new ir.FunctionDefinition(element, null, [], body, [], []); |
| 916 } |
| 917 |
912 /// Create a invocation of the [method] on the super class where the call | 918 /// Create a invocation of the [method] on the super class where the call |
913 /// structure is defined [callStructure] and the argument values are defined | 919 /// structure is defined [callStructure] and the argument values are defined |
914 /// by [arguments]. | 920 /// by [arguments]. |
915 ir.Primitive buildSuperMethodInvocation(MethodElement method, | 921 ir.Primitive buildSuperMethodInvocation(MethodElement method, |
916 CallStructure callStructure, | 922 CallStructure callStructure, |
917 List<ir.Primitive> arguments) { | 923 List<ir.Primitive> arguments) { |
918 // TODO(johnniwinther): This shouldn't be necessary. | 924 // TODO(johnniwinther): This shouldn't be necessary. |
919 SelectorKind kind = Elements.isOperatorName(method.name) | 925 SelectorKind kind = Elements.isOperatorName(method.name) |
920 ? SelectorKind.OPERATOR : SelectorKind.CALL; | 926 ? SelectorKind.OPERATOR : SelectorKind.CALL; |
921 Selector selector = | 927 Selector selector = |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 List<ir.Primitive> arguments, | 1083 List<ir.Primitive> arguments, |
1078 {SourceInformation sourceInformation}) { | 1084 {SourceInformation sourceInformation}) { |
1079 Selector selector = | 1085 Selector selector = |
1080 new Selector(SelectorKind.CALL, function.memberName, callStructure); | 1086 new Selector(SelectorKind.CALL, function.memberName, callStructure); |
1081 return _buildInvokeStatic( | 1087 return _buildInvokeStatic( |
1082 function, selector, arguments, sourceInformation); | 1088 function, selector, arguments, sourceInformation); |
1083 } | 1089 } |
1084 | 1090 |
1085 /// Create a read access of the static [field]. | 1091 /// Create a read access of the static [field]. |
1086 ir.Primitive buildStaticFieldGet(FieldElement field, | 1092 ir.Primitive buildStaticFieldGet(FieldElement field, |
1087 {SourceInformation sourceInformation}) { | 1093 SourceInformation sourceInformation) { |
1088 return addPrimitive(new ir.GetStatic(field, sourceInformation)); | 1094 return addPrimitive(new ir.GetStatic(field, sourceInformation)); |
1089 } | 1095 } |
1090 | 1096 |
| 1097 /// Create a read access of a static [field] that might not have been |
| 1098 /// initialized yet. |
| 1099 ir.Primitive buildStaticFieldLazyGet(FieldElement field, |
| 1100 SourceInformation sourceInformation) { |
| 1101 return _continueWithExpression( |
| 1102 (k) => new ir.GetLazyStatic(field, k, sourceInformation)); |
| 1103 } |
| 1104 |
1091 /// Create a getter invocation of the static [getter]. | 1105 /// Create a getter invocation of the static [getter]. |
1092 ir.Primitive buildStaticGetterGet(MethodElement getter, | 1106 ir.Primitive buildStaticGetterGet(MethodElement getter, |
1093 {SourceInformation sourceInformation}) { | 1107 {SourceInformation sourceInformation}) { |
1094 Selector selector = new Selector.getter(getter.name, getter.library); | 1108 Selector selector = new Selector.getter(getter.name, getter.library); |
1095 return _buildInvokeStatic( | 1109 return _buildInvokeStatic( |
1096 getter, selector, const <ir.Primitive>[], sourceInformation); | 1110 getter, selector, const <ir.Primitive>[], sourceInformation); |
1097 } | 1111 } |
1098 | 1112 |
1099 /// Create a read access of the static [function], i.e. a closurization of | 1113 /// Create a read access of the static [function], i.e. a closurization of |
1100 /// [function]. | 1114 /// [function]. |
1101 ir.Primitive buildStaticFunctionGet(MethodElement function, | 1115 ir.Primitive buildStaticFunctionGet(MethodElement function, |
1102 {SourceInformation sourceInformation}) { | 1116 {SourceInformation sourceInformation}) { |
1103 return addPrimitive(new ir.GetStatic(function, sourceInformation)); | 1117 return addPrimitive(new ir.GetStatic(function, sourceInformation)); |
1104 } | 1118 } |
1105 | 1119 |
1106 /// Create a write access to the static [field] with the [value]. | 1120 /// Create a write access to the static [field] with the [value]. |
1107 ir.Primitive buildStaticFieldSet(FieldElement field, | 1121 ir.Primitive buildStaticFieldSet(FieldElement field, |
1108 ir.Primitive value, | 1122 ir.Primitive value, |
1109 {SourceInformation sourceInformation}) { | 1123 [SourceInformation sourceInformation]) { |
1110 add(new ir.SetStatic(field, value, sourceInformation)); | 1124 add(new ir.SetStatic(field, value, sourceInformation)); |
1111 return value; | 1125 return value; |
1112 } | 1126 } |
1113 | 1127 |
1114 /// Create a setter invocation of the static [setter] with the [value]. | 1128 /// Create a setter invocation of the static [setter] with the [value]. |
1115 ir.Primitive buildStaticSetterSet(MethodElement setter, | 1129 ir.Primitive buildStaticSetterSet(MethodElement setter, |
1116 ir.Primitive value, | 1130 ir.Primitive value, |
1117 {SourceInformation sourceInformation}) { | 1131 {SourceInformation sourceInformation}) { |
1118 Selector selector = new Selector.setter(setter.name, setter.library); | 1132 Selector selector = new Selector.setter(setter.name, setter.library); |
1119 _buildInvokeStatic( | 1133 _buildInvokeStatic( |
(...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2721 } | 2735 } |
2722 | 2736 |
2723 /// Synthetic parameter to a JavaScript factory method that takes the type | 2737 /// Synthetic parameter to a JavaScript factory method that takes the type |
2724 /// argument given for the type variable [variable]. | 2738 /// argument given for the type variable [variable]. |
2725 class TypeInformationParameter implements Local { | 2739 class TypeInformationParameter implements Local { |
2726 final TypeVariableElement variable; | 2740 final TypeVariableElement variable; |
2727 final ExecutableElement executableContext; | 2741 final ExecutableElement executableContext; |
2728 TypeInformationParameter(this.variable, this.executableContext); | 2742 TypeInformationParameter(this.variable, this.executableContext); |
2729 String get name => variable.name; | 2743 String get name => variable.name; |
2730 } | 2744 } |
OLD | NEW |