| 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 library _isolate_helper; | 5 library _isolate_helper; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection' show Queue, HashMap; | 8 import 'dart:collection' show Queue, HashMap; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 import 'dart:_js_helper' show convertDartClosureToJS, | 10 import 'dart:_js_helper' show convertDartClosureToJS, |
| 11 Null; | 11 Null; |
| 12 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, | 12 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, |
| 13 JS, | 13 JS, |
| 14 JS_CREATE_ISOLATE, | 14 JS_CREATE_ISOLATE, |
| 15 JS_CURRENT_ISOLATE_CONTEXT, | 15 JS_CURRENT_ISOLATE_CONTEXT, |
| 16 JS_CURRENT_ISOLATE, | 16 JS_CURRENT_ISOLATE, |
| 17 JS_SET_CURRENT_ISOLATE, | 17 JS_SET_CURRENT_ISOLATE, |
| 18 IsolateContext; | 18 IsolateContext; |
| 19 import 'dart:_interceptors' show JSExtendableArray; |
| 19 | 20 |
| 20 ReceivePort lazyPort; | 21 ReceivePort lazyPort; |
| 21 | 22 |
| 22 class CloseToken { | 23 class CloseToken { |
| 23 /// This token is sent from [IsolateSink]s to [IsolateStream]s to ask them to | 24 /// This token is sent from [IsolateSink]s to [IsolateStream]s to ask them to |
| 24 /// close themselves. | 25 /// close themselves. |
| 25 const CloseToken(); | 26 const CloseToken(); |
| 26 } | 27 } |
| 27 | 28 |
| 28 class JsIsolateSink extends EventSink<dynamic> implements IsolateSink { | 29 class JsIsolateSink extends EventSink<dynamic> implements IsolateSink { |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 var pattern, matches; | 449 var pattern, matches; |
| 449 | 450 |
| 450 // This pattern matches V8, Chrome, and Internet Explorer stack | 451 // This pattern matches V8, Chrome, and Internet Explorer stack |
| 451 // traces that look like this: | 452 // traces that look like this: |
| 452 // Error | 453 // Error |
| 453 // at methodName (URI:LINE:COLUMN) | 454 // at methodName (URI:LINE:COLUMN) |
| 454 pattern = JS('', | 455 pattern = JS('', |
| 455 r'new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m")'); | 456 r'new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m")'); |
| 456 | 457 |
| 457 | 458 |
| 458 matches = JS('=List|Null', '#.match(#)', stack, pattern); | 459 matches = JS('JSExtendableArray|Null', '#.match(#)', stack, pattern); |
| 459 if (matches != null) return JS('String', '#[1]', matches); | 460 if (matches != null) return JS('String', '#[1]', matches); |
| 460 | 461 |
| 461 // This pattern matches Firefox stack traces that look like this: | 462 // This pattern matches Firefox stack traces that look like this: |
| 462 // methodName@URI:LINE | 463 // methodName@URI:LINE |
| 463 pattern = JS('', r'new RegExp("^[^@]*@(.*):[0-9]*$", "m")'); | 464 pattern = JS('', r'new RegExp("^[^@]*@(.*):[0-9]*$", "m")'); |
| 464 | 465 |
| 465 matches = JS('=List|Null', '#.match(#)', stack, pattern); | 466 matches = JS('JSExtendableArray|Null', '#.match(#)', stack, pattern); |
| 466 if (matches != null) return JS('String', '#[1]', matches); | 467 if (matches != null) return JS('String', '#[1]', matches); |
| 467 | 468 |
| 468 throw new UnsupportedError('Cannot extract URI from "$stack"'); | 469 throw new UnsupportedError('Cannot extract URI from "$stack"'); |
| 469 } | 470 } |
| 470 | 471 |
| 471 static computeGlobalThis() => JS('', 'function() { return this; }()'); | 472 static computeGlobalThis() => JS('', 'function() { return this; }()'); |
| 472 | 473 |
| 473 /** | 474 /** |
| 474 * Assume that [e] is a browser message event and extract its message data. | 475 * Assume that [e] is a browser message event and extract its message data. |
| 475 * We don't import the dom explicitly so, when workers are disabled, this | 476 * We don't import the dom explicitly so, when workers are disabled, this |
| (...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 JS('void', '#.clearInterval(#)', globalThis, _handle); | 1412 JS('void', '#.clearInterval(#)', globalThis, _handle); |
| 1412 } | 1413 } |
| 1413 _handle = null; | 1414 _handle = null; |
| 1414 } else { | 1415 } else { |
| 1415 throw new UnsupportedError("Canceling a timer."); | 1416 throw new UnsupportedError("Canceling a timer."); |
| 1416 } | 1417 } |
| 1417 } | 1418 } |
| 1418 } | 1419 } |
| 1419 | 1420 |
| 1420 bool hasTimer() => JS('', '#.setTimeout', globalThis) != null; | 1421 bool hasTimer() => JS('', '#.setTimeout', globalThis) != null; |
| OLD | NEW |