| 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 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 'getterName', 'lazyValue']; | 877 'getterName', 'lazyValue']; |
| 878 return js.fun(parameters, [ | 878 return js.fun(parameters, [ |
| 879 js('var getter = new Function("{ return this." + fieldName + ";}")'), | 879 js('var getter = new Function("{ return this." + fieldName + ";}")'), |
| 880 ]..addAll(addLazyInitializerLogic()) | 880 ]..addAll(addLazyInitializerLogic()) |
| 881 ); | 881 ); |
| 882 } | 882 } |
| 883 | 883 |
| 884 List addLazyInitializerLogic() { | 884 List addLazyInitializerLogic() { |
| 885 String isolate = namer.CURRENT_ISOLATE; | 885 String isolate = namer.CURRENT_ISOLATE; |
| 886 String cyclicThrow = namer.isolateAccess(backend.getCyclicThrowHelper()); | 886 String cyclicThrow = namer.isolateAccess(backend.getCyclicThrowHelper()); |
| 887 var lazies = []; |
| 888 if (backend.rememberLazies) { |
| 889 lazies = [ |
| 890 js.if_('!init.lazies', js('init.lazies = {}')), |
| 891 js('init.lazies[fieldName] = getterName')]; |
| 892 } |
| 887 | 893 |
| 888 return [ | 894 return lazies..addAll([ |
| 889 js('var sentinelUndefined = {}'), | 895 js('var sentinelUndefined = {}'), |
| 890 js('var sentinelInProgress = {}'), | 896 js('var sentinelInProgress = {}'), |
| 891 js('prototype[fieldName] = sentinelUndefined'), | 897 js('prototype[fieldName] = sentinelUndefined'), |
| 892 | 898 |
| 893 // prototype[getterName] = function() | 899 // prototype[getterName] = function() |
| 894 js('prototype[getterName] = #', js.fun([], [ | 900 js('prototype[getterName] = #', js.fun([], [ |
| 895 js('var result = $isolate[fieldName]'), | 901 js('var result = $isolate[fieldName]'), |
| 896 | 902 |
| 897 // try | 903 // try |
| 898 js.try_([ | 904 js.try_([ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 921 ) | 927 ) |
| 922 ]), | 928 ]), |
| 923 | 929 |
| 924 // return result; | 930 // return result; |
| 925 js.return_('result') | 931 js.return_('result') |
| 926 | 932 |
| 927 ], finallyPart: [ | 933 ], finallyPart: [ |
| 928 js('$isolate[getterName] = getter') | 934 js('$isolate[getterName] = getter') |
| 929 ]) | 935 ]) |
| 930 ])) | 936 ])) |
| 931 ]; | 937 ]); |
| 932 } | 938 } |
| 933 | 939 |
| 934 List buildDefineClassAndFinishClassFunctionsIfNecessary() { | 940 List buildDefineClassAndFinishClassFunctionsIfNecessary() { |
| 935 if (!needsDefineClass) return []; | 941 if (!needsDefineClass) return []; |
| 936 return defineClassFunction | 942 return defineClassFunction |
| 937 ..addAll(buildProtoSupportCheck()) | 943 ..addAll(buildProtoSupportCheck()) |
| 938 ..addAll([ | 944 ..addAll([ |
| 939 js('$finishClassesName = #', finishClassesFunction) | 945 js('$finishClassesName = #', finishClassesFunction) |
| 940 ]); | 946 ]); |
| 941 } | 947 } |
| (...skipping 2945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3887 | 3893 |
| 3888 const String HOOKS_API_USAGE = """ | 3894 const String HOOKS_API_USAGE = """ |
| 3889 // The code supports the following hooks: | 3895 // The code supports the following hooks: |
| 3890 // dartPrint(message) - if this function is defined it is called | 3896 // dartPrint(message) - if this function is defined it is called |
| 3891 // instead of the Dart [print] method. | 3897 // instead of the Dart [print] method. |
| 3892 // dartMainRunner(main) - if this function is defined, the Dart [main] | 3898 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 3893 // method will not be invoked directly. | 3899 // method will not be invoked directly. |
| 3894 // Instead, a closure that will invoke [main] is | 3900 // Instead, a closure that will invoke [main] is |
| 3895 // passed to [dartMainRunner]. | 3901 // passed to [dartMainRunner]. |
| 3896 """; | 3902 """; |
| OLD | NEW |