OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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.kernel.world_builder; | 5 library dart2js.kernel.world_builder; |
6 | 6 |
7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
8 | 8 |
9 import '../common.dart'; | 9 import '../common.dart'; |
10 import '../common/backend_api.dart'; | 10 import '../common/backend_api.dart'; |
11 import '../compile_time_constants.dart'; | 11 import '../compile_time_constants.dart'; |
12 import '../constants/constant_system.dart'; | 12 import '../constants/constant_system.dart'; |
13 import '../constants/constructors.dart'; | 13 import '../constants/constructors.dart'; |
14 import '../constants/evaluation.dart'; | 14 import '../constants/evaluation.dart'; |
15 import '../constants/expressions.dart'; | 15 import '../constants/expressions.dart'; |
16 import '../constants/values.dart'; | 16 import '../constants/values.dart'; |
17 import '../common_elements.dart'; | 17 import '../common_elements.dart'; |
18 import '../elements/elements.dart'; | 18 import '../elements/elements.dart'; |
19 import '../elements/entities.dart'; | 19 import '../elements/entities.dart'; |
20 import '../elements/types.dart'; | 20 import '../elements/types.dart'; |
21 import '../js_backend/backend_helpers.dart'; | |
22 import '../js_backend/constant_system_javascript.dart'; | 21 import '../js_backend/constant_system_javascript.dart'; |
23 import '../js_backend/no_such_method_registry.dart'; | 22 import '../js_backend/no_such_method_registry.dart'; |
24 import '../native/native.dart' as native; | 23 import '../native/native.dart' as native; |
25 import '../native/resolver.dart'; | 24 import '../native/resolver.dart'; |
26 import '../universe/call_structure.dart'; | 25 import '../universe/call_structure.dart'; |
27 import 'element_adapter.dart'; | 26 import 'element_adapter.dart'; |
28 import 'elements.dart'; | 27 import 'elements.dart'; |
29 | 28 |
30 part 'native_class_resolver.dart'; | 29 part 'native_class_resolver.dart'; |
31 part 'no_such_method_resolver.dart'; | 30 part 'no_such_method_resolver.dart'; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 Map<ir.Field, KField> _fieldMap = <ir.Field, KField>{}; | 68 Map<ir.Field, KField> _fieldMap = <ir.Field, KField>{}; |
70 Map<KField, ConstantExpression> _fieldConstantMap = | 69 Map<KField, ConstantExpression> _fieldConstantMap = |
71 <KField, ConstantExpression>{}; | 70 <KField, ConstantExpression>{}; |
72 | 71 |
73 Map<ir.TreeNode, KLocalFunction> _localFunctionMap = | 72 Map<ir.TreeNode, KLocalFunction> _localFunctionMap = |
74 <ir.TreeNode, KLocalFunction>{}; | 73 <ir.TreeNode, KLocalFunction>{}; |
75 | 74 |
76 KernelWorldBuilder(this.reporter, ir.Program program) | 75 KernelWorldBuilder(this.reporter, ir.Program program) |
77 : _env = new KEnv(program) { | 76 : _env = new KEnv(program) { |
78 _elementEnvironment = new KernelElementEnvironment(this); | 77 _elementEnvironment = new KernelElementEnvironment(this); |
79 _commonElements = new CommonElementsImpl(_elementEnvironment); | 78 _commonElements = new CommonElements(_elementEnvironment); |
80 ConstantEnvironment constants = new KernelConstantEnvironment(this); | 79 ConstantEnvironment constants = new KernelConstantEnvironment(this); |
81 _nativeBehaviorBuilder = | 80 _nativeBehaviorBuilder = |
82 new KernelBehaviorBuilder(_commonElements, helpers, constants); | 81 new KernelBehaviorBuilder(_commonElements, constants); |
83 _typeConverter = new DartTypeConverter(this); | 82 _typeConverter = new DartTypeConverter(this); |
84 } | 83 } |
85 | 84 |
86 KMethod get _mainFunction { | 85 KMethod get _mainFunction { |
87 return _env.program.mainMethod != null | 86 return _env.program.mainMethod != null |
88 ? _getMethod(_env.program.mainMethod) | 87 ? _getMethod(_env.program.mainMethod) |
89 : null; | 88 : null; |
90 } | 89 } |
91 | 90 |
92 KLibrary get _mainLibrary { | 91 KLibrary get _mainLibrary { |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 "Outermost invalid types not currently supported"); | 742 "Outermost invalid types not currently supported"); |
744 } | 743 } |
745 // Nested invalid types are treated as `dynamic`. | 744 // Nested invalid types are treated as `dynamic`. |
746 return const DynamicType(); | 745 return const DynamicType(); |
747 } | 746 } |
748 } | 747 } |
749 | 748 |
750 /// [native.BehaviorBuilder] for kernel based elements. | 749 /// [native.BehaviorBuilder] for kernel based elements. |
751 class KernelBehaviorBuilder extends native.BehaviorBuilder { | 750 class KernelBehaviorBuilder extends native.BehaviorBuilder { |
752 final CommonElements commonElements; | 751 final CommonElements commonElements; |
753 final BackendHelpers helpers; | |
754 final ConstantEnvironment constants; | 752 final ConstantEnvironment constants; |
755 | 753 |
756 KernelBehaviorBuilder(this.commonElements, this.helpers, this.constants); | 754 KernelBehaviorBuilder(this.commonElements, this.constants); |
757 | 755 |
758 @override | 756 @override |
759 bool get trustJSInteropTypeAnnotations { | 757 bool get trustJSInteropTypeAnnotations { |
760 throw new UnimplementedError( | 758 throw new UnimplementedError( |
761 "KernelNativeBehaviorComputer.trustJSInteropTypeAnnotations"); | 759 "KernelNativeBehaviorComputer.trustJSInteropTypeAnnotations"); |
762 } | 760 } |
763 | 761 |
764 @override | 762 @override |
765 DiagnosticReporter get reporter { | 763 DiagnosticReporter get reporter { |
766 throw new UnimplementedError("KernelNativeBehaviorComputer.reporter"); | 764 throw new UnimplementedError("KernelNativeBehaviorComputer.reporter"); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 } | 890 } |
893 | 891 |
894 InterfaceType getMixinTypeForClass(KClass cls) { | 892 InterfaceType getMixinTypeForClass(KClass cls) { |
895 KClassEnv env = builder._classEnvs[cls.classIndex]; | 893 KClassEnv env = builder._classEnvs[cls.classIndex]; |
896 ir.Supertype mixedInType = env.cls.mixedInType; | 894 ir.Supertype mixedInType = env.cls.mixedInType; |
897 if (mixedInType == null) return null; | 895 if (mixedInType == null) return null; |
898 return builder.createInterfaceType( | 896 return builder.createInterfaceType( |
899 mixedInType.classNode, mixedInType.typeArguments); | 897 mixedInType.classNode, mixedInType.typeArguments); |
900 } | 898 } |
901 } | 899 } |
OLD | NEW |