| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // Javascript preamble, that lets the output of dart2js run on V8's d8 shell. | 5 // Javascript preamble, that lets the output of dart2js run on V8's d8 shell. |
| 6 | 6 |
| 7 // Node wraps files and provides them with a different `this`. The global | 7 // Node wraps files and provides them with a different `this`. The global |
| 8 // `this` can be accessed through `global`. | 8 // `this` can be accessed through `global`. |
| 9 | 9 |
| 10 var self = this; | 10 var self = this; |
| 11 if (typeof global != "undefined") self = global; // Node.js. | 11 if (typeof global != "undefined") self = global; // Node.js. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } else { | 262 } else { |
| 263 throw e; | 263 throw e; |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 action = nextEvent(); | 266 action = nextEvent(); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 // Global properties. "self" refers to the global object, so adding a | 270 // Global properties. "self" refers to the global object, so adding a |
| 271 // property to "self" defines a global variable. | 271 // property to "self" defines a global variable. |
| 272 self.self = self |
| 272 self.dartMainRunner = function(main, args) { | 273 self.dartMainRunner = function(main, args) { |
| 273 // Initialize. | 274 // Initialize. |
| 274 var action = function() { main(args); } | 275 var action = function() { main(args); } |
| 275 eventLoop(action); | 276 eventLoop(action); |
| 276 }; | 277 }; |
| 277 self.setTimeout = addTimer; | 278 self.setTimeout = addTimer; |
| 278 self.clearTimeout = cancelTimer; | 279 self.clearTimeout = cancelTimer; |
| 279 self.setInterval = addInterval; | 280 self.setInterval = addInterval; |
| 280 self.clearInterval = cancelTimer; | 281 self.clearInterval = cancelTimer; |
| 281 self.scheduleImmediate = addTask; | 282 self.scheduleImmediate = addTask; |
| 282 self.self = self; | 283 |
| 284 // Support for deferred loading. |
| 285 self.dartDeferredLibraryLoader = function(uri, successCallback, errorCallback)
{ |
| 286 try { |
| 287 load(uri); |
| 288 successCallback(); |
| 289 } catch (error) { |
| 290 errorCallback(error); |
| 291 } |
| 292 }; |
| 283 })(self); | 293 })(self); |
| OLD | NEW |