Chromium Code Reviews| 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/resolution.dart'; | 10 import '../common/resolution.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/constant_system_javascript.dart'; | 21 import '../js_backend/constant_system_javascript.dart'; |
| 22 import '../js_backend/native_data.dart'; | 22 import '../js_backend/native_data.dart'; |
| 23 import '../js_backend/no_such_method_registry.dart'; | 23 import '../js_backend/no_such_method_registry.dart'; |
| 24 import '../native/native.dart' as native; | 24 import '../native/native.dart' as native; |
| 25 import '../native/resolver.dart'; | 25 import '../native/resolver.dart'; |
| 26 import '../ordered_typeset.dart'; | 26 import '../ordered_typeset.dart'; |
| 27 import '../ssa/kernel_impact.dart'; | 27 import '../ssa/kernel_impact.dart'; |
| 28 import '../universe/call_structure.dart'; | 28 import '../universe/call_structure.dart'; |
| 29 import '../universe/world_builder.dart'; | |
| 29 import '../util/util.dart' show Link, LinkBuilder; | 30 import '../util/util.dart' show Link, LinkBuilder; |
| 30 import 'element_adapter.dart'; | 31 import 'element_adapter.dart'; |
| 31 import 'elements.dart'; | 32 import 'elements.dart'; |
| 32 | 33 |
| 33 part 'native_basic_data.dart'; | 34 part 'native_basic_data.dart'; |
| 34 part 'native_class_resolver.dart'; | 35 part 'native_class_resolver.dart'; |
| 35 part 'no_such_method_resolver.dart'; | 36 part 'no_such_method_resolver.dart'; |
| 36 part 'types.dart'; | 37 part 'types.dart'; |
| 37 | 38 |
| 38 /// World builder used for creating elements and types corresponding to Kernel | 39 /// World builder used for creating elements and types corresponding to Kernel |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1095 ConstantExpression getLocalConstant(Local local) { | 1096 ConstantExpression getLocalConstant(Local local) { |
| 1096 throw new UnimplementedError("_EvaluationEnvironment.getLocalConstant"); | 1097 throw new UnimplementedError("_EvaluationEnvironment.getLocalConstant"); |
| 1097 } | 1098 } |
| 1098 | 1099 |
| 1099 @override | 1100 @override |
| 1100 String readFromEnvironment(String name) { | 1101 String readFromEnvironment(String name) { |
| 1101 throw new UnimplementedError("_EvaluationEnvironment.readFromEnvironment"); | 1102 throw new UnimplementedError("_EvaluationEnvironment.readFromEnvironment"); |
| 1102 } | 1103 } |
| 1103 } | 1104 } |
| 1104 | 1105 |
| 1106 class KernelResolutionWorldBuilder extends KernelResolutionWorldBuilderBase { | |
| 1107 final KernelWorldBuilder worldBuilder; | |
| 1108 | |
| 1109 KernelResolutionWorldBuilder( | |
| 1110 this.worldBuilder, | |
| 1111 NativeBasicData nativeBasicData, | |
| 1112 SelectorConstraintsStrategy selectorConstraintsStrategy) | |
| 1113 : super(worldBuilder.elementEnvironment, worldBuilder.commonElements, | |
| 1114 nativeBasicData, selectorConstraintsStrategy); | |
| 1115 | |
| 1116 @override | |
| 1117 Iterable<InterfaceType> getSupertypes(ClassEntity cls) { | |
| 1118 return worldBuilder._getOrderedTypeSet(cls).supertypes; | |
| 1119 } | |
| 1120 | |
| 1121 @override | |
| 1122 ClassEntity getSuperClass(ClassEntity cls) { | |
| 1123 return worldBuilder._getSuperType(cls)?.element; | |
| 1124 } | |
| 1125 | |
| 1126 @override | |
| 1127 bool implementsFunction(ClassEntity cls) { | |
| 1128 // TODO(johnniwinther): Implement this. | |
| 1129 return false; | |
|
Siggi Cherem (dart-lang)
2017/04/21 17:04:21
throw?
Johnni Winther
2017/04/24 09:53:46
Needed for the closed world computation.
| |
| 1130 } | |
| 1131 | |
| 1132 @override | |
| 1133 int getHierarchyDepth(ClassEntity cls) { | |
| 1134 return worldBuilder._getHierarchyDepth(cls); | |
| 1135 } | |
| 1136 | |
| 1137 @override | |
| 1138 ClassEntity getAppliedMixin(ClassEntity cls) { | |
| 1139 // TODO(johnniwinther): Implement this. | |
| 1140 return null; | |
| 1141 } | |
| 1142 | |
| 1143 @override | |
| 1144 bool validateClass(ClassEntity cls) => true; | |
| 1145 | |
| 1146 @override | |
| 1147 bool checkClass(ClassEntity cls) => true; | |
| 1148 } | |
| 1149 | |
| 1105 // Interface for testing equivalence of Kernel-based entities. | 1150 // Interface for testing equivalence of Kernel-based entities. |
| 1106 class WorldDeconstructionForTesting { | 1151 class WorldDeconstructionForTesting { |
| 1107 final KernelWorldBuilder builder; | 1152 final KernelWorldBuilder builder; |
| 1108 | 1153 |
| 1109 WorldDeconstructionForTesting(this.builder); | 1154 WorldDeconstructionForTesting(this.builder); |
| 1110 | 1155 |
| 1111 Uri getLibraryUri(KLibrary library) { | 1156 Uri getLibraryUri(KLibrary library) { |
| 1112 return builder._libraryEnvs[library.libraryIndex].library.importUri; | 1157 return builder._libraryEnvs[library.libraryIndex].library.importUri; |
| 1113 } | 1158 } |
| 1114 | 1159 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1144 } | 1189 } |
| 1145 | 1190 |
| 1146 InterfaceType getMixinTypeForClass(KClass cls) { | 1191 InterfaceType getMixinTypeForClass(KClass cls) { |
| 1147 KClassEnv env = builder._classEnvs[cls.classIndex]; | 1192 KClassEnv env = builder._classEnvs[cls.classIndex]; |
| 1148 ir.Supertype mixedInType = env.cls.mixedInType; | 1193 ir.Supertype mixedInType = env.cls.mixedInType; |
| 1149 if (mixedInType == null) return null; | 1194 if (mixedInType == null) return null; |
| 1150 return builder.createInterfaceType( | 1195 return builder.createInterfaceType( |
| 1151 mixedInType.classNode, mixedInType.typeArguments); | 1196 mixedInType.classNode, mixedInType.typeArguments); |
| 1152 } | 1197 } |
| 1153 } | 1198 } |
| OLD | NEW |