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 dart._isolate_helper; | 5 library dart._isolate_helper; |
6 | 6 |
7 import 'dart:_js_embedded_names' show | 7 import 'dart:_js_embedded_names' show |
8 CLASS_ID_EXTRACTOR, | 8 CLASS_ID_EXTRACTOR, |
9 CLASS_FIELDS_EXTRACTOR, | 9 CLASS_FIELDS_EXTRACTOR, |
10 CURRENT_SCRIPT, | 10 CURRENT_SCRIPT, |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 static String computeThisScript() { | 749 static String computeThisScript() { |
750 // See: https://github.com/dart-lang/dev_compiler/issues/164 | 750 // See: https://github.com/dart-lang/dev_compiler/issues/164 |
751 // var currentScript = JS_EMBEDDED_GLOBAL('', CURRENT_SCRIPT); | 751 // var currentScript = JS_EMBEDDED_GLOBAL('', CURRENT_SCRIPT); |
752 var currentScript = JS('var', 'document.currentScript'); | 752 var currentScript = JS('var', 'document.currentScript'); |
753 if (currentScript != null) { | 753 if (currentScript != null) { |
754 return JS('String', 'String(#.src)', currentScript); | 754 return JS('String', 'String(#.src)', currentScript); |
755 } | 755 } |
756 if (Primitives.isD8) return computeThisScriptD8(); | 756 if (Primitives.isD8) return computeThisScriptD8(); |
757 if (Primitives.isJsshell) return computeThisScriptJsshell(); | 757 if (Primitives.isJsshell) return computeThisScriptJsshell(); |
758 // A worker has no script tag - so get an url from a stack-trace. | 758 // A worker has no script tag - so get an url from a stack-trace. |
759 if (_globalState.isWorker) return computeThisScriptFromTrace(); | 759 if (_globalState != null && _globalState.isWorker) { |
| 760 return computeThisScriptFromTrace(); |
| 761 } |
760 return null; | 762 return null; |
761 } | 763 } |
762 | 764 |
763 static String computeThisScriptJsshell() { | 765 static String computeThisScriptJsshell() { |
764 return JS('String|Null', 'thisFilename()'); | 766 return JS('String|Null', 'thisFilename()'); |
765 } | 767 } |
766 | 768 |
767 // TODO(ahe): The following is for supporting D8. We should move this code | 769 // TODO(ahe): The following is for supporting D8. We should move this code |
768 // to a helper library that is only loaded when testing on D8. | 770 // to a helper library that is only loaded when testing on D8. |
769 static String computeThisScriptD8() => computeThisScriptFromTrace(); | 771 static String computeThisScriptD8() => computeThisScriptFromTrace(); |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 } | 1441 } |
1440 | 1442 |
1441 bool operator==(Object other) { | 1443 bool operator==(Object other) { |
1442 if (identical(other, this)) return true; | 1444 if (identical(other, this)) return true; |
1443 if (other is CapabilityImpl) { | 1445 if (other is CapabilityImpl) { |
1444 return identical(_id, other._id); | 1446 return identical(_id, other._id); |
1445 } | 1447 } |
1446 return false; | 1448 return false; |
1447 } | 1449 } |
1448 } | 1450 } |
OLD | NEW |