Index: sdk/lib/_internal/js_runtime/lib/core_patch.dart |
diff --git a/sdk/lib/_internal/js_runtime/lib/core_patch.dart b/sdk/lib/_internal/js_runtime/lib/core_patch.dart |
index 301517ee669f5a532008375f12048c4f37bc0ba0..2e1037e90c3898166ad5923260dbd71698ada91d 100644 |
--- a/sdk/lib/_internal/js_runtime/lib/core_patch.dart |
+++ b/sdk/lib/_internal/js_runtime/lib/core_patch.dart |
@@ -5,21 +5,22 @@ |
// Patch file for dart:core classes. |
import "dart:_internal" as _symbol_dev; |
import 'dart:_interceptors'; |
-import 'dart:_js_helper' show patch, |
- patch_full, |
- patch_lazy, |
- patch_startup, |
- checkInt, |
+import 'dart:_js_helper' show checkInt, |
+ Closure, |
+ ConstantMap, |
getRuntimeType, |
+ JsLinkedHashMap; |
jsonEncodeNative, |
JSSyntaxRegExp, |
- Primitives, |
- ConstantMap, |
- stringJoinUnchecked, |
+ NoInline, |
objectHashCode, |
- Closure, |
+ patch, |
+ patch_full, |
+ patch_lazy, |
+ patch_startup, |
+ Primitives, |
readHttp, |
- JsLinkedHashMap; |
+ stringJoinUnchecked, |
import 'dart:_foreign_helper' show JS; |
@@ -671,3 +672,24 @@ class _Resource implements Resource { |
}); |
} |
} |
+ |
+@patch |
+class StackTrace { |
+ @patch |
+ @NoInline() |
+ static StackTrace get current { |
+ var error = JS('', 'new Error()'); |
+ var stack = JS('String|Null', '#.stack', error); |
+ if (stack is String) return new StackTrace.fromString(stack); |
+ if (JS('', 'Error.captureStackTrace') != null) { |
+ JS('void', 'Error.captureStackTrace(#)', error); |
+ var stack = JS('String|Null', '#.stack', error); |
+ if (stack is String) return new StackTrace.fromString(stack); |
+ } |
+ try { |
+ throw 0; |
+ } catch (_, stackTrace) { |
+ return stackTrace; |
+ } |
+ } |
+} |