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

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

Issue 2850143002: Reuse RuntimeTypesNeedBuilderImpl and _RuntimeTypesNeed for kernel based elements (Closed)
Patch Set: Fix comment 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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 _ensureThisAndRawType(cls, env); 417 _ensureThisAndRawType(cls, env);
418 return env.thisType; 418 return env.thisType;
419 } 419 }
420 420
421 InterfaceType _getRawType(KClass cls) { 421 InterfaceType _getRawType(KClass cls) {
422 _KClassEnv env = _classEnvs[cls.classIndex]; 422 _KClassEnv env = _classEnvs[cls.classIndex];
423 _ensureThisAndRawType(cls, env); 423 _ensureThisAndRawType(cls, env);
424 return env.rawType; 424 return env.rawType;
425 } 425 }
426 426
427 InterfaceType _asInstanceOf(InterfaceType type, KClass cls) {
428 OrderedTypeSet orderedTypeSet = _getOrderedTypeSet(type.element);
429 InterfaceType supertype =
430 orderedTypeSet.asInstanceOf(cls, _getHierarchyDepth(cls));
431 if (supertype != null) {
432 supertype = _substByContext(supertype, type);
433 }
434 return supertype;
435 }
436
427 void _ensureSupertypes(KClass cls, _KClassEnv env) { 437 void _ensureSupertypes(KClass cls, _KClassEnv env) {
428 if (env.orderedTypeSet == null) { 438 if (env.orderedTypeSet == null) {
429 _ensureThisAndRawType(cls, env); 439 _ensureThisAndRawType(cls, env);
430 440
431 ir.Class node = env.cls; 441 ir.Class node = env.cls;
432 442
433 if (node.supertype == null) { 443 if (node.supertype == null) {
434 env.orderedTypeSet = new OrderedTypeSet.singleton(env.thisType); 444 env.orderedTypeSet = new OrderedTypeSet.singleton(env.thisType);
435 } else { 445 } else {
436 InterfaceType processSupertype(ir.Supertype node) { 446 InterfaceType processSupertype(ir.Supertype node) {
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 InterfaceType getThisType(ClassEntity cls) { 904 InterfaceType getThisType(ClassEntity cls) {
895 return elementMap._getThisType(cls); 905 return elementMap._getThisType(cls);
896 } 906 }
897 907
898 @override 908 @override
899 InterfaceType getRawType(ClassEntity cls) { 909 InterfaceType getRawType(ClassEntity cls) {
900 return elementMap._getRawType(cls); 910 return elementMap._getRawType(cls);
901 } 911 }
902 912
903 @override 913 @override
914 bool isGenericClass(ClassEntity cls) {
915 return getThisType(cls).typeArguments.isNotEmpty;
916 }
917
918 @override
904 DartType getTypeVariableBound(TypeVariableEntity typeVariable) { 919 DartType getTypeVariableBound(TypeVariableEntity typeVariable) {
905 throw new UnimplementedError( 920 throw new UnimplementedError(
906 'KernelElementEnvironment.getTypeVariableBound'); 921 'KernelElementEnvironment.getTypeVariableBound');
907 } 922 }
908 923
909 @override 924 @override
910 InterfaceType createInterfaceType( 925 InterfaceType createInterfaceType(
911 ClassEntity cls, List<DartType> typeArguments) { 926 ClassEntity cls, List<DartType> typeArguments) {
912 return new InterfaceType(cls, typeArguments); 927 return new InterfaceType(cls, typeArguments);
913 } 928 }
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 } 1297 }
1283 1298
1284 InterfaceType getMixinTypeForClass(KClass cls) { 1299 InterfaceType getMixinTypeForClass(KClass cls) {
1285 _KClassEnv env = builder._classEnvs[cls.classIndex]; 1300 _KClassEnv env = builder._classEnvs[cls.classIndex];
1286 ir.Supertype mixedInType = env.cls.mixedInType; 1301 ir.Supertype mixedInType = env.cls.mixedInType;
1287 if (mixedInType == null) return null; 1302 if (mixedInType == null) return null;
1288 return builder.createInterfaceType( 1303 return builder.createInterfaceType(
1289 mixedInType.classNode, mixedInType.typeArguments); 1304 mixedInType.classNode, mixedInType.typeArguments);
1290 } 1305 }
1291 } 1306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698