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

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

Issue 2859133003: Find native classes with mixins in NativeClassFinder (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/native/enqueue.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.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/names.dart' show Identifiers; 10 import '../common/names.dart' show Identifiers;
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 return type.subst( 498 return type.subst(
499 context.typeArguments, _getThisType(context.element).typeArguments); 499 context.typeArguments, _getThisType(context.element).typeArguments);
500 } 500 }
501 501
502 InterfaceType _getSuperType(KClass cls) { 502 InterfaceType _getSuperType(KClass cls) {
503 _KClassEnv env = _classEnvs[cls.classIndex]; 503 _KClassEnv env = _classEnvs[cls.classIndex];
504 _ensureSupertypes(cls, env); 504 _ensureSupertypes(cls, env);
505 return env.supertype; 505 return env.supertype;
506 } 506 }
507 507
508 bool _isUnnamedMixinApplication(KClass cls) {
509 _KClassEnv env = _classEnvs[cls.classIndex];
510 _ensureSupertypes(cls, env);
511 return env.isUnnamedMixinApplication;
512 }
513
508 void _forEachSupertype(KClass cls, void f(InterfaceType supertype)) { 514 void _forEachSupertype(KClass cls, void f(InterfaceType supertype)) {
509 _KClassEnv env = _classEnvs[cls.classIndex]; 515 _KClassEnv env = _classEnvs[cls.classIndex];
510 _ensureSupertypes(cls, env); 516 _ensureSupertypes(cls, env);
511 env.orderedTypeSet.supertypes.forEach(f); 517 env.orderedTypeSet.supertypes.forEach(f);
512 } 518 }
513 519
514 void _forEachMixin(KClass cls, void f(ClassEntity mixin)) { 520 void _forEachMixin(KClass cls, void f(ClassEntity mixin)) {
515 while (cls != null) { 521 while (cls != null) {
516 _KClassEnv env = _classEnvs[cls.classIndex]; 522 _KClassEnv env = _classEnvs[cls.classIndex];
517 _ensureSupertypes(cls, env); 523 _ensureSupertypes(cls, env);
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 MemberEntity member = 984 MemberEntity member =
979 elementMap.lookupClassMember(cls, name, setter: setter); 985 elementMap.lookupClassMember(cls, name, setter: setter);
980 if (member == null && required) { 986 if (member == null && required) {
981 throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE, 987 throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE,
982 "The member '$name' was not found in ${cls.name}."); 988 "The member '$name' was not found in ${cls.name}.");
983 } 989 }
984 return member; 990 return member;
985 } 991 }
986 992
987 @override 993 @override
988 ClassEntity getSuperClass(ClassEntity cls) { 994 ClassEntity getSuperClass(ClassEntity cls,
989 return elementMap._getSuperType(cls)?.element; 995 {bool skipUnnamedMixinApplications: false}) {
996 ClassEntity superclass = elementMap._getSuperType(cls)?.element;
997 if (skipUnnamedMixinApplications) {
998 while (superclass != null &&
999 elementMap._isUnnamedMixinApplication(superclass)) {
1000 superclass = elementMap._getSuperType(superclass)?.element;
1001 }
1002 }
1003 return superclass;
990 } 1004 }
991 1005
992 @override 1006 @override
993 void forEachSupertype(ClassEntity cls, void f(InterfaceType supertype)) { 1007 void forEachSupertype(ClassEntity cls, void f(InterfaceType supertype)) {
994 elementMap._forEachSupertype(cls, f); 1008 elementMap._forEachSupertype(cls, f);
995 } 1009 }
996 1010
997 @override 1011 @override
998 void forEachMixin(ClassEntity cls, void f(ClassEntity mixin)) { 1012 void forEachMixin(ClassEntity cls, void f(ClassEntity mixin)) {
999 elementMap._forEachMixin(cls, f); 1013 elementMap._forEachMixin(cls, f);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 1273
1260 @override 1274 @override
1261 bool validateClass(ClassEntity cls) => true; 1275 bool validateClass(ClassEntity cls) => true;
1262 1276
1263 @override 1277 @override
1264 bool checkClass(ClassEntity cls) => true; 1278 bool checkClass(ClassEntity cls) => true;
1265 } 1279 }
1266 1280
1267 // Interface for testing equivalence of Kernel-based entities. 1281 // Interface for testing equivalence of Kernel-based entities.
1268 class WorldDeconstructionForTesting { 1282 class WorldDeconstructionForTesting {
1269 final KernelToElementMap builder; 1283 final KernelToElementMap elementMap;
1270 1284
1271 WorldDeconstructionForTesting(this.builder); 1285 WorldDeconstructionForTesting(this.elementMap);
1272 1286
1273 KClass getSuperclassForClass(KClass cls) { 1287 KClass getSuperclassForClass(KClass cls) {
1274 _KClassEnv env = builder._classEnvs[cls.classIndex]; 1288 _KClassEnv env = elementMap._classEnvs[cls.classIndex];
1275 ir.Supertype supertype = env.cls.supertype; 1289 ir.Supertype supertype = env.cls.supertype;
1276 if (supertype == null) return null; 1290 if (supertype == null) return null;
1277 return builder.getClass(supertype.classNode); 1291 return elementMap.getClass(supertype.classNode);
1278 } 1292 }
1279 1293
1280 bool isUnnamedMixinApplication(KClass cls) { 1294 bool isUnnamedMixinApplication(KClass cls) {
1281 _KClassEnv env = builder._classEnvs[cls.classIndex]; 1295 return elementMap._isUnnamedMixinApplication(cls);
1282 return env.isUnnamedMixinApplication;
1283 } 1296 }
1284 1297
1285 InterfaceType getMixinTypeForClass(KClass cls) { 1298 InterfaceType getMixinTypeForClass(KClass cls) {
1286 _KClassEnv env = builder._classEnvs[cls.classIndex]; 1299 _KClassEnv env = elementMap._classEnvs[cls.classIndex];
1287 ir.Supertype mixedInType = env.cls.mixedInType; 1300 ir.Supertype mixedInType = env.cls.mixedInType;
1288 if (mixedInType == null) return null; 1301 if (mixedInType == null) return null;
1289 return builder.createInterfaceType( 1302 return elementMap.createInterfaceType(
1290 mixedInType.classNode, mixedInType.typeArguments); 1303 mixedInType.classNode, mixedInType.typeArguments);
1291 } 1304 }
1292 } 1305 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/native/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698