Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Unified Diff: sdk/lib/_internal/js_runtime/lib/core_patch.dart

Issue 1448003002: Add StackTrace.current getter. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address VM comments. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | sdk/lib/core/stacktrace.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+ }
+ }
+}
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | sdk/lib/core/stacktrace.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698