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 f938dc25a9ce1740899388bb0dbfe183498ddbc6..d53af0c39545bb72400800fb56b41c42b758088e 100644 |
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart |
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart |
@@ -965,15 +965,26 @@ abstract class KElementCreatorMixin implements ElementCreatorMixin { |
/// Implementation of [KernelToElementMapForImpact] that only supports world |
/// impact computation. |
-// TODO(johnniwinther): Merge this with [KernelToElementMapForImpactImpl] when |
-// [JsStrategy] is the default. |
-abstract class KernelToElementMapForImpactImpl |
- implements |
- KernelToElementMapBase, |
- KernelToElementMapForImpact, |
- KernelToElementMapForImpactMixin { |
+class KernelToElementMapForImpactImpl extends KernelToElementMapBase |
+ with |
+ KernelToElementMapForImpactMixin, |
+ ElementCreatorMixin, |
+ KElementCreatorMixin { |
native.BehaviorBuilder _nativeBehaviorBuilder; |
+ KernelToElementMapForImpactImpl( |
+ DiagnosticReporter reporter, Environment environment) |
+ : super(reporter, environment); |
+ |
+ @override |
+ bool checkFamily(Entity entity) { |
+ assert( |
+ '$entity'.startsWith(kElementPrefix), |
+ failedAt(entity, |
+ "Unexpected entity $entity, expected family $kElementPrefix.")); |
+ return true; |
+ } |
+ |
/// Adds libraries in [program] to the set of libraries. |
/// |
/// The main method of the first program is used as the main method for the |
@@ -1000,121 +1011,6 @@ abstract class KernelToElementMapForImpactImpl |
} |
} |
-/// Implementation of [KernelToElementMapForImpact] that only supports world |
-/// impact computation. |
-// TODO(johnniwinther): Merge this with [KernelToElementMapForImpactImpl] when |
-// [JsStrategy] is the default. |
-class KernelToElementMapForImpactImpl2 extends KernelToElementMapBase |
- with |
- KernelToElementMapForImpactMixin, |
- KernelToElementMapForImpactImpl, |
- ElementCreatorMixin, |
- KElementCreatorMixin { |
- KernelToElementMapForImpactImpl2( |
- DiagnosticReporter reporter, Environment environment) |
- : super(reporter, environment); |
- |
- @override |
- bool checkFamily(Entity entity) { |
- assert( |
- '$entity'.startsWith(kElementPrefix), |
- failedAt(entity, |
- "Unexpected entity $entity, expected family $kElementPrefix.")); |
- return true; |
- } |
-} |
- |
-/// 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]. |
- return getConstantValue(field.initializer, |
- requireConstant: field.isConst, implicitNull: !field.isConst); |
- } |
- |
- bool hasConstantFieldInitializer(covariant IndexedField field) { |
- FieldData data = _memberData[field.memberIndex]; |
- return getFieldConstantValue(data.node) != null; |
- } |
- |
- ConstantValue getConstantFieldInitializer(covariant IndexedField field) { |
- FieldData data = _memberData[field.memberIndex]; |
- ConstantValue value = getFieldConstantValue(data.node); |
- assert(value != null, |
- failedAt(field, "Field $field doesn't have a constant initial value.")); |
- return value; |
- } |
- |
- 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); |
- |
- @override |
- bool checkFamily(Entity entity) { |
- assert( |
- '$entity'.startsWith(kElementPrefix), |
- failedAt(entity, |
- "Unexpected entity $entity, expected family $kElementPrefix.")); |
- return true; |
- } |
- |
- 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) { |
- return _getSpannable(member, node); |
- } |
- |
- @override |
- ir.Member getMemberNode(MemberEntity member) { |
- return _getMemberNode(member); |
- } |
- |
- @override |
- ir.Class getClassNode(ClassEntity cls) { |
- return _getClassNode(cls); |
- } |
-} |
- |
-/// [KernelToElementMap] implementation used for both world impact computation |
-/// and SSA building. |
-// TODO(johnniwinther): Remove this when [JsStrategy] is the default. |
-class KernelToElementMapImpl extends KernelToElementMapForBuildingImpl |
- with |
- KernelToElementMapForImpactMixin, |
- KernelToElementMapForImpactImpl, |
- ElementCreatorMixin, |
- KElementCreatorMixin |
- implements KernelToElementMapForImpactImpl2 { |
- KernelToElementMapImpl(DiagnosticReporter reporter, Environment environment) |
- : super(reporter, environment); |
-} |
- |
class KernelElementEnvironment implements ElementEnvironment { |
final KernelToElementMapBase elementMap; |
@@ -1781,7 +1677,6 @@ 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 |
@@ -1931,4 +1826,30 @@ class JsKernelToElementMap extends KernelToElementMapBase |
ir.Class getClassNode(ClassEntity cls) { |
return _getClassNode(cls); |
} |
+ |
+ @override |
+ ConstantValue getFieldConstantValue(ir.Field field) { |
+ // TODO(johnniwinther): Cache the result in [FieldData]. |
+ return getConstantValue(field.initializer, |
+ requireConstant: field.isConst, implicitNull: !field.isConst); |
+ } |
+ |
+ bool hasConstantFieldInitializer(covariant IndexedField field) { |
+ FieldData data = _memberData[field.memberIndex]; |
+ return getFieldConstantValue(data.node) != null; |
+ } |
+ |
+ ConstantValue getConstantFieldInitializer(covariant IndexedField field) { |
+ FieldData data = _memberData[field.memberIndex]; |
+ ConstantValue value = getFieldConstantValue(data.node); |
+ assert(value != null, |
+ failedAt(field, "Field $field doesn't have a constant initial value.")); |
+ return value; |
+ } |
+ |
+ void forEachParameter(covariant IndexedFunction function, |
+ void f(DartType type, String name, ConstantValue defaultValue)) { |
+ FunctionData data = _memberData[function.memberIndex]; |
+ data.forEachParameter(this, f); |
+ } |
} |