Chromium Code Reviews| 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(); |
| + } |
| }); |
| } |