Chromium Code Reviews| Index: lib/compiler/implementation/compile_time_constants.dart |
| diff --git a/lib/compiler/implementation/compile_time_constants.dart b/lib/compiler/implementation/compile_time_constants.dart |
| index 39e313d8a22661fecda85bb757476bec98ba7365..229ca46e39b68aefbbe2a1f25b0c17a34d512242 100644 |
| --- a/lib/compiler/implementation/compile_time_constants.dart |
| +++ b/lib/compiler/implementation/compile_time_constants.dart |
| @@ -529,10 +529,15 @@ class CompileTimeConstantEvaluator extends AbstractVisitor { |
| return signalNotCompileTimeConstant(node); |
| } |
| - /** Returns the list of constants that are passed to the static function. */ |
| + /** |
| + * Returns the list of constants that are passed to the static function. |
| + * |
| + * Invariant: [target] must be the implementation element. |
|
ahe
2012/09/18 11:25:54
the -> an.
Johnni Winther
2012/09/20 08:12:23
Done.
|
| + */ |
| List<Constant> evaluateArgumentsToConstructor(Selector selector, |
| Link<Node> arguments, |
| FunctionElement target) { |
| + assert(target.isImplementation); |
| List<Constant> compiledArguments = <Constant>[]; |
| Function compileArgument = evaluateConstant; |
| @@ -560,6 +565,10 @@ class CompileTimeConstantEvaluator extends AbstractVisitor { |
| constructor = constructor.defaultImplementation; |
| classElement = constructor.getEnclosingClass(); |
| } |
| + // The constructor must be the implementation to ensure that field |
|
ahe
2012/09/18 11:25:54
the -> an.
Johnni Winther
2012/09/20 08:12:23
Done.
|
| + // initializers are handled correctly. |
| + constructor = constructor.implementation; |
|
ahe
2012/09/18 11:25:54
Is this temporary?
Johnni Winther
2012/09/20 08:12:23
No. That is why I put in the comment.
|
| + assert(constructor.isImplementation); |
| Selector selector = elements.getSelector(send); |
| List<Constant> arguments = |
| @@ -615,10 +624,13 @@ class TryCompileTimeConstantEvaluator extends CompileTimeConstantEvaluator { |
| } |
| class ConstructorEvaluator extends CompileTimeConstantEvaluator { |
| - FunctionElement constructor; |
| + final FunctionElement constructor; |
| final Map<Element, Constant> definitions; |
| final Map<Element, Constant> fieldValues; |
| + /** |
| + * Invariant: [constructor] must be the implementation element. |
|
ahe
2012/09/18 11:25:54
This is not documentation.
Johnni Winther
2012/09/20 08:12:23
Done.
|
| + */ |
| ConstructorEvaluator(FunctionElement constructor, |
| ConstantSystem constantSystem, |
| Compiler compiler) |
| @@ -626,9 +638,11 @@ class ConstructorEvaluator extends CompileTimeConstantEvaluator { |
| this.definitions = new Map<Element, Constant>(), |
| this.fieldValues = new Map<Element, Constant>(), |
| super(constantSystem, |
| - compiler.resolver.resolveMethodElement(constructor), |
| + compiler.resolver.resolveMethodElement(constructor.declaration), |
| compiler, |
| - isConst: true); |
| + isConst: true) { |
| + assert(constructor.isImplementation); |
| + } |
| Constant visitSend(Send send) { |
| Element element = elements[send]; |