| 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.element_map; | 5 library dart2js.kernel.element_map; |
| 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'; |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 @override | 1243 @override |
| 1244 bool checkClass(ClassEntity cls) => true; | 1244 bool checkClass(ClassEntity cls) => true; |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 // Interface for testing equivalence of Kernel-based entities. | 1247 // Interface for testing equivalence of Kernel-based entities. |
| 1248 class WorldDeconstructionForTesting { | 1248 class WorldDeconstructionForTesting { |
| 1249 final KernelToElementMap builder; | 1249 final KernelToElementMap builder; |
| 1250 | 1250 |
| 1251 WorldDeconstructionForTesting(this.builder); | 1251 WorldDeconstructionForTesting(this.builder); |
| 1252 | 1252 |
| 1253 KLibrary _getLibrary<E>(E member, Map<ir.Member, E> map) { | |
| 1254 ir.Library library; | |
| 1255 map.forEach((ir.Member node, E other) { | |
| 1256 if (library == null && member == other) { | |
| 1257 library = node.enclosingLibrary; | |
| 1258 } | |
| 1259 }); | |
| 1260 if (library == null) { | |
| 1261 throw new ArgumentError("No library found for $member"); | |
| 1262 } | |
| 1263 return builder._getLibrary(library); | |
| 1264 } | |
| 1265 | |
| 1266 KLibrary getLibraryForFunction(KFunction function) => | |
| 1267 _getLibrary(function, builder._methodMap); | |
| 1268 | |
| 1269 KLibrary getLibraryForField(KField field) => | |
| 1270 _getLibrary(field, builder._fieldMap); | |
| 1271 | |
| 1272 KClass getSuperclassForClass(KClass cls) { | 1253 KClass getSuperclassForClass(KClass cls) { |
| 1273 _KClassEnv env = builder._classEnvs[cls.classIndex]; | 1254 _KClassEnv env = builder._classEnvs[cls.classIndex]; |
| 1274 ir.Supertype supertype = env.cls.supertype; | 1255 ir.Supertype supertype = env.cls.supertype; |
| 1275 if (supertype == null) return null; | 1256 if (supertype == null) return null; |
| 1276 return builder.getClass(supertype.classNode); | 1257 return builder.getClass(supertype.classNode); |
| 1277 } | 1258 } |
| 1278 | 1259 |
| 1279 bool isUnnamedMixinApplication(KClass cls) { | 1260 bool isUnnamedMixinApplication(KClass cls) { |
| 1280 _KClassEnv env = builder._classEnvs[cls.classIndex]; | 1261 _KClassEnv env = builder._classEnvs[cls.classIndex]; |
| 1281 return env.isUnnamedMixinApplication; | 1262 return env.isUnnamedMixinApplication; |
| 1282 } | 1263 } |
| 1283 | 1264 |
| 1284 InterfaceType getMixinTypeForClass(KClass cls) { | 1265 InterfaceType getMixinTypeForClass(KClass cls) { |
| 1285 _KClassEnv env = builder._classEnvs[cls.classIndex]; | 1266 _KClassEnv env = builder._classEnvs[cls.classIndex]; |
| 1286 ir.Supertype mixedInType = env.cls.mixedInType; | 1267 ir.Supertype mixedInType = env.cls.mixedInType; |
| 1287 if (mixedInType == null) return null; | 1268 if (mixedInType == null) return null; |
| 1288 return builder.createInterfaceType( | 1269 return builder.createInterfaceType( |
| 1289 mixedInType.classNode, mixedInType.typeArguments); | 1270 mixedInType.classNode, mixedInType.typeArguments); |
| 1290 } | 1271 } |
| 1291 } | 1272 } |
| OLD | NEW |