| Index: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
|
| ===================================================================
|
| --- sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (revision 15244)
|
| +++ sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (working copy)
|
| @@ -322,14 +322,21 @@
|
|
|
| String get lazyInitializerFunction {
|
| String isolate = namer.CURRENT_ISOLATE;
|
| + return """
|
| +function(prototype, staticName, fieldName, getterName, lazyValue) {
|
| + var getter = new Function("{ return $isolate." + fieldName + ";}");
|
| +$lazyInitializerLogic
|
| +}""";
|
| + }
|
| +
|
| + String get lazyInitializerLogic {
|
| + String isolate = namer.CURRENT_ISOLATE;
|
| JavaScriptBackend backend = compiler.backend;
|
| String cyclicThrow = namer.isolateAccess(backend.cyclicThrowHelper);
|
| return """
|
| -function(prototype, staticName, fieldName, getterName, lazyValue) {
|
| var sentinelUndefined = {};
|
| var sentinelInProgress = {};
|
| prototype[fieldName] = sentinelUndefined;
|
| - var getter = new Function("{ return $isolate." + fieldName + ";}");
|
| prototype[getterName] = function() {
|
| var result = $isolate[fieldName];
|
| try {
|
| @@ -350,8 +357,7 @@
|
| } finally {
|
| $isolate[getterName] = getter;
|
| }
|
| - };
|
| -}""";
|
| + };""";
|
| }
|
|
|
| void addDefineClassAndFinishClassFunctionsIfNecessary(CodeBuffer buffer) {
|
| @@ -1336,11 +1342,16 @@
|
| buffer.add(namer.getLazyInitializerName(element));
|
| buffer.add("', ");
|
| buffer.add(code);
|
| + emitLazyInitializedGetter(element, buffer);
|
| buffer.add(");\n");
|
| }
|
| }
|
| }
|
|
|
| + void emitLazyInitializedGetter(VariableElement element, CodeBuffer buffer) {
|
| + // Nothing to do, the 'lazy' function will create the getter.
|
| + }
|
| +
|
| void emitCompileTimeConstants(CodeBuffer buffer) {
|
| ConstantHandler handler = compiler.constantHandler;
|
| List<Constant> constants = handler.getConstantsForEmission();
|
|
|