1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 var GetProperties = function(this_name, object) {
10 var names = Object.getOwnPropertyNames(object);
14 for (var i = 0; i < names.length; ++i) {
16 if (typeof object === "function") {
17 if (name === "length" ||
19 name === "arguments" ||
21 name === "prototype") {
25 // Avoid endless recursion.
26 if (this_name === "prototype" && name === "constructor") continue;
27 // Could get this from the parent, but having it locally is easier.
28 var property = { "name": name };
30 var value = object[name];
32 property.type = "getter";
33 result[name] = property;
36 var type = typeof value;
38 if (type === "function") {
39 property.length = value.length;
40 property.prototype = GetProperties("prototype", value.prototype);
42 property.properties = GetProperties(name, value);
43 result[name] = property;
48 var g = GetProperties("", global, "");
49 print(JSON.stringify(g, undefined, 2));
51 })(this); // Must wrap in anonymous closure or it'll detect itself as builtin.