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

Unified Diff: src/d8.js

Issue 1543803002: Revert of [proxies] Better print for proxies in d8 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 c375d20698ba10e7185c373351e04979332864f5..8d55c788e2b42fa0d591ed146316c2c29dd9f365 100644
--- a/src/d8.js
+++ b/src/d8.js
@@ -13,9 +13,6 @@
depth = stringifyDepthLimit;
else if (depth === 0)
return "*";
- if (IS_PROXY(x)) {
- return StringifyProxy(x, depth);
- }
switch (typeof x) {
case "undefined":
return "undefined";
@@ -29,56 +26,40 @@
return x.toString();
case "object":
if (IS_NULL(x)) return "null";
+ if (x.constructor && x.constructor.name === "Array") {
+ var elems = [];
+ for (var i = 0; i < x.length; ++i) {
+ elems.push(
+ {}.hasOwnProperty.call(x, i) ? Stringify(x[i], depth - 1) : "");
+ }
+ return "[" + elems.join(", ") + "]";
+ }
try {
- return StringifyObject(x, depth);
- } catch(RangeError) {
- return "{*}"
+ var string = String(x);
+ if (string && string !== "[object Object]") return string;
+ } catch(e) {}
+ var props = [];
+ var names = Object.getOwnPropertyNames(x);
+ names = names.concat(Object.getOwnPropertySymbols(x));
+ for (var i in names) {
+ var name = names[i];
+ var desc = Object.getOwnPropertyDescriptor(x, name);
+ if (IS_UNDEFINED(desc)) continue;
+ if (IS_SYMBOL(name)) name = "[" + Stringify(name) + "]";
+ if ("value" in desc) {
+ props.push(name + ": " + Stringify(desc.value, depth - 1));
+ }
+ if (desc.get) {
+ var getter = Stringify(desc.get);
+ props.push("get " + name + getter.slice(getter.indexOf('(')));
+ }
+ if (desc.set) {
+ var setter = Stringify(desc.set);
+ props.push("set " + name + setter.slice(setter.indexOf('(')));
+ }
}
+ return "{" + props.join(", ") + "}";
default:
return "[crazy non-standard value]";
}
}
-
-function StringifyObject(x, depth) {
- if (x.constructor && x.constructor.name === "Array") {
- var elems = [];
- for (var i = 0; i < x.length; ++i) {
- elems.push(
- {}.hasOwnProperty.call(x, i) ? Stringify(x[i], depth - 1) : "");
- }
- return "[" + elems.join(", ") + "]";
- }
- try {
- var string = String(x);
- if (string && string !== "[object Object]") return string;
- } catch(e) {}
- var props = [];
- var names = Object.getOwnPropertyNames(x);
- names = names.concat(Object.getOwnPropertySymbols(x));
- for (var i in names) {
- var name = names[i];
- var desc = Object.getOwnPropertyDescriptor(x, name);
- if (IS_UNDEFINED(desc)) continue;
- if (IS_SYMBOL(name)) name = "[" + Stringify(name) + "]";
- if ("value" in desc) {
- props.push(name + ": " + Stringify(desc.value, depth - 1));
- }
- if (desc.get) {
- var getter = Stringify(desc.get);
- props.push("get " + name + getter.slice(getter.indexOf('(')));
- }
- if (desc.set) {
- var setter = Stringify(desc.set);
- props.push("set " + name + setter.slice(setter.indexOf('(')));
- }
- }
- return "{" + props.join(", ") + "}";
-}
-
-function StringifyProxy(proxy, depth) {
- var proxy_type = typeof proxy;
- return '[' + proxy_type + ' Proxy ' + Stringify({
- target: %JSProxyGetTarget(proxy),
- handler: %JSProxyGetHandler(proxy)
- }, 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