| 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 var $thisScriptUrl = null; | 10 var $thisScriptUrl = null; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 var self = this; | 37 var self = this; |
| 38 this.wrap$1 = function(arg) { | 38 this.wrap$1 = function(arg) { |
| 39 var res = isolateContext.eval(function() { return self(arg); }); | 39 var res = isolateContext.eval(function() { return self(arg); }); |
| 40 $globalState.topEventLoop.run(); | 40 $globalState.topEventLoop.run(); |
| 41 return res; | 41 return res; |
| 42 }; | 42 }; |
| 43 this.wrap$call$1 = function() { return this.wrap$1; }; | 43 this.wrap$call$1 = function() { return this.wrap$1; }; |
| 44 return this.wrap$1; | 44 return this.wrap$1; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // Wrap a 2-arg dom-callback to bind it with the current isolate: |
| 48 function $wrap_call$2(fn) { return fn && fn.wrap$call$2(); } |
| 49 |
| 50 Function.prototype.wrap$call$2 = function() { |
| 51 var isolateContext = $globalState.currentContext; |
| 52 var self = this; |
| 53 this.wrap$2 = function(arg1, arg2) { |
| 54 var res = isolateContext.eval(function() { return self(arg1, arg2); }); |
| 55 $globalState.topEventLoop.run(); |
| 56 return res; |
| 57 }; |
| 58 this.wrap$call$2 = function() { return this.wrap$2; }; |
| 59 return this.wrap$2; |
| 60 }; |
| 61 |
| 47 $thisScriptUrl = (function () { | 62 $thisScriptUrl = (function () { |
| 48 if (!$supportsWorkers || $isWorker) return (void 0); | 63 if (!$supportsWorkers || $isWorker) return (void 0); |
| 49 | 64 |
| 50 // TODO(5334778): Find a cross-platform non-brittle way of getting the | 65 // TODO(5334778): Find a cross-platform non-brittle way of getting the |
| 51 // currently running script. | 66 // currently running script. |
| 52 var scripts = document.getElementsByTagName('script'); | 67 var scripts = document.getElementsByTagName('script'); |
| 53 // The scripts variable only contains the scripts that have already been | 68 // The scripts variable only contains the scripts that have already been |
| 54 // executed. The last one is the currently running script. | 69 // executed. The last one is the currently running script. |
| 55 var script = scripts[scripts.length - 1]; | 70 var script = scripts[scripts.length - 1]; |
| 56 var src = script && script.src; | 71 var src = script && script.src; |
| 57 if (!src) { | 72 if (!src) { |
| 58 // TODO() | 73 // TODO() |
| 59 src = "FIXME:5407062" + "_" + Math.random().toString(); | 74 src = "FIXME:5407062" + "_" + Math.random().toString(); |
| 60 if (script) script.src = src; | 75 if (script) script.src = src; |
| 61 } | 76 } |
| 62 return src; | 77 return src; |
| 63 })(); | 78 })(); |
| OLD | NEW |