| 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 // Top-level native code needed by the frog compiler | 5 // Top-level native code needed by the frog compiler |
| 6 | 6 |
| 7 var $globalThis = this; | 7 var $globalThis = this; |
| 8 var $globals = null; | 8 var $globals = null; |
| 9 var $globalState = null; | 9 var $globalState = null; |
| 10 function $initGlobals(context) { context.isolateStatics = {}; } | 10 function $initGlobals(context) { context.isolateStatics = {}; } |
| 11 function $setGlobals(context) { $globals = context.isolateStatics; } | 11 function $setGlobals(context) { $globals = context.isolateStatics; } |
| 12 | 12 |
| 13 // Wrap a 0-arg dom-callback to bind it with the current isolate: | 13 // Wrap a 0-arg dom-callback to bind it with the current isolate: |
| 14 function $wrap_call$0(fn) { return fn && fn.wrap$call$0(); } | 14 function $wrap_call$0(fn) { return fn && fn.wrap$call$0(); } |
| 15 | 15 |
| 16 Function.prototype.wrap$call$0 = function() { | 16 Function.prototype.wrap$call$0 = function() { |
| 17 var isolateContext = $globalState.currentContext; | 17 var isolateContext = $globalState.currentContext; |
| 18 var self = this; | 18 var self = this; |
| 19 this.wrap$0 = function() { | 19 this.wrap$0 = function() { |
| 20 isolateContext.eval(self); | 20 var res = isolateContext.eval(self); |
| 21 $globalState.topEventLoop.run(); | 21 $globalState.topEventLoop.run(); |
| 22 return res; |
| 22 }; | 23 }; |
| 23 this.wrap$call$0 = function() { return this.wrap$0; }; | 24 this.wrap$call$0 = function() { return this.wrap$0; }; |
| 24 return this.wrap$0; | 25 return this.wrap$0; |
| 25 }; | 26 }; |
| 26 | 27 |
| 27 // Wrap a 1-arg dom-callback to bind it with the current isolate: | 28 // Wrap a 1-arg dom-callback to bind it with the current isolate: |
| 28 function $wrap_call$1(fn) { return fn && fn.wrap$call$1(); } | 29 function $wrap_call$1(fn) { return fn && fn.wrap$call$1(); } |
| 29 | 30 |
| 30 Function.prototype.wrap$call$1 = function() { | 31 Function.prototype.wrap$call$1 = function() { |
| 31 var isolateContext = $globalState.currentContext; | 32 var isolateContext = $globalState.currentContext; |
| 32 var self = this; | 33 var self = this; |
| 33 this.wrap$1 = function(arg) { | 34 this.wrap$1 = function(arg) { |
| 34 isolateContext.eval(function() { self(arg); }); | 35 var res = isolateContext.eval(function() { return self(arg); }); |
| 35 $globalState.topEventLoop.run(); | 36 $globalState.topEventLoop.run(); |
| 37 return res; |
| 36 }; | 38 }; |
| 37 this.wrap$call$1 = function() { return this.wrap$1; }; | 39 this.wrap$call$1 = function() { return this.wrap$1; }; |
| 38 return this.wrap$1; | 40 return this.wrap$1; |
| 39 }; | 41 }; |
| OLD | NEW |