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

Unified Diff: src/d8.js

Issue 1530293004: [proxies] Better print for proxies in d8 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding macro and fixing printing for infinite __proto__ proxies Created 5 years 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 | « no previous file | src/js/macros.py » ('j') | src/js/macros.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.js
diff --git a/src/d8.js b/src/d8.js
index 8d55c788e2b42fa0d591ed146316c2c29dd9f365..c52d33a5f41f09ca33f048d32566519a363755b6 100644
--- a/src/d8.js
+++ b/src/d8.js
@@ -13,6 +13,9 @@ function Stringify(x, depth) {
depth = stringifyDepthLimit;
else if (depth === 0)
return "*";
+ if (IS_PROXY(x)) {
+ return StringifyProxy(x, depth);
+ }
switch (typeof x) {
case "undefined":
return "undefined";
@@ -63,3 +66,22 @@ function Stringify(x, depth) {
return "[crazy non-standard value]";
}
}
+
+function StringifyProxy(proxy, depth) {
+ var proxy_type = typeof proxy;
+ return '[' + proxy_type + ' Proxy {' +
+ 'target: ' +
+ StringifyProxyInternal(%JSProxyGetTarget(proxy), depth) + ', ' +
+ 'handler: '+
+ StringifyProxyInternal(%JSProxyGetHandler(proxy), depth) +
+ '}]';
+}
+
+function StringifyProxyInternal(object, depth) {
+ // Special case to handle proxy __proto__ recursions on target or handler.
+ try {
+ return Stringify(object, depth-1);
+ } catch(RangeError) {
+ return '{*}'
+ }
+}
« no previous file with comments | « no previous file | src/js/macros.py » ('j') | src/js/macros.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698