Chromium Code Reviews| Index: lib/compiler/implementation/compiler.dart |
| diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart |
| index 2725e1ee675e5d6e25329c38a68942a594538b74..c5998d9a6fd165d8e9d7cf6e00cd4dc064a67122 100644 |
| --- a/lib/compiler/implementation/compiler.dart |
| +++ b/lib/compiler/implementation/compiler.dart |
| @@ -765,10 +765,13 @@ class Compiler implements DiagnosticListener { |
| progress.reset(); |
| } |
| if (work.element.kind.category == ElementCategory.VARIABLE) { |
| - constantHandler.compileWorkItem(work); |
| - } else { |
| - backend.codegen(work); |
| + Constant initialValue = constantHandler.compileWorkItem(work); |
| + if (initialValue != null) return; |
|
kasperl
2012/08/17 09:30:04
!==
floitsch
2012/09/04 17:32:21
Done.
|
| + // If the constant-handler was not able to produce a result we have to |
| + // go through the builder (below) to generate the lazy initializer for |
| + // the static variable. |
| } |
| + backend.codegen(work); |
| } |
| void registerInstantiatedClass(ClassElement cls) { |
| @@ -802,6 +805,18 @@ class Compiler implements DiagnosticListener { |
| () => resolver.computeFunctionType(element, signature)); |
| } |
| + bool isLazilyInitialized(VariableElement element) { |
| + Constant initialValue = compileVariable(element); |
| + return initialValue === null; |
| + } |
| + |
| + /** 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); |