| 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 'package:js_runtime/shared/embedded_names.dart' |
| 8 show JsBuiltin, JsGetName; |
| 9 |
| 7 import '../closure.dart' as closure; | 10 import '../closure.dart' as closure; |
| 8 import '../common.dart'; | 11 import '../common.dart'; |
| 9 import '../common/names.dart' show Identifiers, Names, Selectors; | 12 import '../common/names.dart' show Identifiers, Names, Selectors; |
| 10 import '../common/tasks.dart' show CompilerTask; | 13 import '../common/tasks.dart' show CompilerTask; |
| 11 import '../compiler.dart' show Compiler; | 14 import '../compiler.dart' show Compiler; |
| 12 import '../constants/expressions.dart'; | 15 import '../constants/expressions.dart'; |
| 16 import '../constants/values.dart' show ConstantValue; |
| 17 import '../constants/values.dart'; |
| 13 import '../dart_types.dart'; | 18 import '../dart_types.dart'; |
| 14 import '../elements/elements.dart'; | 19 import '../elements/elements.dart'; |
| 15 import '../elements/modelx.dart' | 20 import '../elements/modelx.dart' show ConstructorBodyElementX; |
| 16 show | |
| 17 SynthesizedConstructorElementX, | |
| 18 ConstructorBodyElementX, | |
| 19 FunctionSignatureX; | |
| 20 import '../io/source_information.dart'; | 21 import '../io/source_information.dart'; |
| 22 import '../js/js.dart' as js show js, Template, Expression, Name; |
| 21 import '../js_backend/backend_helpers.dart' show BackendHelpers; | 23 import '../js_backend/backend_helpers.dart' show BackendHelpers; |
| 22 import '../js_backend/js_backend.dart' | 24 import '../js_backend/js_backend.dart' |
| 23 show JavaScriptBackend, SyntheticConstantKind; | 25 show JavaScriptBackend, SyntheticConstantKind; |
| 26 import '../native/native.dart' show NativeBehavior, HasCapturedPlaceholders; |
| 27 import '../resolution/operators.dart' as op; |
| 28 import '../resolution/semantic_visitor.dart'; |
| 24 import '../resolution/tree_elements.dart' show TreeElements; | 29 import '../resolution/tree_elements.dart' show TreeElements; |
| 25 import '../resolution/semantic_visitor.dart'; | 30 import '../ssa/types.dart' show TypeMaskFactory; |
| 26 import '../resolution/operators.dart' as op; | |
| 27 import '../tree/tree.dart' as ast; | 31 import '../tree/tree.dart' as ast; |
| 28 import '../types/types.dart' show TypeMask; | 32 import '../types/types.dart' show TypeMask; |
| 29 import '../universe/call_structure.dart' show CallStructure; | 33 import '../universe/call_structure.dart' show CallStructure; |
| 30 import '../universe/selector.dart' show Selector; | 34 import '../universe/selector.dart' show Selector; |
| 31 import '../constants/values.dart' show ConstantValue; | 35 import '../util/util.dart'; |
| 36 import 'cps_ir_builder.dart'; |
| 32 import 'cps_ir_nodes.dart' as ir; | 37 import 'cps_ir_nodes.dart' as ir; |
| 33 import 'cps_ir_builder.dart'; | 38 import 'type_mask_system.dart' show TypeMaskSystem; |
| 34 import '../native/native.dart' show NativeBehavior, HasCapturedPlaceholders; | |
| 35 | |
| 36 // TODO(karlklose): remove. | 39 // TODO(karlklose): remove. |
| 37 import '../js/js.dart' as js show js, Template, Expression, Name; | |
| 38 import '../ssa/types.dart' show TypeMaskFactory; | |
| 39 import '../util/util.dart'; | |
| 40 | |
| 41 import 'package:js_runtime/shared/embedded_names.dart' | |
| 42 show JsBuiltin, JsGetName; | |
| 43 import '../constants/values.dart'; | |
| 44 import 'type_mask_system.dart' show TypeMaskSystem; | |
| 45 | 40 |
| 46 typedef void IrBuilderCallback(Element element, ir.FunctionDefinition irNode); | 41 typedef void IrBuilderCallback(Element element, ir.FunctionDefinition irNode); |
| 47 | 42 |
| 48 class ExplicitReceiverParameter implements Local { | 43 class ExplicitReceiverParameter implements Local { |
| 49 final ExecutableElement executableContext; | 44 final ExecutableElement executableContext; |
| 50 | 45 |
| 51 ExplicitReceiverParameter(this.executableContext); | 46 ExplicitReceiverParameter(this.executableContext); |
| 52 | 47 |
| 53 String get name => 'receiver'; | 48 String get name => 'receiver'; |
| 54 String toString() => 'ExplicitReceiverParameter($executableContext)'; | 49 String toString() => 'ExplicitReceiverParameter($executableContext)'; |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 env: getClosureEnvironment()); | 898 env: getClosureEnvironment()); |
| 904 | 899 |
| 905 if (element == helpers.jsArrayTypedConstructor) { | 900 if (element == helpers.jsArrayTypedConstructor) { |
| 906 // Generate a body for JSArray<E>.typed(allocation): | 901 // Generate a body for JSArray<E>.typed(allocation): |
| 907 // | 902 // |
| 908 // t1 = setRuntimeTypeInfo(allocation, TypeExpression($E)); | 903 // t1 = setRuntimeTypeInfo(allocation, TypeExpression($E)); |
| 909 // return Refinement(t1, <JSArray>); | 904 // return Refinement(t1, <JSArray>); |
| 910 // | 905 // |
| 911 assert(parameters.length == 1 || parameters.length == 2); | 906 assert(parameters.length == 1 || parameters.length == 2); |
| 912 ir.Primitive allocation = irBuilder.buildLocalGet(parameters[0]); | 907 ir.Primitive allocation = irBuilder.buildLocalGet(parameters[0]); |
| 913 ClassElement classElement = element.enclosingElement; | |
| 914 | 908 |
| 915 // Only call setRuntimeTypeInfo if JSArray requires the type parameter. | 909 // Only call setRuntimeTypeInfo if JSArray requires the type parameter. |
| 916 if (requiresRuntimeTypes) { | 910 if (requiresRuntimeTypes) { |
| 917 assert(parameters.length == 2); | 911 assert(parameters.length == 2); |
| 918 closure.TypeVariableLocal typeParameter = parameters[1]; | 912 closure.TypeVariableLocal typeParameter = parameters[1]; |
| 919 ir.Primitive typeArgument = | 913 ir.Primitive typeArgument = |
| 920 irBuilder.buildTypeVariableAccess(typeParameter.typeVariable); | 914 irBuilder.buildTypeVariableAccess(typeParameter.typeVariable); |
| 921 | 915 |
| 922 ir.Primitive typeInformation = irBuilder.addPrimitive( | 916 ir.Primitive typeInformation = irBuilder.addPrimitive( |
| 923 new ir.TypeExpression(ir.TypeExpressionKind.INSTANCE, | 917 new ir.TypeExpression(ir.TypeExpressionKind.INSTANCE, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 ir.Primitive stream = visit(node.expression); | 1119 ir.Primitive stream = visit(node.expression); |
| 1126 ir.Primitive dummyTypeArgument = irBuilder.buildNullConstant(); | 1120 ir.Primitive dummyTypeArgument = irBuilder.buildNullConstant(); |
| 1127 ConstructorElement constructor = helpers.streamIteratorConstructor; | 1121 ConstructorElement constructor = helpers.streamIteratorConstructor; |
| 1128 ir.Primitive iterator = irBuilder.addPrimitive(new ir.InvokeConstructor( | 1122 ir.Primitive iterator = irBuilder.addPrimitive(new ir.InvokeConstructor( |
| 1129 constructor.enclosingClass.thisType, | 1123 constructor.enclosingClass.thisType, |
| 1130 constructor, | 1124 constructor, |
| 1131 new Selector.callConstructor(constructor.memberName, 1), | 1125 new Selector.callConstructor(constructor.memberName, 1), |
| 1132 <ir.Primitive>[stream, dummyTypeArgument], | 1126 <ir.Primitive>[stream, dummyTypeArgument], |
| 1133 sourceInformationBuilder.buildGeneric(node))); | 1127 sourceInformationBuilder.buildGeneric(node))); |
| 1134 | 1128 |
| 1135 ir.Node buildTryBody(IrBuilder builder) { | 1129 buildTryBody(IrBuilder builder) { |
| 1136 ir.Node buildLoopCondition(IrBuilder builder) { | 1130 ir.Node buildLoopCondition(IrBuilder builder) { |
| 1137 ir.Primitive moveNext = builder.buildDynamicInvocation( | 1131 ir.Primitive moveNext = builder.buildDynamicInvocation( |
| 1138 iterator, | 1132 iterator, |
| 1139 Selectors.moveNext, | 1133 Selectors.moveNext, |
| 1140 elements.getMoveNextTypeMask(node), | 1134 elements.getMoveNextTypeMask(node), |
| 1141 <ir.Primitive>[], | 1135 <ir.Primitive>[], |
| 1142 sourceInformationBuilder.buildForInMoveNext(node)); | 1136 sourceInformationBuilder.buildForInMoveNext(node)); |
| 1143 return builder.addPrimitive(new ir.Await(moveNext)); | 1137 return builder.addPrimitive(new ir.Await(moveNext)); |
| 1144 } | 1138 } |
| 1145 | 1139 |
| (...skipping 2875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4021 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); | 4015 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); |
| 4022 | 4016 |
| 4023 String getJsInteropTargetPath(FunctionElement element) { | 4017 String getJsInteropTargetPath(FunctionElement element) { |
| 4024 return '${_backend.namer.fixedBackendPath(element)}.' | 4018 return '${_backend.namer.fixedBackendPath(element)}.' |
| 4025 '${_backend.nativeData.getFixedBackendName(element)}'; | 4019 '${_backend.nativeData.getFixedBackendName(element)}'; |
| 4026 } | 4020 } |
| 4027 | 4021 |
| 4028 DartType get jsJavascriptObjectType => | 4022 DartType get jsJavascriptObjectType => |
| 4029 _backend.helpers.jsJavaScriptObjectClass.thisType; | 4023 _backend.helpers.jsJavaScriptObjectClass.thisType; |
| 4030 } | 4024 } |
| OLD | NEW |