Chromium Code Reviews| Index: lib/isolate/frog/isolateimpl.dart |
| =================================================================== |
| --- lib/isolate/frog/isolateimpl.dart (revision 5289) |
| +++ lib/isolate/frog/isolateimpl.dart (working copy) |
| @@ -19,6 +19,21 @@ |
| $static_init(); |
| """; |
| +ReceivePort _port; |
|
ngeoffray
2012/03/11 15:43:54
I moved this code here because it can be shared be
|
| + |
| +SendPort _spawnFunction(void topLevelFunction()) { |
| + final name = _IsolateNatives._getJSFunctionName(topLevelFunction); |
| + if (name == null) { |
| + throw new UnsupportedOperationException( |
| + "only top-level functions can be spawned."); |
| + } |
| + return _IsolateNatives._spawn2(name, null, false); |
| +} |
| + |
| +SendPort _spawnUri(String uri) { |
| + return _IsolateNatives._spawn2(null, uri, false); |
| +} |
| + |
| /** Global state associated with the current worker. See [globalState]. */ |
| // TODO(sigmund): split in multiple classes: global, thread, main-worker states? |
| class _GlobalState { |
| @@ -139,7 +154,7 @@ |
| } |
| // these are filled lazily the first time the isolate starts running. |
| - void initGlobals() native 'this.isolateStatics = {};'; |
| + void initGlobals() native @'$initGlobals(this);'; |
|
ngeoffray
2012/03/11 15:43:54
Leg and Frog currently differ in where they put gl
|
| /** |
| * Run [code] in the context of the isolate represented by [this]. Note this |
| @@ -159,7 +174,7 @@ |
| return result; |
| } |
| - void _setGlobals() native @'$globals = this.isolateStatics;'; |
| + void _setGlobals() native @'$setGlobals(this);'; |
|
ngeoffray
2012/03/11 15:43:54
Ditto.
|
| /** Lookup a port registered for this isolate. */ |
| ReceivePort lookup(int id) => ports[id]; |
| @@ -338,7 +353,7 @@ |
| // TODO(sigmund): fix - this code should be run synchronously when loading the |
| // script. Running lazily on DOMContentLoaded will yield incorrect results. |
| static String _computeThisScript() native @""" |
| - if (!$globalState.supportsWorkers || $globalState.isWorker) return null; |
| + if (!$globalState.supportsWorkers || $globalState.isWorker) return (void 0); |
|
ngeoffray
2012/03/11 15:43:54
Currently leg recognizes JS undefined as Dart null
|
| // TODO(5334778): Find a cross-platform non-brittle way of getting the |
| // currently running script. |
| @@ -507,9 +522,9 @@ |
| // in discussion on the CL, 9416119. |
| native @""" |
| if (typeof(f.name) === 'undefined') { |
| - return (f.toString().match(/function (.+)\(/) || [, null])[1]; |
| + return (f.toString().match(/function (.+)\(/) || [, (void 0)])[1]; |
| } else { |
| - return f.name || null; |
| + return f.name || (void 0); |
| } |
| """; |