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

Unified Diff: pkg/compiler/lib/src/universe/world_impact.dart

Issue 1421463005: Move codegen registration to transformImpact method. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 2 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/resolution/registry.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/universe/world_impact.dart
diff --git a/pkg/compiler/lib/src/universe/world_impact.dart b/pkg/compiler/lib/src/universe/world_impact.dart
index bb6ac355a32783b9694fb33874dac21cacbdef25..745df3e6ad06df80c23e5c6b998fa9ea4b1afb27 100644
--- a/pkg/compiler/lib/src/universe/world_impact.dart
+++ b/pkg/compiler/lib/src/universe/world_impact.dart
@@ -246,3 +246,120 @@ class WorldImpactBuilder {
? _closures : const <LocalFunctionElement>[];
}
}
+
+/// Mutable implementation of [WorldImpact] used to transform
+/// [ResolutionImpact] or [CodegenImpact] to [WorldImpact].
+class TransformedWorldImpact implements WorldImpact {
+ final WorldImpact worldImpact;
+
+ Setlet<Element> _staticUses;
+ Setlet<InterfaceType> _instantiatedTypes;
+ Setlet<UniverseSelector> _dynamicGetters;
+ Setlet<UniverseSelector> _dynamicInvocations;
+ Setlet<UniverseSelector> _dynamicSetters;
+
+ TransformedWorldImpact(this.worldImpact);
+
+ @override
+ Iterable<DartType> get asCasts => worldImpact.asCasts;
+
+ @override
+ Iterable<DartType> get checkedModeChecks => worldImpact.checkedModeChecks;
+
+ @override
+ Iterable<MethodElement> get closurizedFunctions {
+ return worldImpact.closurizedFunctions;
+ }
+
+ @override
+ Iterable<UniverseSelector> get dynamicGetters {
+ return _dynamicGetters != null
+ ? _dynamicGetters : worldImpact.dynamicGetters;
+ }
+
+ @override
+ Iterable<UniverseSelector> get dynamicInvocations {
+ return _dynamicInvocations != null
+ ? _dynamicInvocations : worldImpact.dynamicInvocations;
+ }
+
+ @override
+ Iterable<UniverseSelector> get dynamicSetters {
+ return _dynamicSetters != null
+ ? _dynamicSetters : worldImpact.dynamicSetters;
+ }
+
+ @override
+ Iterable<DartType> get isChecks => worldImpact.isChecks;
+
+ @override
+ Iterable<DartType> get onCatchTypes => worldImpact.onCatchTypes;
+
+ _unsupported(String message) => throw new UnsupportedError(message);
+
+ void registerDynamicGetter(UniverseSelector selector) {
+ if (_dynamicGetters == null) {
+ _dynamicGetters = new Setlet<UniverseSelector>();
+ _dynamicGetters.addAll(worldImpact.dynamicGetters);
+ }
+ _dynamicGetters.add(selector);
+ }
+
+ void registerDynamicInvocation(UniverseSelector selector) {
+ if (_dynamicInvocations == null) {
+ _dynamicInvocations = new Setlet<UniverseSelector>();
+ _dynamicInvocations.addAll(worldImpact.dynamicInvocations);
+ }
+ _dynamicInvocations.add(selector);
+ }
+
+ void registerDynamicSetter(UniverseSelector selector) {
+ if (_dynamicSetters == null) {
+ _dynamicSetters = new Setlet<UniverseSelector>();
+ _dynamicSetters.addAll(worldImpact.dynamicSetters);
+ }
+ _dynamicSetters.add(selector);
+ }
+
+ void registerInstantiatedType(InterfaceType type) {
+ if (_instantiatedTypes == null) {
+ _instantiatedTypes = new Setlet<InterfaceType>();
+ _instantiatedTypes.addAll(worldImpact.instantiatedTypes);
+ }
+ _instantiatedTypes.add(type);
+ }
+
+ @override
+ Iterable<InterfaceType> get instantiatedTypes {
+ return _instantiatedTypes != null
+ ? _instantiatedTypes : worldImpact.instantiatedTypes;
+ }
+
+ @override
+ Iterable<DartType> get typeLiterals {
+ return worldImpact.typeLiterals;
+ }
+
+ void registerStaticUse(Element element) {
+ if (_staticUses == null) {
+ _staticUses = new Setlet<Element>();
+ _staticUses.addAll(worldImpact.staticUses);
+ }
+ _staticUses.add(element);
+ }
+
+ @override
+ Iterable<Element> get staticUses {
+ return _staticUses != null ? _staticUses : worldImpact.staticUses;
+ }
+
+ @override
+ Iterable<LocalFunctionElement> get closures => worldImpact.closures;
+
+ String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.write('TransformedWorldImpact($worldImpact)');
+ WorldImpact.printOn(sb, this);
+ return sb.toString();
+ }
+}
« no previous file with comments | « pkg/compiler/lib/src/resolution/registry.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698