Chromium Code Reviews| Index: lib/compiler/implementation/compiler.dart |
| diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart |
| index 69234fe7f8c32557ec96fb69ee1ee7501d6430ed..21d14664e60e6fffe47cbeb2818e17f975f95892 100644 |
| --- a/lib/compiler/implementation/compiler.dart |
| +++ b/lib/compiler/implementation/compiler.dart |
| @@ -749,13 +749,13 @@ class Compiler implements DiagnosticListener { |
| progress.reset(); |
| } |
| if (work.element.kind.category == ElementCategory.VARIABLE) { |
| - constantHandler.compileWorkItem(work); |
| - return null; |
| - } else { |
| - CodeBuffer codeBuffer = backend.codegen(work); |
| - codegenWorld.addGeneratedCode(work, codeBuffer); |
| - return codeBuffer.toString(); |
| + Constant initialValue = constantHandler.compileWorkItem(work); |
| + if (initialValue != null) return null; |
| + // Otherwise we need to go through the builder. |
|
kasperl
2012/08/16 14:41:37
Maybe change the comment to explain why we have to
floitsch
2012/08/16 22:52:33
Done.
|
| } |
| + CodeBuffer codeBuffer = backend.codegen(work); |
| + codegenWorld.addGeneratedCode(work, codeBuffer); |
| + return codeBuffer.toString(); |
| } |
| void registerInstantiatedClass(ClassElement cls) { |
| @@ -793,6 +793,18 @@ class Compiler implements DiagnosticListener { |
| () => resolver.computeFunctionType(element, signature)); |
| } |
| + bool isLazilyInitialized(VariableElement element) { |
| + Constant initialValue = compileVariable(element); |
| + return initialValue == null; |
|
kasperl
2012/08/16 14:41:37
===?
floitsch
2012/08/16 22:52:33
Done.
|
| + } |
| + |
| + /** Compiles compile-time constants. Must not return `null`. */ |
| + Constant compileConstant(VariableElement element) { |
| + return withCurrentElement(element, () { |
| + return constantHandler.compileConstant(element); |
| + }); |
| + } |
| + |
| Constant compileVariable(VariableElement element) { |
| return withCurrentElement(element, () { |
| return constantHandler.compileVariable(element); |