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

Unified Diff: pkg/compiler/lib/src/kernel/element_map_impl.dart

Issue 2970673004: Handle static fields in js_model/model_test (Closed)
Patch Set: Updated cf. comment Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/js_model/js_strategy.dart ('k') | pkg/compiler/lib/src/world.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/kernel/element_map_impl.dart
diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart
index 18d00bae482ada4039afb9a6de0f300c3c295afa..3d120e6fc6e8d61f9e44d0690ffd2f65f8783cbb 100644
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart
@@ -972,21 +972,10 @@ class KernelToElementMapForImpactImpl2 extends KernelToElementMapBase
: super(reporter, environment);
}
-/// Element builder used for creating elements and types corresponding to Kernel
-/// IR nodes.
-// TODO(johnniwinther): Use this in the JsStrategy
-class KernelToElementMapForBuildingImpl extends KernelToElementMapBase
- with
- KernelToElementMapForBuildingMixin,
- ElementCreatorMixin,
- KElementCreatorMixin
- implements KernelToWorldBuilder {
- KernelToElementMapForBuildingImpl(
- DiagnosticReporter reporter, Environment environment)
- : super(reporter, environment);
-
- ConstantEnvironment get constantEnvironment => _constantEnvironment;
-
+/// Mixin for implementing [KernelToElementMapForBuilding] shared between
+/// classes that extend [KernelToElementMapBase], i.e. not [KernelAstAdapter].
+abstract class KernelToElementMapForBuildingFromBaseMixin
+ implements KernelToElementMapForBuilding, KernelToElementMapBase {
@override
ConstantValue getFieldConstantValue(ir.Field field) {
// TODO(johnniwinther): Cache the result in [FieldData].
@@ -994,17 +983,12 @@ class KernelToElementMapForBuildingImpl extends KernelToElementMapBase
requireConstant: field.isConst, implicitNull: !field.isConst);
}
- ir.Library getKernelLibrary(KLibrary entity) =>
- _libraryEnvs[entity.libraryIndex].library;
-
- ir.Class getKernelClass(KClass entity) => _classEnvs[entity.classIndex].cls;
-
- bool hasConstantFieldInitializer(covariant KField field) {
+ bool hasConstantFieldInitializer(covariant IndexedField field) {
FieldData data = _memberData[field.memberIndex];
return getFieldConstantValue(data.node) != null;
}
- ConstantValue getConstantFieldInitializer(covariant KField field) {
+ ConstantValue getConstantFieldInitializer(covariant IndexedField field) {
FieldData data = _memberData[field.memberIndex];
ConstantValue value = getFieldConstantValue(data.node);
assert(value != null,
@@ -1012,11 +996,33 @@ class KernelToElementMapForBuildingImpl extends KernelToElementMapBase
return value;
}
- void forEachParameter(covariant KFunction function,
+ void forEachParameter(covariant IndexedFunction function,
void f(DartType type, String name, ConstantValue defaultValue)) {
FunctionData data = _memberData[function.memberIndex];
data.forEachParameter(this, f);
}
+}
+
+/// Element builder used for creating elements and types corresponding to Kernel
+/// IR nodes.
+// TODO(johnniwinther): Use this in the JsStrategy
+class KernelToElementMapForBuildingImpl extends KernelToElementMapBase
+ with
+ KernelToElementMapForBuildingMixin,
+ KernelToElementMapForBuildingFromBaseMixin,
+ ElementCreatorMixin,
+ KElementCreatorMixin
+ implements KernelToWorldBuilder {
+ KernelToElementMapForBuildingImpl(
+ DiagnosticReporter reporter, Environment environment)
+ : super(reporter, environment);
+
+ ConstantEnvironment get constantEnvironment => _constantEnvironment;
+
+ ir.Library getKernelLibrary(KLibrary entity) =>
+ _libraryEnvs[entity.libraryIndex].library;
+
+ ir.Class getKernelClass(KClass entity) => _classEnvs[entity.classIndex].cls;
@override
Spannable getSpannable(MemberEntity member, ir.Node node) {
@@ -1467,7 +1473,9 @@ class KernelResolutionWorldBuilder extends KernelResolutionWorldBuilderBase {
bool checkClass(ClassEntity cls) => true;
}
-abstract class KernelClosedWorldMixin implements ClosedWorld {
+abstract class KernelClosedWorldMixin implements ClosedWorldBase {
+ KernelToElementMapBase get elementMap;
+
@override
bool hasElementIn(ClassEntity cls, Selector selector, Entity element) {
while (cls != null) {
@@ -1482,78 +1490,42 @@ abstract class KernelClosedWorldMixin implements ClosedWorld {
}
return false;
}
-}
-
-class KernelClosedWorld extends ClosedWorldBase with KernelClosedWorldMixin {
- final KernelToElementMapForImpactImpl _elementMap;
-
- KernelClosedWorld(this._elementMap,
- {ElementEnvironment elementEnvironment,
- DartTypes dartTypes,
- CommonElements commonElements,
- ConstantSystem constantSystem,
- NativeData nativeData,
- InterceptorData interceptorData,
- BackendUsage backendUsage,
- ResolutionWorldBuilder resolutionWorldBuilder,
- Set<ClassEntity> implementedClasses,
- Iterable<MemberEntity> liveInstanceMembers,
- Set<TypedefElement> allTypedefs,
- Map<ClassEntity, Set<ClassEntity>> mixinUses,
- Map<ClassEntity, Set<ClassEntity>> typesImplementedBySubclasses,
- Map<ClassEntity, ClassHierarchyNode> classHierarchyNodes,
- Map<ClassEntity, ClassSet> classSets})
- : super(
- elementEnvironment,
- dartTypes,
- commonElements,
- constantSystem,
- nativeData,
- interceptorData,
- backendUsage,
- resolutionWorldBuilder,
- implementedClasses,
- liveInstanceMembers,
- allTypedefs,
- mixinUses,
- typesImplementedBySubclasses,
- classHierarchyNodes,
- classSets);
@override
bool hasConcreteMatch(ClassEntity cls, Selector selector,
{ClassEntity stopAtSuperclass}) {
- throw new UnimplementedError('KernelClosedWorld.hasConcreteMatch');
+ throw new UnimplementedError('KernelClosedWorldMixin.hasConcreteMatch');
}
@override
bool isNamedMixinApplication(ClassEntity cls) {
- throw new UnimplementedError('KernelClosedWorld.isNamedMixinApplication');
+ throw new UnimplementedError(
+ 'KernelClosedWorldMixin.isNamedMixinApplication');
}
@override
ClassEntity getAppliedMixin(ClassEntity cls) {
- throw new UnimplementedError('KernelClosedWorld.getAppliedMixin');
+ throw new UnimplementedError('KernelClosedWorldMixin.getAppliedMixin');
}
@override
Iterable<ClassEntity> getInterfaces(ClassEntity cls) {
- throw new UnimplementedError('KernelClosedWorld.getInterfaces');
+ throw new UnimplementedError('KernelClosedWorldMixin.getInterfaces');
}
@override
ClassEntity getSuperClass(ClassEntity cls) {
- throw new UnimplementedError('KernelClosedWorld.getSuperClass');
+ throw new UnimplementedError('KernelClosedWorldMixin.getSuperClass');
}
@override
int getHierarchyDepth(ClassEntity cls) {
- return _elementMap._getHierarchyDepth(cls);
+ return elementMap._getHierarchyDepth(cls);
}
@override
OrderedTypeSet getOrderedTypeSet(ClassEntity cls) {
- return _elementMap._getOrderedTypeSet(cls);
+ return elementMap._getOrderedTypeSet(cls);
}
@override
@@ -1565,6 +1537,43 @@ class KernelClosedWorld extends ClosedWorldBase with KernelClosedWorldMixin {
@override
bool checkEntity(Entity element) => true;
+}
+
+class KernelClosedWorld extends ClosedWorldBase with KernelClosedWorldMixin {
+ final KernelToElementMapForImpactImpl elementMap;
+
+ KernelClosedWorld(this.elementMap,
+ {ElementEnvironment elementEnvironment,
+ DartTypes dartTypes,
+ CommonElements commonElements,
+ ConstantSystem constantSystem,
+ NativeData nativeData,
+ InterceptorData interceptorData,
+ BackendUsage backendUsage,
+ ResolutionWorldBuilder resolutionWorldBuilder,
+ Set<ClassEntity> implementedClasses,
+ Iterable<MemberEntity> liveInstanceMembers,
+ Set<TypedefElement> allTypedefs,
+ Map<ClassEntity, Set<ClassEntity>> mixinUses,
+ Map<ClassEntity, Set<ClassEntity>> typesImplementedBySubclasses,
+ Map<ClassEntity, ClassHierarchyNode> classHierarchyNodes,
+ Map<ClassEntity, ClassSet> classSets})
+ : super(
+ elementEnvironment,
+ dartTypes,
+ commonElements,
+ constantSystem,
+ nativeData,
+ interceptorData,
+ backendUsage,
+ resolutionWorldBuilder,
+ implementedClasses,
+ liveInstanceMembers,
+ allTypedefs,
+ mixinUses,
+ typesImplementedBySubclasses,
+ classHierarchyNodes,
+ classSets);
@override
void registerClosureClass(ClassElement cls) {
@@ -1686,6 +1695,7 @@ class JsToFrontendMapImpl extends JsToFrontendMapBase
class JsKernelToElementMap extends KernelToElementMapBase
with
KernelToElementMapForBuildingMixin,
+ KernelToElementMapForBuildingFromBaseMixin,
JsElementCreatorMixin,
// TODO(johnniwinther): Avoid mixin in [ElementCreatorMixin]. The
// codegen world should be a strict subset of the resolution world and
@@ -1782,11 +1792,6 @@ class JsKernelToElementMap extends KernelToElementMapBase
return cls;
}
- /*@override
- TypeVariableEntity _getTypeVariable(ir.TypeParameter node) {
- throw new UnsupportedError("JsKernelToElementMap._getTypeVariable");
- }*/
-
// TODO(johnniwinther): Reinsert these when [ElementCreatorMixin] is no longer
// mixed in.
/*@override
@@ -1819,27 +1824,4 @@ class JsKernelToElementMap extends KernelToElementMapBase
ir.Class getClassNode(ClassEntity cls) {
return _getClassNode(cls);
}
-
- @override
- ConstantValue getFieldConstantValue(ir.Field field) {
- throw new UnsupportedError("JsKernelToElementMap.getFieldConstantValue");
- }
-
- @override
- void forEachParameter(FunctionEntity function,
- void f(DartType type, String name, ConstantValue defaultValue)) {
- throw new UnsupportedError("JsKernelToElementMap.forEachParameter");
- }
-
- @override
- ConstantValue getConstantFieldInitializer(FieldEntity field) {
- throw new UnsupportedError(
- "JsKernelToElementMap.getConstantFieldInitializer");
- }
-
- @override
- bool hasConstantFieldInitializer(FieldEntity field) {
- throw new UnsupportedError(
- "JsKernelToElementMap.hasConstantFieldInitializer");
- }
}
« no previous file with comments | « pkg/compiler/lib/src/js_model/js_strategy.dart ('k') | pkg/compiler/lib/src/world.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698