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

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: do not expose intrinsics directly 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/collection.js » ('j') | no next file with comments »
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..27a0bc39cd07107cb03fa65f0c12534aed45573a 100644
--- a/src/d8.js
+++ b/src/d8.js
@@ -8,11 +8,28 @@
// Used by the d8 shell to output results.
var stringifyDepthLimit = 4; // To avoid crashing on cyclic objects
+// Hacky solution to circumvent forcing --allow-natives-syntax for d8
caitp (gmail) 2015/12/22 13:21:10 Why not just compile the utility script with --all
+function isProxy(o) { return false };
+function JSProxyGetTarget(proxy) { };
+function JSProxyGetHandler(proxy) { };
+
+try {
+ isProxy = Function(['object'], 'return %_IsJSProxy(object)');
+ JSProxyGetTarget = Function(['proxy'],
+ 'return %JSProxyGetTarget(proxy)');
+ JSProxyGetHandler = Function(['proxy'],
+ 'return %JSProxyGetHandler(proxy)');
+} catch(e) {};
+
+
function Stringify(x, depth) {
if (depth === undefined)
depth = stringifyDepthLimit;
else if (depth === 0)
- return "*";
+ return "...";
+ if (isProxy(x)) {
+ return StringifyProxy(x, depth);
+ }
switch (typeof x) {
case "undefined":
return "undefined";
@@ -63,3 +80,12 @@ function Stringify(x, depth) {
return "[crazy non-standard value]";
}
}
+
+function StringifyProxy(proxy, depth) {
+ var proxy_type = typeof proxy;
+ var info_object = {
+ target: JSProxyGetTarget(proxy),
+ handler: JSProxyGetHandler(proxy)
+ }
+ return '[' + proxy_type + ' Proxy ' + Stringify(info_object, depth-1) + ']';
+}
« no previous file with comments | « no previous file | src/js/collection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698