OLD | NEW |
1 var _isolate_helper; | 1 var _isolate_helper; |
2 (function(exports) { | 2 (function(exports) { |
3 'use strict'; | 3 'use strict'; |
4 // Function _serializeMessage: (dynamic) → dynamic | 4 // Function _serializeMessage: (dynamic) → dynamic |
5 function _serializeMessage(message) { | 5 function _serializeMessage(message) { |
6 return new _Serializer().serialize(message); | 6 return new _Serializer().serialize(message); |
7 } | 7 } |
8 // Function _deserializeMessage: (dynamic) → dynamic | 8 // Function _deserializeMessage: (dynamic) → dynamic |
9 function _deserializeMessage(message) { | 9 function _deserializeMessage(message) { |
10 return new _Deserializer().deserialize(message); | 10 return new _Deserializer().deserialize(message); |
11 } | 11 } |
12 // Function _clone: (dynamic) → dynamic | 12 // Function _clone: (dynamic) → dynamic |
13 function _clone(message) { | 13 function _clone(message) { |
14 let serializer = new _Serializer({serializeSendPorts: false}); | 14 let serializer = new _Serializer({serializeSendPorts: false}); |
15 let deserializer = new _Deserializer(); | 15 let deserializer = new _Deserializer(); |
16 return deserializer.deserialize(serializer.serialize(message)); | 16 return deserializer.deserialize(serializer.serialize(message)); |
17 } | 17 } |
18 let _serializeSendPorts = Symbol('_serializeSendPorts'); | 18 let _serializeSendPorts = Symbol('_serializeSendPorts'); |
19 let _workerId = Symbol('_workerId'); | 19 let _workerId = Symbol('_workerId'); |
20 let _isolateId = Symbol('_isolateId'); | 20 let _isolateId = Symbol('_isolateId'); |
21 let _receivePortId = Symbol('_receivePortId'); | 21 let _receivePortId = Symbol('_receivePortId'); |
22 let _receivePort = Symbol('_receivePort'); | 22 let _receivePort = Symbol('_receivePort'); |
23 let _id = Symbol('_id'); | 23 let _id = Symbol('_id'); |
24 class _Serializer extends core.Object { | 24 class _Serializer extends core.Object { |
25 _Serializer(opt$) { | 25 _Serializer(opts) { |
26 let serializeSendPorts = opt$ && 'serializeSendPorts' in opt$ ? opt$.seria
lizeSendPorts : true; | 26 let serializeSendPorts = opts && 'serializeSendPorts' in opts ? opts.seria
lizeSendPorts : true; |
27 this.serializedObjectIds = new core.Map.identity(); | 27 this.serializedObjectIds = new core.Map.identity(); |
28 this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); | 28 this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); |
29 } | 29 } |
30 serialize(x) { | 30 serialize(x) { |
31 if (this.isPrimitive(x)) | 31 if (this.isPrimitive(x)) |
32 return this.serializePrimitive(x); | 32 return this.serializePrimitive(x); |
33 let serializationId = this.serializedObjectIds.get(x); | 33 let serializationId = this.serializedObjectIds.get(x); |
34 if (serializationId !== null) | 34 if (serializationId !== null) |
35 return this.makeRef(serializationId); | 35 return this.makeRef(serializationId); |
36 serializationId = this.serializedObjectIds.length; | 36 serializationId = this.serializedObjectIds.length; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 serializeDartObject(x) { | 150 serializeDartObject(x) { |
151 let classExtractor = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_n
ames.CLASS_ID_EXTRACTOR); | 151 let classExtractor = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_n
ames.CLASS_ID_EXTRACTOR); |
152 let fieldsExtractor = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_
names.CLASS_FIELDS_EXTRACTOR); | 152 let fieldsExtractor = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_
names.CLASS_FIELDS_EXTRACTOR); |
153 let classId = classExtractor(x); | 153 let classId = classExtractor(x); |
154 let fields = dart.as(fieldsExtractor(x), core.List); | 154 let fields = dart.as(fieldsExtractor(x), core.List); |
155 return new List.from(['dart', classId, this.serializeArrayInPlace(dart.as(
fields, _interceptors.JSArray))]); | 155 return new List.from(['dart', classId, this.serializeArrayInPlace(dart.as(
fields, _interceptors.JSArray))]); |
156 } | 156 } |
157 } | 157 } |
158 let _adjustSendPorts = Symbol('_adjustSendPorts'); | 158 let _adjustSendPorts = Symbol('_adjustSendPorts'); |
159 class _Deserializer extends core.Object { | 159 class _Deserializer extends core.Object { |
160 _Deserializer(opt$) { | 160 _Deserializer(opts) { |
161 let adjustSendPorts = opt$ && 'adjustSendPorts' in opt$ ? opt$.adjustSendP
orts : true; | 161 let adjustSendPorts = opts && 'adjustSendPorts' in opts ? opts.adjustSendP
orts : true; |
162 this.deserializedObjects = new core.List(); | 162 this.deserializedObjects = new core.List(); |
163 this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool); | 163 this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool); |
164 } | 164 } |
165 deserialize(x) { | 165 deserialize(x) { |
166 if (this.isPrimitive(x)) | 166 if (this.isPrimitive(x)) |
167 return this.deserializePrimitive(x); | 167 return this.deserializePrimitive(x); |
168 if (!dart.is(x, _interceptors.JSArray)) | 168 if (!dart.is(x, _interceptors.JSArray)) |
169 throw new core.ArgumentError(`Bad serialized message: ${x}`); | 169 throw new core.ArgumentError(`Bad serialized message: ${x}`); |
170 switch (dart.dload(x, 'first')) { | 170 switch (dart.dload(x, 'first')) { |
171 case "ref": | 171 case "ref": |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 let fields = dart.as(dart.dindex(x, 2), core.List); | 313 let fields = dart.as(dart.dindex(x, 2), core.List); |
314 let instanceFromClassId = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embed
ded_names.INSTANCE_FROM_CLASS_ID); | 314 let instanceFromClassId = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embed
ded_names.INSTANCE_FROM_CLASS_ID); |
315 let initializeObject = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded
_names.INITIALIZE_EMPTY_INSTANCE); | 315 let initializeObject = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded
_names.INITIALIZE_EMPTY_INSTANCE); |
316 let emptyInstance = instanceFromClassId(classId); | 316 let emptyInstance = instanceFromClassId(classId); |
317 this.deserializedObjects.add(emptyInstance); | 317 this.deserializedObjects.add(emptyInstance); |
318 this.deserializeArrayInPlace(dart.as(fields, _interceptors.JSArray)); | 318 this.deserializeArrayInPlace(dart.as(fields, _interceptors.JSArray)); |
319 return initializeObject(classId, emptyInstance, fields); | 319 return initializeObject(classId, emptyInstance, fields); |
320 } | 320 } |
321 } | 321 } |
322 // Function _callInIsolate: (_IsolateContext, Function) → dynamic | 322 // Function _callInIsolate: (_IsolateContext, Function) → dynamic |
323 function _callInIsolate(isolate, function) { | 323 function _callInIsolate(isolate, function$0) { |
324 let result = isolate.eval(function); | 324 let result = isolate.eval(function$0); |
325 exports._globalState.topEventLoop.run(); | 325 exports._globalState.topEventLoop.run(); |
326 return result; | 326 return result; |
327 } | 327 } |
328 let _activeJsAsyncCount = Symbol('_activeJsAsyncCount'); | 328 let _activeJsAsyncCount = Symbol('_activeJsAsyncCount'); |
329 // Function enterJsAsync: () → dynamic | 329 // Function enterJsAsync: () → dynamic |
330 function enterJsAsync() { | 330 function enterJsAsync() { |
331 exports._globalState.topEventLoop[_activeJsAsyncCount] = dart.notNull(export
s._globalState.topEventLoop[_activeJsAsyncCount]) + 1; | 331 exports._globalState.topEventLoop[_activeJsAsyncCount] = dart.notNull(export
s._globalState.topEventLoop[_activeJsAsyncCount]) + 1; |
332 } | 332 } |
333 // Function leaveJsAsync: () → dynamic | 333 // Function leaveJsAsync: () → dynamic |
334 function leaveJsAsync() { | 334 function leaveJsAsync() { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 dart.copyProperties(exports, { | 373 dart.copyProperties(exports, { |
374 get _globalState() { | 374 get _globalState() { |
375 return dart.as(init.globalState, _Manager); | 375 return dart.as(init.globalState, _Manager); |
376 }, | 376 }, |
377 set _globalState(val) { | 377 set _globalState(val) { |
378 init.globalState = val; | 378 init.globalState = val; |
379 } | 379 } |
380 }); | 380 }); |
381 let _nativeDetectEnvironment = Symbol('_nativeDetectEnvironment'); | 381 let _nativeDetectEnvironment = Symbol('_nativeDetectEnvironment'); |
382 let _nativeInitWorkerMessageHandler = Symbol('_nativeInitWorkerMessageHandler'
); | 382 let _nativeInitWorkerMessageHandler = Symbol('_nativeInitWorkerMessageHandler'
); |
383 let _processWorkerMessage = Symbol('_processWorkerMessage'); | 383 let _processWorkerMessage$ = Symbol('_processWorkerMessage'); |
384 let _serializePrintMessage = Symbol('_serializePrintMessage'); | 384 let _serializePrintMessage$ = Symbol('_serializePrintMessage'); |
385 class _Manager extends core.Object { | 385 class _Manager extends core.Object { |
386 get useWorkers() { | 386 get useWorkers() { |
387 return this.supportsWorkers; | 387 return this.supportsWorkers; |
388 } | 388 } |
389 _Manager(entry) { | 389 _Manager(entry) { |
390 this.entry = entry; | 390 this.entry = entry; |
391 this.nextIsolateId = 0; | 391 this.nextIsolateId = 0; |
392 this.currentManagerId = 0; | 392 this.currentManagerId = 0; |
393 this.nextManagerId = 1; | 393 this.nextManagerId = 1; |
394 this.currentContext = null; | 394 this.currentContext = null; |
(...skipping 15 matching lines...) Expand all Loading... |
410 } | 410 } |
411 } | 411 } |
412 [_nativeDetectEnvironment]() { | 412 [_nativeDetectEnvironment]() { |
413 let isWindowDefined = exports.globalWindow !== null; | 413 let isWindowDefined = exports.globalWindow !== null; |
414 let isWorkerDefined = exports.globalWorker !== null; | 414 let isWorkerDefined = exports.globalWorker !== null; |
415 this.isWorker = !dart.notNull(isWindowDefined) && dart.notNull(exports.glo
balPostMessageDefined); | 415 this.isWorker = !dart.notNull(isWindowDefined) && dart.notNull(exports.glo
balPostMessageDefined); |
416 this.supportsWorkers = dart.notNull(this.isWorker) || dart.notNull(isWorke
rDefined) && dart.notNull(IsolateNatives.thisScript !== null); | 416 this.supportsWorkers = dart.notNull(this.isWorker) || dart.notNull(isWorke
rDefined) && dart.notNull(IsolateNatives.thisScript !== null); |
417 this.fromCommandLine = !dart.notNull(isWindowDefined) && !dart.notNull(thi
s.isWorker); | 417 this.fromCommandLine = !dart.notNull(isWindowDefined) && !dart.notNull(thi
s.isWorker); |
418 } | 418 } |
419 [_nativeInitWorkerMessageHandler]() { | 419 [_nativeInitWorkerMessageHandler]() { |
420 let function = function(f, a) { | 420 let function$0 = function(f, a) { |
421 return function(e) { | 421 return function(e) { |
422 f(a, e); | 422 f(a, e); |
423 }; | 423 }; |
424 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives[_processWorkerMessage]
), this.mainManager); | 424 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives[_processWorkerMessage$
]), this.mainManager); |
425 self.onmessage = function; | 425 self.onmessage = function$0; |
426 self.dartPrint = self.dartPrint || function(serialize) { | 426 self.dartPrint = self.dartPrint || function(serialize) { |
427 return function(object) { | 427 return function(object) { |
428 if (self.console && self.console.log) { | 428 if (self.console && self.console.log) { |
429 self.console.log(object); | 429 self.console.log(object); |
430 } else { | 430 } else { |
431 self.postMessage(serialize(object)); | 431 self.postMessage(serialize(object)); |
432 } | 432 } |
433 }; | 433 }; |
434 }(_foreign_helper.DART_CLOSURE_TO_JS(_serializePrintMessage)); | 434 }(_foreign_helper.DART_CLOSURE_TO_JS(_serializePrintMessage)); |
435 } | 435 } |
436 static [_serializePrintMessage](object) { | 436 static [_serializePrintMessage$](object) { |
437 return _serializeMessage(dart.map({command: "print", msg: object})); | 437 return _serializeMessage(dart.map({command: "print", msg: object})); |
438 } | 438 } |
439 maybeCloseWorker() { | 439 maybeCloseWorker() { |
440 if (dart.notNull(this.isWorker) && dart.notNull(this.isolates.isEmpty) &&
this.topEventLoop[_activeJsAsyncCount] === 0) { | 440 if (dart.notNull(this.isWorker) && dart.notNull(this.isolates.isEmpty) &&
this.topEventLoop[_activeJsAsyncCount] === 0) { |
441 this.mainManager.postMessage(_serializeMessage(dart.map({command: 'close
'}))); | 441 this.mainManager.postMessage(_serializeMessage(dart.map({command: 'close
'}))); |
442 } | 442 } |
443 } | 443 } |
444 } | 444 } |
445 let _scheduledControlEvents = Symbol('_scheduledControlEvents'); | 445 let _scheduledControlEvents = Symbol('_scheduledControlEvents'); |
446 let _isExecutingEvent = Symbol('_isExecutingEvent'); | 446 let _isExecutingEvent = Symbol('_isExecutingEvent'); |
447 let _updateGlobalState = Symbol('_updateGlobalState'); | 447 let _updateGlobalState = Symbol('_updateGlobalState'); |
448 let _setGlobals = Symbol('_setGlobals'); | 448 let _setGlobals = Symbol('_setGlobals'); |
449 let _addRegistration = Symbol('_addRegistration'); | 449 let _addRegistration = Symbol('_addRegistration'); |
450 class _IsolateContext extends core.Object { | 450 class _IsolateContext extends core.Object { |
451 _IsolateContext() { | 451 _IsolateContext() { |
452 this.id = (($tmp) => exports._globalState.nextIsolateId = dart.notNull($tm
p) + 1, $tmp).bind(this)(exports._globalState.nextIsolateId); | 452 this.id = ((x) => exports._globalState.nextIsolateId = dart.notNull(x$) +
1, x$).bind(this)(exports._globalState.nextIsolateId); |
453 this.ports = new core.Map(); | 453 this.ports = new core.Map(); |
454 this.weakPorts = new core.Set(); | 454 this.weakPorts = new core.Set(); |
455 this.isolateStatics = _foreign_helper.JS_CREATE_ISOLATE(); | 455 this.isolateStatics = _foreign_helper.JS_CREATE_ISOLATE(); |
456 this.controlPort = new RawReceivePortImpl._controlPort(); | 456 this.controlPort = new RawReceivePortImpl._controlPort(); |
457 this.pauseCapability = new isolate.Capability(); | 457 this.pauseCapability = new isolate.Capability(); |
458 this.terminateCapability = new isolate.Capability(); | 458 this.terminateCapability = new isolate.Capability(); |
459 this.delayedEvents = dart.as(new List.from([]), core.List$(_IsolateEvent))
; | 459 this.delayedEvents = dart.as(new List.from([]), core.List$(_IsolateEvent))
; |
460 this.pauseTokens = dart.as(new core.Set(), core.Set$(isolate.Capability)); | 460 this.pauseTokens = dart.as(new core.Set(), core.Set$(isolate.Capability)); |
461 this.errorPorts = dart.as(new core.Set(), core.Set$(isolate.SendPort)); | 461 this.errorPorts = dart.as(new core.Set(), core.Set$(isolate.SendPort)); |
462 this.initialized = false; | 462 this.initialized = false; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 }, | 771 }, |
772 get globalWorker() { | 772 get globalWorker() { |
773 _js_helper.requiresPreamble(); | 773 _js_helper.requiresPreamble(); |
774 return self.Worker; | 774 return self.Worker; |
775 }, | 775 }, |
776 get globalPostMessageDefined() { | 776 get globalPostMessageDefined() { |
777 _js_helper.requiresPreamble(); | 777 _js_helper.requiresPreamble(); |
778 return !!self.postMessage; | 778 return !!self.postMessage; |
779 } | 779 } |
780 }); | 780 }); |
781 let _getEventData = Symbol('_getEventData'); | 781 let _getEventData$ = Symbol('_getEventData'); |
782 let _log = Symbol('_log'); | 782 let _log$ = Symbol('_log'); |
783 let _consoleLog = Symbol('_consoleLog'); | 783 let _consoleLog$ = Symbol('_consoleLog'); |
784 let _getJSFunctionFromName = Symbol('_getJSFunctionFromName'); | 784 let _getJSFunctionFromName$ = Symbol('_getJSFunctionFromName'); |
785 let _getJSFunctionName = Symbol('_getJSFunctionName'); | 785 let _getJSFunctionName$ = Symbol('_getJSFunctionName'); |
786 let _allocate = Symbol('_allocate'); | 786 let _allocate = Symbol('_allocate'); |
787 let _startWorker = Symbol('_startWorker'); | 787 let _startWorker$ = Symbol('_startWorker'); |
788 let _startNonWorker = Symbol('_startNonWorker'); | 788 let _startNonWorker$ = Symbol('_startNonWorker'); |
789 let _startIsolate = Symbol('_startIsolate'); | 789 let _startIsolate$ = Symbol('_startIsolate'); |
790 let _spawnWorker = Symbol('_spawnWorker'); | 790 let _spawnWorker$ = Symbol('_spawnWorker'); |
791 class IsolateNatives extends core.Object { | 791 class IsolateNatives extends core.Object { |
792 static computeThisScript() { | 792 static computeThisScript() { |
793 let currentScript = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_na
mes.CURRENT_SCRIPT); | 793 let currentScript = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_na
mes.CURRENT_SCRIPT); |
794 if (currentScript !== null) { | 794 if (currentScript !== null) { |
795 return String(currentScript.src); | 795 return String(currentScript.src); |
796 } | 796 } |
797 if (_js_helper.Primitives.isD8) | 797 if (_js_helper.Primitives.isD8) |
798 return computeThisScriptD8(); | 798 return computeThisScriptD8(); |
799 if (_js_helper.Primitives.isJsshell) | 799 if (_js_helper.Primitives.isJsshell) |
800 return computeThisScriptJsshell(); | 800 return computeThisScriptJsshell(); |
(...skipping 25 matching lines...) Expand all Loading... |
826 pattern = new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m"); | 826 pattern = new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m"); |
827 matches = stack.match(pattern); | 827 matches = stack.match(pattern); |
828 if (matches !== null) | 828 if (matches !== null) |
829 return matches[1]; | 829 return matches[1]; |
830 pattern = new RegExp("^[^@]*@(.*):[0-9]*$", "m"); | 830 pattern = new RegExp("^[^@]*@(.*):[0-9]*$", "m"); |
831 matches = stack.match(pattern); | 831 matches = stack.match(pattern); |
832 if (matches !== null) | 832 if (matches !== null) |
833 return matches[1]; | 833 return matches[1]; |
834 throw new core.UnsupportedError(`Cannot extract URI from "${stack}"`); | 834 throw new core.UnsupportedError(`Cannot extract URI from "${stack}"`); |
835 } | 835 } |
836 static [_getEventData](e) { | 836 static [_getEventData$](e) { |
837 return e.data; | 837 return e.data; |
838 } | 838 } |
839 static [_processWorkerMessage](sender, e) { | 839 static [_processWorkerMessage$](sender, e) { |
840 let msg = _deserializeMessage(_getEventData(e)); | 840 let msg = _deserializeMessage(_getEventData(e)); |
841 switch (dart.dindex(msg, 'command')) { | 841 switch (dart.dindex(msg, 'command')) { |
842 case 'start': | 842 case 'start': |
843 exports._globalState.currentManagerId = dart.as(dart.dindex(msg, 'id')
, core.int); | 843 exports._globalState.currentManagerId = dart.as(dart.dindex(msg, 'id')
, core.int); |
844 let functionName = dart.as(dart.dindex(msg, 'functionName'), core.Stri
ng); | 844 let functionName = dart.as(dart.dindex(msg, 'functionName'), core.Stri
ng); |
845 let entryPoint = dart.as(functionName === null ? exports._globalState.
entry : _getJSFunctionFromName(functionName), core.Function); | 845 let entryPoint = dart.as(functionName === null ? exports._globalState.
entry : _getJSFunctionFromName(functionName), core.Function); |
846 let args = dart.dindex(msg, 'args'); | 846 let args = dart.dindex(msg, 'args'); |
847 let message = _deserializeMessage(dart.dindex(msg, 'msg')); | 847 let message = _deserializeMessage(dart.dindex(msg, 'msg')); |
848 let isSpawnUri = dart.dindex(msg, 'isSpawnUri'); | 848 let isSpawnUri = dart.dindex(msg, 'isSpawnUri'); |
849 let startPaused = dart.dindex(msg, 'startPaused'); | 849 let startPaused = dart.dindex(msg, 'startPaused'); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 static handleSpawnWorkerRequest(msg) { | 888 static handleSpawnWorkerRequest(msg) { |
889 let replyPort = dart.dindex(msg, 'replyPort'); | 889 let replyPort = dart.dindex(msg, 'replyPort'); |
890 spawn(dart.as(dart.dindex(msg, 'functionName'), core.String), dart.as(dart
.dindex(msg, 'uri'), core.String), dart.as(dart.dindex(msg, 'args'), core.List$(
core.String)), dart.dindex(msg, 'msg'), false, dart.as(dart.dindex(msg, 'isSpawn
Uri'), core.bool), dart.as(dart.dindex(msg, 'startPaused'), core.bool)).then(dar
t.closureWrap((msg) => { | 890 spawn(dart.as(dart.dindex(msg, 'functionName'), core.String), dart.as(dart
.dindex(msg, 'uri'), core.String), dart.as(dart.dindex(msg, 'args'), core.List$(
core.String)), dart.dindex(msg, 'msg'), false, dart.as(dart.dindex(msg, 'isSpawn
Uri'), core.bool), dart.as(dart.dindex(msg, 'startPaused'), core.bool)).then(dar
t.closureWrap((msg) => { |
891 dart.dinvoke(replyPort, 'send', msg); | 891 dart.dinvoke(replyPort, 'send', msg); |
892 }, "(List<dynamic>) → dynamic"), { | 892 }, "(List<dynamic>) → dynamic"), { |
893 onError: (errorMessage) => { | 893 onError: (errorMessage) => { |
894 dart.dinvoke(replyPort, 'send', new List.from([_SPAWN_FAILED_SIGNAL, e
rrorMessage])); | 894 dart.dinvoke(replyPort, 'send', new List.from([_SPAWN_FAILED_SIGNAL, e
rrorMessage])); |
895 } | 895 } |
896 }); | 896 }); |
897 } | 897 } |
898 static [_log](msg) { | 898 static [_log$](msg) { |
899 if (exports._globalState.isWorker) { | 899 if (exports._globalState.isWorker) { |
900 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'log', msg: msg}))); | 900 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'log', msg: msg}))); |
901 } else { | 901 } else { |
902 try { | 902 try { |
903 _consoleLog(msg); | 903 _consoleLog(msg); |
904 } catch (e) { | 904 } catch (e) { |
905 let trace = dart.stackTrace(e); | 905 let trace = dart.stackTrace(e); |
906 throw new core.Exception(trace); | 906 throw new core.Exception(trace); |
907 } | 907 } |
908 | 908 |
909 } | 909 } |
910 } | 910 } |
911 static [_consoleLog](msg) { | 911 static [_consoleLog$](msg) { |
912 _js_helper.requiresPreamble(); | 912 _js_helper.requiresPreamble(); |
913 self.console.log(msg); | 913 self.console.log(msg); |
914 } | 914 } |
915 static [_getJSFunctionFromName](functionName) { | 915 static [_getJSFunctionFromName$](functionName) { |
916 let globalFunctionsContainer = _foreign_helper.JS_EMBEDDED_GLOBAL("", _js_
embedded_names.GLOBAL_FUNCTIONS); | 916 let globalFunctionsContainer = _foreign_helper.JS_EMBEDDED_GLOBAL("", _js_
embedded_names.GLOBAL_FUNCTIONS); |
917 return globalFunctionsContainer[functionName](); | 917 return globalFunctionsContainer[functionName](); |
918 } | 918 } |
919 static [_getJSFunctionName](f) { | 919 static [_getJSFunctionName$](f) { |
920 return dart.as(dart.is(f, _js_helper.Closure) ? f.$name : null, core.Strin
g); | 920 return dart.as(dart.is(f, _js_helper.Closure) ? f.$name : null, core.Strin
g); |
921 } | 921 } |
922 static [_allocate](ctor) { | 922 static [_allocate](ctor) { |
923 return new ctor(); | 923 return new ctor(); |
924 } | 924 } |
925 static spawnFunction(topLevelFunction, message, startPaused) { | 925 static spawnFunction(topLevelFunction, message, startPaused) { |
926 IsolateNatives.enableSpawnWorker = true; | 926 IsolateNatives.enableSpawnWorker = true; |
927 let name = _getJSFunctionName(topLevelFunction); | 927 let name = _getJSFunctionName(topLevelFunction); |
928 if (name === null) { | 928 if (name === null) { |
929 throw new core.UnsupportedError("only top-level functions can be spawned
."); | 929 throw new core.UnsupportedError("only top-level functions can be spawned
."); |
(...skipping 22 matching lines...) Expand all Loading... |
952 } | 952 } |
953 }).bind(this)); | 953 }).bind(this)); |
954 let signalReply = port.sendPort; | 954 let signalReply = port.sendPort; |
955 if (dart.notNull(exports._globalState.useWorkers) && !dart.notNull(isLight
)) { | 955 if (dart.notNull(exports._globalState.useWorkers) && !dart.notNull(isLight
)) { |
956 _startWorker(functionName, uri, args, message, isSpawnUri, startPaused,
signalReply, ((message) => completer.completeError(message)).bind(this)); | 956 _startWorker(functionName, uri, args, message, isSpawnUri, startPaused,
signalReply, ((message) => completer.completeError(message)).bind(this)); |
957 } else { | 957 } else { |
958 _startNonWorker(functionName, uri, args, message, isSpawnUri, startPause
d, signalReply); | 958 _startNonWorker(functionName, uri, args, message, isSpawnUri, startPause
d, signalReply); |
959 } | 959 } |
960 return completer.future; | 960 return completer.future; |
961 } | 961 } |
962 static [_startWorker](functionName, uri, args, message, isSpawnUri, startPau
sed, replyPort, onError) { | 962 static [_startWorker$](functionName, uri, args, message, isSpawnUri, startPa
used, replyPort, onError) { |
963 if (args !== null) | 963 if (args !== null) |
964 args = new core.List.from(args); | 964 args = new core.List.from(args); |
965 if (exports._globalState.isWorker) { | 965 if (exports._globalState.isWorker) { |
966 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'spawn-worker', functionName: functionName, args: args, msg: message,
uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort
}))); | 966 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'spawn-worker', functionName: functionName, args: args, msg: message,
uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort
}))); |
967 } else { | 967 } else { |
968 _spawnWorker(functionName, uri, args, message, isSpawnUri, startPaused,
replyPort, onError); | 968 _spawnWorker(functionName, uri, args, message, isSpawnUri, startPaused,
replyPort, onError); |
969 } | 969 } |
970 } | 970 } |
971 static [_startNonWorker](functionName, uri, args, message, isSpawnUri, start
Paused, replyPort) { | 971 static [_startNonWorker$](functionName, uri, args, message, isSpawnUri, star
tPaused, replyPort) { |
972 if (uri !== null) { | 972 if (uri !== null) { |
973 throw new core.UnsupportedError("Currently spawnUri is not supported wit
hout web workers."); | 973 throw new core.UnsupportedError("Currently spawnUri is not supported wit
hout web workers."); |
974 } | 974 } |
975 message = _clone(message); | 975 message = _clone(message); |
976 if (args !== null) | 976 if (args !== null) |
977 args = new core.List.from(args); | 977 args = new core.List.from(args); |
978 exports._globalState.topEventLoop.enqueue(new _IsolateContext(), () => { | 978 exports._globalState.topEventLoop.enqueue(new _IsolateContext(), () => { |
979 let func = _getJSFunctionFromName(functionName); | 979 let func = _getJSFunctionFromName(functionName); |
980 _startIsolate(dart.as(func, core.Function), args, message, isSpawnUri, s
tartPaused, replyPort); | 980 _startIsolate(dart.as(func, core.Function), args, message, isSpawnUri, s
tartPaused, replyPort); |
981 }, 'nonworker start'); | 981 }, 'nonworker start'); |
982 } | 982 } |
983 static get currentIsolate() { | 983 static get currentIsolate() { |
984 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); | 984 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); |
985 return new isolate.Isolate(context.controlPort.sendPort, {pauseCapability:
context.pauseCapability, terminateCapability: context.terminateCapability}); | 985 return new isolate.Isolate(context.controlPort.sendPort, {pauseCapability:
context.pauseCapability, terminateCapability: context.terminateCapability}); |
986 } | 986 } |
987 static [_startIsolate](topLevel, args, message, isSpawnUri, startPaused, rep
lyTo) { | 987 static [_startIsolate$](topLevel, args, message, isSpawnUri, startPaused, re
plyTo) { |
988 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); | 988 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); |
989 _js_helper.Primitives.initializeStatics(context.id); | 989 _js_helper.Primitives.initializeStatics(context.id); |
990 replyTo.send(new List.from([_SPAWNED_SIGNAL, context.controlPort.sendPort,
context.pauseCapability, context.terminateCapability])); | 990 replyTo.send(new List.from([_SPAWNED_SIGNAL, context.controlPort.sendPort,
context.pauseCapability, context.terminateCapability])); |
991 // Function runStartFunction: () → void | 991 // Function runStartFunction: () → void |
992 function runStartFunction() { | 992 function runStartFunction() { |
993 context.initialized = true; | 993 context.initialized = true; |
994 if (!dart.notNull(isSpawnUri)) { | 994 if (!dart.notNull(isSpawnUri)) { |
995 dart.dinvokef(topLevel, message); | 995 dart.dinvokef(topLevel, message); |
996 } else if (dart.is(topLevel, _MainFunctionArgsMessage)) { | 996 } else if (dart.is(topLevel, _MainFunctionArgsMessage)) { |
997 dart.dinvokef(topLevel, args, message); | 997 dart.dinvokef(topLevel, args, message); |
998 } else if (dart.is(topLevel, _MainFunctionArgs)) { | 998 } else if (dart.is(topLevel, _MainFunctionArgs)) { |
999 dart.dinvokef(topLevel, args); | 999 dart.dinvokef(topLevel, args); |
1000 } else { | 1000 } else { |
1001 dart.dinvokef(topLevel); | 1001 dart.dinvokef(topLevel); |
1002 } | 1002 } |
1003 } | 1003 } |
1004 if (startPaused) { | 1004 if (startPaused) { |
1005 context.addPause(context.pauseCapability, context.pauseCapability); | 1005 context.addPause(context.pauseCapability, context.pauseCapability); |
1006 exports._globalState.topEventLoop.enqueue(context, runStartFunction, 'st
art isolate'); | 1006 exports._globalState.topEventLoop.enqueue(context, runStartFunction, 'st
art isolate'); |
1007 } else { | 1007 } else { |
1008 runStartFunction(); | 1008 runStartFunction(); |
1009 } | 1009 } |
1010 } | 1010 } |
1011 static [_spawnWorker](functionName, uri, args, message, isSpawnUri, startPau
sed, replyPort, onError) { | 1011 static [_spawnWorker$](functionName, uri, args, message, isSpawnUri, startPa
used, replyPort, onError) { |
1012 if (uri === null) | 1012 if (uri === null) |
1013 uri = thisScript; | 1013 uri = thisScript; |
1014 let worker = new Worker(uri); | 1014 let worker = new Worker(uri); |
1015 let onerrorTrampoline = function(f, u, c) { | 1015 let onerrorTrampoline = function(f, u, c) { |
1016 return function(e) { | 1016 return function(e) { |
1017 return f(e, u, c); | 1017 return f(e, u, c); |
1018 }; | 1018 }; |
1019 }(_foreign_helper.DART_CLOSURE_TO_JS(workerOnError), uri, onError); | 1019 }(_foreign_helper.DART_CLOSURE_TO_JS(workerOnError), uri, onError); |
1020 worker.onerror = onerrorTrampoline; | 1020 worker.onerror = onerrorTrampoline; |
1021 let processWorkerMessageTrampoline = function(f, a) { | 1021 let processWorkerMessageTrampoline = function(f, a) { |
1022 return function(e) { | 1022 return function(e) { |
1023 e.onerror = null; | 1023 e.onerror = null; |
1024 return f(a, e); | 1024 return f(a, e); |
1025 }; | 1025 }; |
1026 }(_foreign_helper.DART_CLOSURE_TO_JS(_processWorkerMessage), worker); | 1026 }(_foreign_helper.DART_CLOSURE_TO_JS(_processWorkerMessage), worker); |
1027 worker.onmessage = processWorkerMessageTrampoline; | 1027 worker.onmessage = processWorkerMessageTrampoline; |
1028 let workerId = (($tmp) => exports._globalState.nextManagerId = dart.notNul
l($tmp) + 1, $tmp).bind(this)(exports._globalState.nextManagerId); | 1028 let workerId = ((x) => exports._globalState.nextManagerId = dart.notNull(x
$) + 1, x$).bind(this)(exports._globalState.nextManagerId); |
1029 workerIds.set(worker, workerId); | 1029 workerIds.set(worker, workerId); |
1030 exports._globalState.managers.set(workerId, worker); | 1030 exports._globalState.managers.set(workerId, worker); |
1031 worker.postMessage(_serializeMessage(dart.map({command: 'start', id: worke
rId, replyTo: _serializeMessage(replyPort), args: args, msg: _serializeMessage(m
essage), isSpawnUri: isSpawnUri, startPaused: startPaused, functionName: functio
nName}))); | 1031 worker.postMessage(_serializeMessage(dart.map({command: 'start', id: worke
rId, replyTo: _serializeMessage(replyPort), args: args, msg: _serializeMessage(m
essage), isSpawnUri: isSpawnUri, startPaused: startPaused, functionName: functio
nName}))); |
1032 } | 1032 } |
1033 static workerOnError(event, uri, onError) { | 1033 static workerOnError(event, uri, onError) { |
1034 event.preventDefault(); | 1034 event.preventDefault(); |
1035 let message = dart.as(event.message, core.String); | 1035 let message = dart.as(event.message, core.String); |
1036 if (message === null) { | 1036 if (message === null) { |
1037 message = `Error spawning worker for ${uri}`; | 1037 message = `Error spawning worker for ${uri}`; |
1038 } else { | 1038 } else { |
1039 message = `Error spawning worker for ${uri} (${message})`; | 1039 message = `Error spawning worker for ${uri} (${message})`; |
1040 } | 1040 } |
1041 onError(message); | 1041 onError(message); |
1042 return true; | 1042 return true; |
1043 } | 1043 } |
1044 } | 1044 } |
1045 IsolateNatives.enableSpawnWorker = null; | 1045 IsolateNatives.enableSpawnWorker = null; |
1046 dart.defineLazyProperties(IsolateNatives, { | 1046 dart.defineLazyProperties(IsolateNatives, { |
1047 get thisScript() { | 1047 get thisScript() { |
1048 return computeThisScript(); | 1048 return computeThisScript(); |
1049 }, | 1049 }, |
1050 set thisScript(_) {}, | 1050 set thisScript(_) {}, |
1051 get workerIds() { | 1051 get workerIds() { |
1052 return new core.Expando(); | 1052 return new core.Expando(); |
1053 } | 1053 } |
1054 }); | 1054 }); |
1055 let _checkReplyTo = Symbol('_checkReplyTo'); | 1055 let _checkReplyTo = Symbol('_checkReplyTo'); |
1056 class _BaseSendPort extends core.Object { | 1056 class _BaseSendPort extends core.Object { |
1057 _BaseSendPort($_isolateId) { | 1057 _BaseSendPort(isolateId$) { |
1058 this[_isolateId] = $_isolateId; | 1058 this[_isolateId] = isolateId$; |
1059 } | 1059 } |
1060 [_checkReplyTo](replyTo) { | 1060 [_checkReplyTo](replyTo) { |
1061 if (dart.notNull(replyTo !== null) && dart.notNull(!dart.is(replyTo, _Nati
veJsSendPort)) && dart.notNull(!dart.is(replyTo, _WorkerSendPort))) { | 1061 if (dart.notNull(replyTo !== null) && dart.notNull(!dart.is(replyTo, _Nati
veJsSendPort)) && dart.notNull(!dart.is(replyTo, _WorkerSendPort))) { |
1062 throw new core.Exception("SendPort.send: Illegal replyTo port type"); | 1062 throw new core.Exception("SendPort.send: Illegal replyTo port type"); |
1063 } | 1063 } |
1064 } | 1064 } |
1065 } | 1065 } |
1066 let _isClosed = Symbol('_isClosed'); | 1066 let _isClosed = Symbol('_isClosed'); |
1067 class _NativeJsSendPort extends _BaseSendPort { | 1067 class _NativeJsSendPort extends _BaseSendPort { |
1068 _NativeJsSendPort($_receivePort, isolateId) { | 1068 _NativeJsSendPort(receivePort$, isolateId) { |
1069 this[_receivePort] = $_receivePort; | 1069 this[_receivePort] = receivePort$; |
1070 super._BaseSendPort(isolateId); | 1070 super._BaseSendPort(isolateId); |
1071 } | 1071 } |
1072 send(message) { | 1072 send(message) { |
1073 let isolate = exports._globalState.isolates.get(this[_isolateId]); | 1073 let isolate = exports._globalState.isolates.get(this[_isolateId]); |
1074 if (isolate === null) | 1074 if (isolate === null) |
1075 return; | 1075 return; |
1076 if (this[_receivePort][_isClosed]) | 1076 if (this[_receivePort][_isClosed]) |
1077 return; | 1077 return; |
1078 let msg = _clone(message); | 1078 let msg = _clone(message); |
1079 if (dart.equals(isolate.controlPort, this[_receivePort])) { | 1079 if (dart.equals(isolate.controlPort, this[_receivePort])) { |
1080 isolate.handleControlMessage(msg); | 1080 isolate.handleControlMessage(msg); |
1081 return; | 1081 return; |
1082 } | 1082 } |
1083 exports._globalState.topEventLoop.enqueue(isolate, (() => { | 1083 exports._globalState.topEventLoop.enqueue(isolate, (() => { |
1084 if (!dart.notNull(this[_receivePort][_isClosed])) { | 1084 if (!dart.notNull(this[_receivePort][_isClosed])) { |
1085 this[_receivePort]._add(msg); | 1085 this[_receivePort]._add(msg); |
1086 } | 1086 } |
1087 }).bind(this), `receive ${message}`); | 1087 }).bind(this), `receive ${message}`); |
1088 } | 1088 } |
1089 ['=='](other) { | 1089 ['=='](other) { |
1090 return dart.notNull(dart.is(other, _NativeJsSendPort)) && dart.notNull(dar
t.equals(this[_receivePort], dart.dload(other, '_receivePort'))); | 1090 return dart.notNull(dart.is(other, _NativeJsSendPort)) && dart.notNull(dar
t.equals(this[_receivePort], dart.dload(other, '_receivePort'))); |
1091 } | 1091 } |
1092 get hashCode() { | 1092 get hashCode() { |
1093 return this[_receivePort][_id]; | 1093 return this[_receivePort][_id]; |
1094 } | 1094 } |
1095 } | 1095 } |
1096 class _WorkerSendPort extends _BaseSendPort { | 1096 class _WorkerSendPort extends _BaseSendPort { |
1097 _WorkerSendPort($_workerId, isolateId, $_receivePortId) { | 1097 _WorkerSendPort(workerId$, isolateId, receivePortId$) { |
1098 this[_workerId] = $_workerId; | 1098 this[_workerId] = workerId$; |
1099 this[_receivePortId] = $_receivePortId; | 1099 this[_receivePortId] = receivePortId$; |
1100 super._BaseSendPort(isolateId); | 1100 super._BaseSendPort(isolateId); |
1101 } | 1101 } |
1102 send(message) { | 1102 send(message) { |
1103 let workerMessage = _serializeMessage(dart.map({command: 'message', port:
this, msg: message})); | 1103 let workerMessage = _serializeMessage(dart.map({command: 'message', port:
this, msg: message})); |
1104 if (exports._globalState.isWorker) { | 1104 if (exports._globalState.isWorker) { |
1105 exports._globalState.mainManager.postMessage(workerMessage); | 1105 exports._globalState.mainManager.postMessage(workerMessage); |
1106 } else { | 1106 } else { |
1107 let manager = exports._globalState.managers.get(this[_workerId]); | 1107 let manager = exports._globalState.managers.get(this[_workerId]); |
1108 if (manager !== null) { | 1108 if (manager !== null) { |
1109 manager.postMessage(workerMessage); | 1109 manager.postMessage(workerMessage); |
1110 } | 1110 } |
1111 } | 1111 } |
1112 } | 1112 } |
1113 ['=='](other) { | 1113 ['=='](other) { |
1114 return dart.notNull(dart.is(other, _WorkerSendPort)) && this[_workerId] ==
= dart.dload(other, '_workerId') && this[_isolateId] === dart.dload(other, '_iso
lateId') && this[_receivePortId] === dart.dload(other, '_receivePortId'); | 1114 return dart.notNull(dart.is(other, _WorkerSendPort)) && this[_workerId] ==
= dart.dload(other, '_workerId') && this[_isolateId] === dart.dload(other, '_iso
lateId') && this[_receivePortId] === dart.dload(other, '_receivePortId'); |
1115 } | 1115 } |
1116 get hashCode() { | 1116 get hashCode() { |
1117 return dart.notNull(this[_workerId]) << 16 ^ dart.notNull(this[_isolateId]
) << 8 ^ dart.notNull(this[_receivePortId]); | 1117 return dart.notNull(this[_workerId]) << 16 ^ dart.notNull(this[_isolateId]
) << 8 ^ dart.notNull(this[_receivePortId]); |
1118 } | 1118 } |
1119 } | 1119 } |
1120 let _handler = Symbol('_handler'); | 1120 let _handler = Symbol('_handler'); |
1121 let _close = Symbol('_close'); | 1121 let _close = Symbol('_close'); |
1122 let _add = Symbol('_add'); | 1122 let _add = Symbol('_add'); |
1123 class RawReceivePortImpl extends core.Object { | 1123 class RawReceivePortImpl extends core.Object { |
1124 RawReceivePortImpl($_handler) { | 1124 RawReceivePortImpl(handler) { |
1125 this[_handler] = $_handler; | 1125 this[_handler] = handler; |
1126 this[_id] = (($tmp) => _nextFreeId = dart.notNull($tmp) + 1, $tmp)(_nextFr
eeId); | 1126 this[_id] = ((x) => _nextFreeId = dart.notNull(x$) + 1, x$)(_nextFreeId); |
1127 this[_isClosed] = false; | 1127 this[_isClosed] = false; |
1128 exports._globalState.currentContext.register(this[_id], this); | 1128 exports._globalState.currentContext.register(this[_id], this); |
1129 } | 1129 } |
1130 RawReceivePortImpl$weak($_handler) { | 1130 RawReceivePortImpl$weak(handler) { |
1131 this[_handler] = $_handler; | 1131 this[_handler] = handler; |
1132 this[_id] = (($tmp) => _nextFreeId = dart.notNull($tmp) + 1, $tmp)(_nextFr
eeId); | 1132 this[_id] = ((x) => _nextFreeId = dart.notNull(x$) + 1, x$)(_nextFreeId); |
1133 this[_isClosed] = false; | 1133 this[_isClosed] = false; |
1134 exports._globalState.currentContext.registerWeak(this[_id], this); | 1134 exports._globalState.currentContext.registerWeak(this[_id], this); |
1135 } | 1135 } |
1136 RawReceivePortImpl$_controlPort() { | 1136 RawReceivePortImpl$_controlPort() { |
1137 this[_handler] = null; | 1137 this[_handler] = null; |
1138 this[_id] = 0; | 1138 this[_id] = 0; |
1139 this[_isClosed] = false; | 1139 this[_isClosed] = false; |
1140 } | 1140 } |
1141 set handler(newHandler) { | 1141 set handler(newHandler) { |
1142 this[_handler] = newHandler; | 1142 this[_handler] = newHandler; |
(...skipping 23 matching lines...) Expand all Loading... |
1166 RawReceivePortImpl._nextFreeId = 1; | 1166 RawReceivePortImpl._nextFreeId = 1; |
1167 let _rawPort = Symbol('_rawPort'); | 1167 let _rawPort = Symbol('_rawPort'); |
1168 let _controller = Symbol('_controller'); | 1168 let _controller = Symbol('_controller'); |
1169 class ReceivePortImpl extends async.Stream { | 1169 class ReceivePortImpl extends async.Stream { |
1170 ReceivePortImpl() { | 1170 ReceivePortImpl() { |
1171 this.ReceivePortImpl$fromRawReceivePort(new RawReceivePortImpl(null)); | 1171 this.ReceivePortImpl$fromRawReceivePort(new RawReceivePortImpl(null)); |
1172 } | 1172 } |
1173 ReceivePortImpl$weak() { | 1173 ReceivePortImpl$weak() { |
1174 this.ReceivePortImpl$fromRawReceivePort(new RawReceivePortImpl.weak(null))
; | 1174 this.ReceivePortImpl$fromRawReceivePort(new RawReceivePortImpl.weak(null))
; |
1175 } | 1175 } |
1176 ReceivePortImpl$fromRawReceivePort($_rawPort) { | 1176 ReceivePortImpl$fromRawReceivePort(rawPort) { |
1177 this[_rawPort] = $_rawPort; | 1177 this[_rawPort] = rawPort; |
1178 this[_controller] = null; | 1178 this[_controller] = null; |
1179 super.Stream(); | 1179 super.Stream(); |
1180 this[_controller] = new async.StreamController({onCancel: this.close, sync
: true}); | 1180 this[_controller] = new async.StreamController({onCancel: this.close, sync
: true}); |
1181 this[_rawPort].handler = this[_controller].add; | 1181 this[_rawPort].handler = this[_controller].add; |
1182 } | 1182 } |
1183 listen(onData, opt$) { | 1183 listen(onData, opts) { |
1184 let onError = opt$ && 'onError' in opt$ ? opt$.onError : null; | 1184 let onError = opts && 'onError' in opts ? opts.onError : null; |
1185 let onDone = opt$ && 'onDone' in opt$ ? opt$.onDone : null; | 1185 let onDone = opts && 'onDone' in opts ? opts.onDone : null; |
1186 let cancelOnError = opt$ && 'cancelOnError' in opt$ ? opt$.cancelOnError :
null; | 1186 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError :
null; |
1187 return this[_controller].stream.listen(onData, {onError: onError, onDone:
onDone, cancelOnError: cancelOnError}); | 1187 return this[_controller].stream.listen(onData, {onError: onError, onDone:
onDone, cancelOnError: cancelOnError}); |
1188 } | 1188 } |
1189 close() { | 1189 close() { |
1190 this[_rawPort].close(); | 1190 this[_rawPort].close(); |
1191 this[_controller].close(); | 1191 this[_controller].close(); |
1192 } | 1192 } |
1193 get sendPort() { | 1193 get sendPort() { |
1194 return this[_rawPort].sendPort; | 1194 return this[_rawPort].sendPort; |
1195 } | 1195 } |
1196 } | 1196 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 dart.defineNamedConstructor(TimerImpl, 'periodic'); | 1265 dart.defineNamedConstructor(TimerImpl, 'periodic'); |
1266 // Function hasTimer: () → bool | 1266 // Function hasTimer: () → bool |
1267 function hasTimer() { | 1267 function hasTimer() { |
1268 _js_helper.requiresPreamble(); | 1268 _js_helper.requiresPreamble(); |
1269 return self.setTimeout !== null; | 1269 return self.setTimeout !== null; |
1270 } | 1270 } |
1271 class CapabilityImpl extends core.Object { | 1271 class CapabilityImpl extends core.Object { |
1272 CapabilityImpl() { | 1272 CapabilityImpl() { |
1273 this.CapabilityImpl$_internal(_js_helper.random64()); | 1273 this.CapabilityImpl$_internal(_js_helper.random64()); |
1274 } | 1274 } |
1275 CapabilityImpl$_internal($_id) { | 1275 CapabilityImpl$_internal(id) { |
1276 this[_id] = $_id; | 1276 this[_id] = id; |
1277 } | 1277 } |
1278 get hashCode() { | 1278 get hashCode() { |
1279 let hash = this[_id]; | 1279 let hash = this[_id]; |
1280 hash = dart.notNull(hash) >> 0 ^ (dart.notNull(hash) / 4294967296).truncat
e(); | 1280 hash = dart.notNull(hash) >> 0 ^ (dart.notNull(hash) / 4294967296).truncat
e(); |
1281 hash = ~dart.notNull(hash) + (dart.notNull(hash) << 15) & 4294967295; | 1281 hash = ~dart.notNull(hash) + (dart.notNull(hash) << 15) & 4294967295; |
1282 hash = dart.notNull(hash) >> 12; | 1282 hash = dart.notNull(hash) >> 12; |
1283 hash = dart.notNull(hash) * 5 & 4294967295; | 1283 hash = dart.notNull(hash) * 5 & 4294967295; |
1284 hash = dart.notNull(hash) >> 4; | 1284 hash = dart.notNull(hash) >> 4; |
1285 hash = dart.notNull(hash) * 2057 & 4294967295; | 1285 hash = dart.notNull(hash) * 2057 & 4294967295; |
1286 hash = dart.notNull(hash) >> 16; | 1286 hash = dart.notNull(hash) >> 16; |
(...skipping 14 matching lines...) Expand all Loading... |
1301 exports.leaveJsAsync = leaveJsAsync; | 1301 exports.leaveJsAsync = leaveJsAsync; |
1302 exports.isWorker = isWorker; | 1302 exports.isWorker = isWorker; |
1303 exports.startRootIsolate = startRootIsolate; | 1303 exports.startRootIsolate = startRootIsolate; |
1304 exports.IsolateNatives = IsolateNatives; | 1304 exports.IsolateNatives = IsolateNatives; |
1305 exports.RawReceivePortImpl = RawReceivePortImpl; | 1305 exports.RawReceivePortImpl = RawReceivePortImpl; |
1306 exports.ReceivePortImpl = ReceivePortImpl; | 1306 exports.ReceivePortImpl = ReceivePortImpl; |
1307 exports.TimerImpl = TimerImpl; | 1307 exports.TimerImpl = TimerImpl; |
1308 exports.hasTimer = hasTimer; | 1308 exports.hasTimer = hasTimer; |
1309 exports.CapabilityImpl = CapabilityImpl; | 1309 exports.CapabilityImpl = CapabilityImpl; |
1310 })(_isolate_helper || (_isolate_helper = {})); | 1310 })(_isolate_helper || (_isolate_helper = {})); |
OLD | NEW |