Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: pkg/compiler/lib/src/kernel/world_builder.dart

Issue 2814453005: Merge CommonElements and BackendHelpers! (Closed)
Patch Set: comments and re-merge, take two Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 '../common/resolution.dart'; 11 import '../common/resolution.dart';
12 import '../compile_time_constants.dart'; 12 import '../compile_time_constants.dart';
13 import '../constants/constant_system.dart'; 13 import '../constants/constant_system.dart';
14 import '../constants/constructors.dart'; 14 import '../constants/constructors.dart';
15 import '../constants/evaluation.dart'; 15 import '../constants/evaluation.dart';
16 import '../constants/expressions.dart'; 16 import '../constants/expressions.dart';
17 import '../constants/values.dart'; 17 import '../constants/values.dart';
18 import '../common_elements.dart'; 18 import '../common_elements.dart';
19 import '../elements/elements.dart'; 19 import '../elements/elements.dart';
20 import '../elements/entities.dart'; 20 import '../elements/entities.dart';
21 import '../elements/types.dart'; 21 import '../elements/types.dart';
22 import '../js_backend/backend_helpers.dart';
23 import '../js_backend/constant_system_javascript.dart'; 22 import '../js_backend/constant_system_javascript.dart';
24 import '../js_backend/no_such_method_registry.dart'; 23 import '../js_backend/no_such_method_registry.dart';
25 import '../native/native.dart' as native; 24 import '../native/native.dart' as native;
26 import '../native/resolver.dart'; 25 import '../native/resolver.dart';
27 import '../ssa/kernel_impact.dart'; 26 import '../ssa/kernel_impact.dart';
28 import '../universe/call_structure.dart'; 27 import '../universe/call_structure.dart';
29 import 'element_adapter.dart'; 28 import 'element_adapter.dart';
30 import 'elements.dart'; 29 import 'elements.dart';
31 30
32 part 'native_class_resolver.dart'; 31 part 'native_class_resolver.dart';
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 Map<ir.Field, KField> _fieldMap = <ir.Field, KField>{}; 70 Map<ir.Field, KField> _fieldMap = <ir.Field, KField>{};
72 Map<KField, ConstantExpression> _fieldConstantMap = 71 Map<KField, ConstantExpression> _fieldConstantMap =
73 <KField, ConstantExpression>{}; 72 <KField, ConstantExpression>{};
74 73
75 Map<ir.TreeNode, KLocalFunction> _localFunctionMap = 74 Map<ir.TreeNode, KLocalFunction> _localFunctionMap =
76 <ir.TreeNode, KLocalFunction>{}; 75 <ir.TreeNode, KLocalFunction>{};
77 76
78 KernelWorldBuilder(this.reporter, ir.Program program) 77 KernelWorldBuilder(this.reporter, ir.Program program)
79 : _env = new KEnv(program) { 78 : _env = new KEnv(program) {
80 _elementEnvironment = new KernelElementEnvironment(this); 79 _elementEnvironment = new KernelElementEnvironment(this);
81 _commonElements = new CommonElementsImpl(_elementEnvironment); 80 _commonElements = new CommonElements(_elementEnvironment);
82 ConstantEnvironment constants = new KernelConstantEnvironment(this); 81 ConstantEnvironment constants = new KernelConstantEnvironment(this);
83 _nativeBehaviorBuilder = 82 _nativeBehaviorBuilder =
84 new KernelBehaviorBuilder(_commonElements, helpers, constants); 83 new KernelBehaviorBuilder(_commonElements, constants);
85 _typeConverter = new DartTypeConverter(this); 84 _typeConverter = new DartTypeConverter(this);
86 } 85 }
87 86
88 KMethod get _mainFunction { 87 KMethod get _mainFunction {
89 return _env.program.mainMethod != null 88 return _env.program.mainMethod != null
90 ? _getMethod(_env.program.mainMethod) 89 ? _getMethod(_env.program.mainMethod)
91 : null; 90 : null;
92 } 91 }
93 92
94 KLibrary get _mainLibrary { 93 KLibrary get _mainLibrary {
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 "Outermost invalid types not currently supported"); 855 "Outermost invalid types not currently supported");
857 } 856 }
858 // Nested invalid types are treated as `dynamic`. 857 // Nested invalid types are treated as `dynamic`.
859 return const DynamicType(); 858 return const DynamicType();
860 } 859 }
861 } 860 }
862 861
863 /// [native.BehaviorBuilder] for kernel based elements. 862 /// [native.BehaviorBuilder] for kernel based elements.
864 class KernelBehaviorBuilder extends native.BehaviorBuilder { 863 class KernelBehaviorBuilder extends native.BehaviorBuilder {
865 final CommonElements commonElements; 864 final CommonElements commonElements;
866 final BackendHelpers helpers;
867 final ConstantEnvironment constants; 865 final ConstantEnvironment constants;
868 866
869 KernelBehaviorBuilder(this.commonElements, this.helpers, this.constants); 867 KernelBehaviorBuilder(this.commonElements, this.constants);
870 868
871 @override 869 @override
872 bool get trustJSInteropTypeAnnotations { 870 bool get trustJSInteropTypeAnnotations {
873 throw new UnimplementedError( 871 throw new UnimplementedError(
874 "KernelNativeBehaviorComputer.trustJSInteropTypeAnnotations"); 872 "KernelNativeBehaviorComputer.trustJSInteropTypeAnnotations");
875 } 873 }
876 874
877 @override 875 @override
878 DiagnosticReporter get reporter { 876 DiagnosticReporter get reporter {
879 throw new UnimplementedError("KernelNativeBehaviorComputer.reporter"); 877 throw new UnimplementedError("KernelNativeBehaviorComputer.reporter");
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 } 1003 }
1006 1004
1007 InterfaceType getMixinTypeForClass(KClass cls) { 1005 InterfaceType getMixinTypeForClass(KClass cls) {
1008 KClassEnv env = builder._classEnvs[cls.classIndex]; 1006 KClassEnv env = builder._classEnvs[cls.classIndex];
1009 ir.Supertype mixedInType = env.cls.mixedInType; 1007 ir.Supertype mixedInType = env.cls.mixedInType;
1010 if (mixedInType == null) return null; 1008 if (mixedInType == null) return null;
1011 return builder.createInterfaceType( 1009 return builder.createInterfaceType(
1012 mixedInType.classNode, mixedInType.typeArguments); 1010 mixedInType.classNode, mixedInType.typeArguments);
1013 } 1011 }
1014 } 1012 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/element_adapter.dart ('k') | pkg/compiler/lib/src/native/behavior.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698