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

Unified Diff: pkg/compiler/lib/src/elements/modelx.dart

Issue 1391193002: Make computeSignature private to modelx. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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/closure.dart ('k') | pkg/compiler/lib/src/resolution/enum_creator.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/elements/modelx.dart
diff --git a/pkg/compiler/lib/src/elements/modelx.dart b/pkg/compiler/lib/src/elements/modelx.dart
index 7ef3d1e36d73166b88b0712e892943fcf592bdc5..c9c15167d88e58bfca95ea9a65d5a2873db8c7e8 100644
--- a/pkg/compiler/lib/src/elements/modelx.dart
+++ b/pkg/compiler/lib/src/elements/modelx.dart
@@ -315,7 +315,6 @@ class ErroneousElementX extends ElementX implements ErroneousElement {
bool get isRedirectingGenerative => unsupported();
bool get isRedirectingFactory => unsupported();
- computeSignature(Resolution resolution) => unsupported();
computeType(Resolution resolution) => unsupported();
bool get hasFunctionSignature => false;
@@ -396,6 +395,10 @@ class ErroneousConstructorElementX extends ErroneousElementX
throw new UnsupportedError("effectiveTargetType=");
}
+ void _computeSignature(Resolution resolution) {
+ throw new UnsupportedError("_computeSignature");
+ }
+
get typeCache {
throw new UnsupportedError("typeCache");
}
@@ -420,6 +423,10 @@ class ErroneousConstructorElementX extends ErroneousElementX
throw new UnsupportedError("functionSignatureCache=");
}
+ set functionSignature(_) {
+ throw new UnsupportedError("functionSignatureCache=");
+ }
+
get nestedClosures {
throw new UnsupportedError("nestedClosures");
}
@@ -1975,18 +1982,26 @@ abstract class BaseFunctionElementX
bool get hasFunctionSignature => functionSignatureCache != null;
- FunctionSignature computeSignature(Resolution resolution) {
- if (functionSignatureCache != null) return functionSignatureCache;
- functionSignatureCache = resolution.resolveSignature(this);
- return functionSignatureCache;
+ void _computeSignature(Resolution resolution) {
+ if (hasFunctionSignature) return;
+ functionSignature = resolution.resolveSignature(this);
}
FunctionSignature get functionSignature {
- assert(invariant(this, functionSignatureCache != null,
+ assert(invariant(this, hasFunctionSignature,
message: "Function signature has not been computed for $this."));
return functionSignatureCache;
}
+ void set functionSignature(FunctionSignature value) {
sigurdm 2015/10/07 11:53:07 The setter could be pushed down the element class-
Johnni Winther 2015/10/07 12:15:03 This is currently the lowest common point.
+ // TODO(johnniwinther): Strengthen the invariant to `!hasFunctionSignature`
+ // when checked mode checks are not enqueued eagerly.
+ assert(invariant(this, !hasFunctionSignature || type == value.type,
+ message: "Function signature has already been computed for $this."));
+ functionSignatureCache = value;
sigurdm 2015/10/07 11:53:07 functionSignaturePrivate could be private
Johnni Winther 2015/10/07 12:15:03 Done.
+ typeCache = functionSignatureCache.type;
+ }
+
List<ParameterElement> get parameters {
// TODO(johnniwinther): Store the list directly, possibly by using List
// instead of Link in FunctionSignature.
@@ -1997,7 +2012,9 @@ abstract class BaseFunctionElementX
FunctionType computeType(Resolution resolution) {
if (typeCache != null) return typeCache;
- typeCache = computeSignature(resolution).type;
+ _computeSignature(resolution);
+ assert(invariant(this, typeCache != null,
+ message: "Type cache expected to be set on $this."));
return typeCache;
}
@@ -2233,13 +2250,8 @@ class DeferredLoaderGetterElementX extends GetterElementX
super("loadLibrary",
Modifiers.EMPTY,
prefix,
- false);
-
- FunctionSignature computeSignature(Resolution resolution) {
- if (functionSignatureCache != null) return functionSignature;
- functionSignatureCache =
- new FunctionSignatureX(type: new FunctionType(this));
- return functionSignatureCache;
+ false) {
+ functionSignature = new FunctionSignatureX(type: new FunctionType(this));
}
bool get isClassMember => false;
@@ -2273,7 +2285,7 @@ class ConstructorBodyElementX extends BaseFunctionElementX
ElementKind.GENERATIVE_CONSTRUCTOR_BODY,
Modifiers.EMPTY,
constructor.enclosingElement) {
- functionSignatureCache = constructor.functionSignature;
+ functionSignature = constructor.functionSignature;
}
bool get hasNode => constructor.hasNode;
@@ -2330,8 +2342,8 @@ class SynthesizedConstructorElementX extends ConstructorElementX {
ElementKind.GENERATIVE_CONSTRUCTOR,
Modifiers.EMPTY,
enclosing) {
- typeCache = new FunctionType.synthesized(enclosingClass.thisType);
- functionSignatureCache = new FunctionSignatureX(type: type);
+ functionSignature = new FunctionSignatureX(
+ type: new FunctionType.synthesized(enclosingClass.thisType));
}
FunctionExpression parseNode(Parsing parsing) => null;
@@ -2354,18 +2366,16 @@ class SynthesizedConstructorElementX extends ConstructorElementX {
}
}
- FunctionSignature computeSignature(Resolution resolution) {
- if (functionSignatureCache != null) return functionSignatureCache;
+ void _computeSignature(Resolution resolution) {
+ if (hasFunctionSignature) return;
if (definingConstructor.isErroneous) {
- typeCache = new FunctionType.synthesized(enclosingClass.thisType);
- return functionSignatureCache = new FunctionSignatureX(type: type);
+ functionSignature = new FunctionSignatureX(
+ type: new FunctionType.synthesized(enclosingClass.thisType));
}
// TODO(johnniwinther): Ensure that the function signature (and with it the
// function type) substitutes type variables correctly.
definingConstructor.computeType(resolution);
- functionSignatureCache = definingConstructor.functionSignature;
- typeCache = definingConstructor.type;
- return functionSignatureCache;
+ functionSignature = definingConstructor.functionSignature;
}
accept(ElementVisitor visitor, arg) {
« no previous file with comments | « pkg/compiler/lib/src/closure.dart ('k') | pkg/compiler/lib/src/resolution/enum_creator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698