| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library _js_helper; | 5 library _js_helper; |
| 6 | 6 |
| 7 import 'shared/embedded_names.dart' show | 7 import 'shared/embedded_names.dart' show |
| 8 ALL_CLASSES, | 8 ALL_CLASSES, |
| 9 GET_ISOLATE_TAG, | 9 GET_ISOLATE_TAG, |
| 10 INTERCEPTED_NAMES, | 10 INTERCEPTED_NAMES, |
| (...skipping 3220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3231 * | 3231 * |
| 3232 * This will be truncated to the 53 bits available in a double. | 3232 * This will be truncated to the 53 bits available in a double. |
| 3233 */ | 3233 */ |
| 3234 int random64() { | 3234 int random64() { |
| 3235 // TODO(lrn): Use a secure random source. | 3235 // TODO(lrn): Use a secure random source. |
| 3236 int int32a = JS("int", "(Math.random() * 0x100000000) >>> 0"); | 3236 int int32a = JS("int", "(Math.random() * 0x100000000) >>> 0"); |
| 3237 int int32b = JS("int", "(Math.random() * 0x100000000) >>> 0"); | 3237 int int32b = JS("int", "(Math.random() * 0x100000000) >>> 0"); |
| 3238 return int32a + int32b * 0x100000000; | 3238 return int32a + int32b * 0x100000000; |
| 3239 } | 3239 } |
| 3240 | 3240 |
| 3241 String jsonEncodeNative(String string) { |
| 3242 return JS("String", "JSON.stringify(#)", string); |
| 3243 } |
| 3244 |
| 3241 /** | 3245 /** |
| 3242 * Returns a property name for placing data on JavaScript objects shared between | 3246 * Returns a property name for placing data on JavaScript objects shared between |
| 3243 * DOM isolates. This happens when multiple programs are loaded in the same | 3247 * DOM isolates. This happens when multiple programs are loaded in the same |
| 3244 * JavaScript context (i.e. page). The name is based on [name] but with an | 3248 * JavaScript context (i.e. page). The name is based on [name] but with an |
| 3245 * additional part that is unique for each isolate. | 3249 * additional part that is unique for each isolate. |
| 3246 * | 3250 * |
| 3247 * The form of the name is '___dart_$name_$id'. | 3251 * The form of the name is '___dart_$name_$id'. |
| 3248 */ | 3252 */ |
| 3249 String getIsolateAffinityTag(String name) { | 3253 String getIsolateAffinityTag(String name) { |
| 3250 var isolateTagGetter = | 3254 var isolateTagGetter = |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3398 throw new MainError("No top-level function named 'main'."); | 3402 throw new MainError("No top-level function named 'main'."); |
| 3399 } | 3403 } |
| 3400 | 3404 |
| 3401 void badMain() { | 3405 void badMain() { |
| 3402 throw new MainError("'main' is not a function."); | 3406 throw new MainError("'main' is not a function."); |
| 3403 } | 3407 } |
| 3404 | 3408 |
| 3405 void mainHasTooManyParameters() { | 3409 void mainHasTooManyParameters() { |
| 3406 throw new MainError("'main' expects too many parameters."); | 3410 throw new MainError("'main' expects too many parameters."); |
| 3407 } | 3411 } |
| OLD | NEW |