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

Unified Diff: src/d8.js

Issue 388243002: Fix d8 object printing (symbols, accessors) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 months 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 | no next file » | 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 10546c289f02e530a77c468949ed878e90e42c6a..1e64b3c50dfd38f8318bcf7f233f570665c912c4 100644
--- a/src/d8.js
+++ b/src/d8.js
@@ -1980,7 +1980,7 @@ function Stringify(x, depth) {
case "string":
return "\"" + x.toString() + "\"";
case "symbol":
- return "Symbol(" + (x.name ? Stringify(x.name, depth) : "") + ")"
+ return x.toString();
case "object":
if (IS_NULL(x)) return "null";
if (x.constructor && x.constructor.name === "Array") {
@@ -1996,18 +1996,25 @@ function Stringify(x, depth) {
if (string && string !== "[object Object]") return string;
} catch(e) {}
var props = [];
- for (var name in x) {
+ var names = Object.getOwnPropertyNames(x);
+ if (Object.getOwnPropertySymbols) {
+ // FLAG_harmony_symbols is turned on.
+ 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 ("get" in desc) {
- var getter = desc.get.toString();
+ if (desc.get) {
+ var getter = Stringify(desc.get);
props.push("get " + name + getter.slice(getter.indexOf('(')));
}
- if ("set" in desc) {
- var setter = desc.set.toString();
+ if (desc.set) {
+ var setter = Stringify(desc.set);
props.push("set " + name + setter.slice(setter.indexOf('(')));
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698