Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A function element that represents a closure call. The signature is copied | 8 * A function element that represents a closure call. The signature is copied |
| 9 * from the given element. | 9 * from the given element. |
| 10 */ | 10 */ |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 | 322 |
| 323 String get lazyInitializerFunction { | 323 String get lazyInitializerFunction { |
| 324 String isolate = namer.CURRENT_ISOLATE; | 324 String isolate = namer.CURRENT_ISOLATE; |
| 325 JavaScriptBackend backend = compiler.backend; | 325 JavaScriptBackend backend = compiler.backend; |
| 326 String cyclicThrow = namer.isolateAccess(backend.cyclicThrowHelper); | 326 String cyclicThrow = namer.isolateAccess(backend.cyclicThrowHelper); |
| 327 return """ | 327 return """ |
| 328 function(prototype, staticName, fieldName, getterName, lazyValue) { | 328 function(prototype, staticName, fieldName, getterName, lazyValue) { |
| 329 var sentinelUndefined = {}; | 329 var sentinelUndefined = {}; |
| 330 var sentinelInProgress = {}; | 330 var sentinelInProgress = {}; |
| 331 prototype[fieldName] = sentinelUndefined; | 331 prototype[fieldName] = sentinelUndefined; |
| 332 var getter = new Function("{ return $isolate." + fieldName + ";}"); | 332 var getter = function() { return ${isolate}[fieldName]; }; |
|
floitsch
2012/11/21 16:58:13
Unfortunately no.
I'm pretty sure this would make
| |
| 333 prototype[getterName] = function() { | 333 prototype[getterName] = function() { |
| 334 var result = $isolate[fieldName]; | 334 var result = $isolate[fieldName]; |
| 335 try { | 335 try { |
| 336 if (result === sentinelUndefined) { | 336 if (result === sentinelUndefined) { |
| 337 $isolate[fieldName] = sentinelInProgress; | 337 $isolate[fieldName] = sentinelInProgress; |
| 338 try { | 338 try { |
| 339 result = $isolate[fieldName] = lazyValue(); | 339 result = $isolate[fieldName] = lazyValue(); |
| 340 } catch (e) { | 340 } catch (e) { |
| 341 if ($isolate[fieldName] === sentinelInProgress) { | 341 if ($isolate[fieldName] === sentinelInProgress) { |
| 342 $isolate[fieldName] = null; | 342 $isolate[fieldName] = null; |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1734 const String HOOKS_API_USAGE = """ | 1734 const String HOOKS_API_USAGE = """ |
| 1735 // Generated by dart2js, the Dart to JavaScript compiler. | 1735 // Generated by dart2js, the Dart to JavaScript compiler. |
| 1736 // The code supports the following hooks: | 1736 // The code supports the following hooks: |
| 1737 // dartPrint(message) - if this function is defined it is called | 1737 // dartPrint(message) - if this function is defined it is called |
| 1738 // instead of the Dart [print] method. | 1738 // instead of the Dart [print] method. |
| 1739 // dartMainRunner(main) - if this function is defined, the Dart [main] | 1739 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 1740 // method will not be invoked directly. | 1740 // method will not be invoked directly. |
| 1741 // Instead, a closure that will invoke [main] is | 1741 // Instead, a closure that will invoke [main] is |
| 1742 // passed to [dartMainRunner]. | 1742 // passed to [dartMainRunner]. |
| 1743 """; | 1743 """; |
| OLD | NEW |