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

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: Use newer dartfmt 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 2bda4fe090638daab0fbd36703c35d58436d35e6..bcd4495af044f8147fb57a2b09f5c80cad3ffc83 100644
--- a/pkg/compiler/lib/src/resolution/members.dart
+++ b/pkg/compiler/lib/src/resolution/members.dart
@@ -3844,6 +3844,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
registry.registerTypeUse(new TypeUse.instantiation(type));
}
+ ResolutionResult resolutionResult = const NoneResult();
if (node.isConst) {
bool isValidAsConstant = !isInvalid && constructor.isConst;
@@ -3880,6 +3881,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
@@ -3893,7 +3899,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
type, constructor, callStructure, 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;
@@ -3905,9 +3911,17 @@ 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);
+ // TODO(johnniwinther): Avoid registering the
+ // [LateConstInvokeStructure]; it might not be necessary.
+ registry.registerNewStructure(node, structure);
+ onAnalyzed = () {
+ registry.registerNewStructure(node, structure.resolve(node));
+ };
}
+
+ analyzeConstantDeferred(node, onAnalyzed: onAnalyzed);
} else {
// Not constant.
if (constructor == compiler.symbolConstructor &&
@@ -3922,7 +3936,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
selector));
}
- return const NoneResult();
+ return resolutionResult;
}
void checkConstMapKeysDontOverrideEquals(
@@ -3956,9 +3970,13 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
}
}
- void analyzeConstantDeferred(Node node, {bool enforceConst: true}) {
+ void analyzeConstantDeferred(Node node,
+ {bool enforceConst: true, void onAnalyzed()}) {
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