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

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

Issue 2836993003: Handle instantiation of native classes in closed_world2_test (Closed)
Patch Set: Fixes 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
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/resolution.dart'; 10 import '../common/resolution.dart';
(...skipping 15 matching lines...) Expand all
26 import '../native/resolver.dart'; 26 import '../native/resolver.dart';
27 import '../ordered_typeset.dart'; 27 import '../ordered_typeset.dart';
28 import '../ssa/kernel_impact.dart'; 28 import '../ssa/kernel_impact.dart';
29 import '../universe/call_structure.dart'; 29 import '../universe/call_structure.dart';
30 import '../universe/world_builder.dart'; 30 import '../universe/world_builder.dart';
31 import '../util/util.dart' show Link, LinkBuilder; 31 import '../util/util.dart' show Link, LinkBuilder;
32 import 'element_adapter.dart'; 32 import 'element_adapter.dart';
33 import 'elements.dart'; 33 import 'elements.dart';
34 34
35 part 'native_basic_data.dart'; 35 part 'native_basic_data.dart';
36 part 'native_class_resolver.dart';
37 part 'no_such_method_resolver.dart'; 36 part 'no_such_method_resolver.dart';
38 part 'types.dart'; 37 part 'types.dart';
39 38
40 /// Element builder used for creating elements and types corresponding to Kernel 39 /// Element builder used for creating elements and types corresponding to Kernel
41 /// IR nodes. 40 /// IR nodes.
42 class KernelToElementMap extends KernelElementAdapterMixin { 41 class KernelToElementMap extends KernelElementAdapterMixin {
43 CommonElements _commonElements; 42 CommonElements _commonElements;
44 native.BehaviorBuilder _nativeBehaviorBuilder; 43 native.BehaviorBuilder _nativeBehaviorBuilder;
45 final DiagnosticReporter reporter; 44 final DiagnosticReporter reporter;
46 ElementEnvironment _elementEnvironment; 45 ElementEnvironment _elementEnvironment;
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 KClass superclass = type.element; 435 KClass superclass = type.element;
437 _KClassEnv env = _classEnvs[superclass.classIndex]; 436 _KClassEnv env = _classEnvs[superclass.classIndex];
438 _ensureSupertypes(superclass, env); 437 _ensureSupertypes(superclass, env);
439 return type; 438 return type;
440 } 439 }
441 440
442 env.supertype = processSupertype(node.supertype); 441 env.supertype = processSupertype(node.supertype);
443 LinkBuilder<InterfaceType> linkBuilder = 442 LinkBuilder<InterfaceType> linkBuilder =
444 new LinkBuilder<InterfaceType>(); 443 new LinkBuilder<InterfaceType>();
445 if (node.mixedInType != null) { 444 if (node.mixedInType != null) {
446 linkBuilder.addLast(processSupertype(node.mixedInType)); 445 linkBuilder
446 .addLast(env.mixedInType = processSupertype(node.mixedInType));
447 } 447 }
448 node.implementedTypes.forEach((ir.Supertype supertype) { 448 node.implementedTypes.forEach((ir.Supertype supertype) {
449 linkBuilder.addLast(processSupertype(supertype)); 449 linkBuilder.addLast(processSupertype(supertype));
450 }); 450 });
451 Link<InterfaceType> interfaces = linkBuilder.toLink(); 451 Link<InterfaceType> interfaces = linkBuilder.toLink();
452 OrderedTypeSetBuilder setBuilder = 452 OrderedTypeSetBuilder setBuilder =
453 new _KernelOrderedTypeSetBuilder(this, cls); 453 new _KernelOrderedTypeSetBuilder(this, cls);
454 env.orderedTypeSet = 454 env.orderedTypeSet =
455 setBuilder.createOrderedTypeSet(env.supertype, interfaces); 455 setBuilder.createOrderedTypeSet(env.supertype, interfaces);
456 } 456 }
(...skipping 22 matching lines...) Expand all
479 _ensureSupertypes(cls, env); 479 _ensureSupertypes(cls, env);
480 return env.supertype; 480 return env.supertype;
481 } 481 }
482 482
483 void _forEachSupertype(KClass cls, void f(InterfaceType supertype)) { 483 void _forEachSupertype(KClass cls, void f(InterfaceType supertype)) {
484 _KClassEnv env = _classEnvs[cls.classIndex]; 484 _KClassEnv env = _classEnvs[cls.classIndex];
485 _ensureSupertypes(cls, env); 485 _ensureSupertypes(cls, env);
486 env.orderedTypeSet.supertypes.forEach(f); 486 env.orderedTypeSet.supertypes.forEach(f);
487 } 487 }
488 488
489 void _forEachMixin(KClass cls, void f(ClassEntity mixin)) {
490 while (cls != null) {
491 _KClassEnv env = _classEnvs[cls.classIndex];
492 _ensureSupertypes(cls, env);
493 if (env.mixedInType != null) {
494 f(env.mixedInType.element);
495 }
496 cls = env.supertype?.element;
497 }
498 }
499
489 void _forEachClassMember( 500 void _forEachClassMember(
490 KClass cls, void f(ClassEntity cls, MemberEntity member)) { 501 KClass cls, void f(ClassEntity cls, MemberEntity member)) {
491 _KClassEnv env = _classEnvs[cls.classIndex]; 502 _KClassEnv env = _classEnvs[cls.classIndex];
492 env.forEachMember((ir.Member member) { 503 env.forEachMember((ir.Member member) {
493 f(cls, getMember(member)); 504 f(cls, getMember(member));
494 }); 505 });
495 _ensureSupertypes(cls, env); 506 _ensureSupertypes(cls, env);
496 if (env.supertype != null) { 507 if (env.supertype != null) {
497 _forEachClassMember(env.supertype.element, f); 508 _forEachClassMember(env.supertype.element, f);
498 } 509 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 } 703 }
693 } 704 }
694 705
695 /// Environment for fast lookup of class members. 706 /// Environment for fast lookup of class members.
696 class _KClassEnv { 707 class _KClassEnv {
697 final ir.Class cls; 708 final ir.Class cls;
698 709
699 InterfaceType thisType; 710 InterfaceType thisType;
700 InterfaceType rawType; 711 InterfaceType rawType;
701 InterfaceType supertype; 712 InterfaceType supertype;
713 InterfaceType mixedInType;
702 OrderedTypeSet orderedTypeSet; 714 OrderedTypeSet orderedTypeSet;
703 715
704 Map<String, ir.Member> _constructorMap; 716 Map<String, ir.Member> _constructorMap;
705 Map<String, ir.Member> _memberMap; 717 Map<String, ir.Member> _memberMap;
706 Map<String, ir.Member> _setterMap; 718 Map<String, ir.Member> _setterMap;
707 719
708 Iterable<ConstantExpression> _metadata; 720 Iterable<ConstantExpression> _metadata;
709 721
710 _KClassEnv(this.cls); 722 _KClassEnv(this.cls);
711 723
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 return elementMap._getSuperType(cls)?.element; 937 return elementMap._getSuperType(cls)?.element;
926 } 938 }
927 939
928 @override 940 @override
929 void forEachSupertype(ClassEntity cls, void f(InterfaceType supertype)) { 941 void forEachSupertype(ClassEntity cls, void f(InterfaceType supertype)) {
930 elementMap._forEachSupertype(cls, f); 942 elementMap._forEachSupertype(cls, f);
931 } 943 }
932 944
933 @override 945 @override
934 void forEachMixin(ClassEntity cls, void f(ClassEntity mixin)) { 946 void forEachMixin(ClassEntity cls, void f(ClassEntity mixin)) {
935 throw new UnimplementedError('KernelElementEnvironment.forEachMixin'); 947 elementMap._forEachMixin(cls, f);
936 } 948 }
937 949
938 @override 950 @override
939 void forEachClassMember( 951 void forEachClassMember(
940 ClassEntity cls, void f(ClassEntity declarer, MemberEntity member)) { 952 ClassEntity cls, void f(ClassEntity declarer, MemberEntity member)) {
941 elementMap._forEachClassMember(cls, f); 953 elementMap._forEachClassMember(cls, f);
942 } 954 }
943 955
944 @override 956 @override
945 MemberEntity lookupLibraryMember(LibraryEntity library, String name, 957 MemberEntity lookupLibraryMember(LibraryEntity library, String name,
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 } 1263 }
1252 1264
1253 InterfaceType getMixinTypeForClass(KClass cls) { 1265 InterfaceType getMixinTypeForClass(KClass cls) {
1254 _KClassEnv env = builder._classEnvs[cls.classIndex]; 1266 _KClassEnv env = builder._classEnvs[cls.classIndex];
1255 ir.Supertype mixedInType = env.cls.mixedInType; 1267 ir.Supertype mixedInType = env.cls.mixedInType;
1256 if (mixedInType == null) return null; 1268 if (mixedInType == null) return null;
1257 return builder.createInterfaceType( 1269 return builder.createInterfaceType(
1258 mixedInType.classNode, mixedInType.typeArguments); 1270 mixedInType.classNode, mixedInType.typeArguments);
1259 } 1271 }
1260 } 1272 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/kernel/kernel_strategy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698