Commit 3fade8e4 authored by rossberg@chromium.org's avatar rossberg@chromium.org

Fix d8 object printing (symbols, accessors)

R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/388243002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22380 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent aa7198df
...@@ -1980,7 +1980,7 @@ function Stringify(x, depth) { ...@@ -1980,7 +1980,7 @@ function Stringify(x, depth) {
case "string": case "string":
return "\"" + x.toString() + "\""; return "\"" + x.toString() + "\"";
case "symbol": case "symbol":
return "Symbol(" + (x.name ? Stringify(x.name, depth) : "") + ")" return x.toString();
case "object": case "object":
if (IS_NULL(x)) return "null"; if (IS_NULL(x)) return "null";
if (x.constructor && x.constructor.name === "Array") { if (x.constructor && x.constructor.name === "Array") {
...@@ -1996,18 +1996,25 @@ function Stringify(x, depth) { ...@@ -1996,18 +1996,25 @@ function Stringify(x, depth) {
if (string && string !== "[object Object]") return string; if (string && string !== "[object Object]") return string;
} catch(e) {} } catch(e) {}
var props = []; 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); var desc = Object.getOwnPropertyDescriptor(x, name);
if (IS_UNDEFINED(desc)) continue; if (IS_UNDEFINED(desc)) continue;
if (IS_SYMBOL(name)) name = "[" + Stringify(name) + "]";
if ("value" in desc) { if ("value" in desc) {
props.push(name + ": " + Stringify(desc.value, depth - 1)); props.push(name + ": " + Stringify(desc.value, depth - 1));
} }
if ("get" in desc) { if (desc.get) {
var getter = desc.get.toString(); var getter = Stringify(desc.get);
props.push("get " + name + getter.slice(getter.indexOf('('))); props.push("get " + name + getter.slice(getter.indexOf('(')));
} }
if ("set" in desc) { if (desc.set) {
var setter = desc.set.toString(); var setter = Stringify(desc.set);
props.push("set " + name + setter.slice(setter.indexOf('('))); props.push("set " + name + setter.slice(setter.indexOf('(')));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment