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

Unified Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 1869383002: Replace LateConstInvokeStructure after analysis. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | pkg/compiler/lib/src/resolution/send_structure.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/members.dart
diff --git a/pkg/compiler/lib/src/resolution/members.dart b/pkg/compiler/lib/src/resolution/members.dart
index b72dba8ae19031d22902ccae954fd38fb13aa8d4..4def9629e34b6a51621f06fba95f146e74bbdb93 100644
--- a/pkg/compiler/lib/src/resolution/members.dart
+++ b/pkg/compiler/lib/src/resolution/members.dart
@@ -4013,6 +4013,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
registry.registerTypeUse(new TypeUse.instantiation(type));
}
+ ResolutionResult resolutionResult = const NoneResult();
if (node.isConst) {
bool isValidAsConstant = !isInvalid && constructor.isConst;
@@ -4053,6 +4054,11 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
isValidAsConstant = false;
}
+ // Callback hook for when the compile-time constant evaluator has
+ // analyzed the constant.
+ // TODO(johnniwinther): Remove this when all constants are computed
+ // in resolution.
+ Function onAnalyzed;
if (isValidAsConstant &&
argumentsResult.isValidAsConstant &&
// TODO(johnniwinther): Remove this when all constants are computed
@@ -4069,7 +4075,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
arguments);
registry.registerNewStructure(node,
new ConstInvokeStructure(ConstantInvokeKind.CONSTRUCTED, constant));
- return new ConstantResult(node, constant);
+ resolutionResult = new ConstantResult(node, constant);
} else if (isInvalid) {
// Known to be non-constant.
kind == ConstructorAccessKind.NON_CONSTANT_CONSTRUCTOR;
@@ -4080,10 +4086,15 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
} else {
// Might be valid but we don't know for sure. The compile-time constant
// evaluator will compute the actual constant as a deferred action.
- registry.registerNewStructure(node,
- new LateConstInvokeStructure(registry.mapping));
+ LateConstInvokeStructure structure =
+ new LateConstInvokeStructure(registry.mapping);
+ registry.registerNewStructure(node, structure);
Siggi Cherem (dart-lang) 2016/04/08 16:10:45 do we need to register it if we are replacing it l
Johnni Winther 2016/04/11 07:40:45 I'm not sure. Adding a TODO for trying in a follow
+ onAnalyzed = () {
+ registry.registerNewStructure(node, structure.resolve(node));
+ };
}
+ analyzeConstantDeferred(node, onAnalyzed: onAnalyzed);
} else {
// Not constant.
if (constructor == compiler.symbolConstructor &&
@@ -4098,7 +4109,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
selector));
}
- return const NoneResult();
+ return resolutionResult;
}
void checkConstMapKeysDontOverrideEquals(Spannable spannable,
@@ -4135,9 +4146,14 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
}
}
- void analyzeConstantDeferred(Node node, {bool enforceConst: true}) {
+ void analyzeConstantDeferred(Node node,
+ {bool enforceConst: true,
+ void onAnalyzed()}) {
Siggi Cherem (dart-lang) 2016/04/08 16:10:45 ... eventually we should consider using futures in
Johnni Winther 2016/04/11 07:40:45 Acknowledged.
addDeferredAction(enclosingElement, () {
analyzeConstant(node, enforceConst: enforceConst);
+ if (onAnalyzed != null) {
+ onAnalyzed();
+ }
});
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/resolution/send_structure.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698