| Index: lib/compiler/implementation/compiler.dart
|
| diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart
|
| index 1b68df8719f13412a70e87a49c951672b67cbc8f..d753a5997891831555bf945f44ce294b3ca60d13 100644
|
| --- a/lib/compiler/implementation/compiler.dart
|
| +++ b/lib/compiler/implementation/compiler.dart
|
| @@ -719,10 +719,18 @@ 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;
|
| + } else {
|
| + // 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.
|
| + // We also need to register the use of the cyclic-error helper.
|
| + world.registerStaticUse(cyclicThrowHelper);
|
| + }
|
| }
|
| + backend.codegen(work);
|
| }
|
|
|
| void registerInstantiatedClass(ClassElement cls) {
|
| @@ -756,6 +764,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);
|
| @@ -848,6 +868,10 @@ class Compiler implements DiagnosticListener {
|
| unimplemented('Compiler.legDirectory');
|
| }
|
|
|
| + Element get cyclicThrowHelper() {
|
| + return findHelper(const SourceString("throwCyclicInit"));
|
| + }
|
| +
|
| Element findHelper(SourceString name)
|
| => jsHelperLibrary.findLocal(name);
|
| Element findInterceptor(SourceString name)
|
|
|