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

Side by Side Diff: tools/detect-builtins.js

Issue 2048593004: [tools] Fix detect-builtins.js (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global) { 5 (function(global) {
6 6
7 var GetProperties = function(this_name, object) { 7 var GetProperties = function(this_name, object) {
8 var result = {}; 8 var result = {};
9 try { 9 try {
10 var names = Object.getOwnPropertyNames(object); 10 var names = Object.getOwnPropertyNames(object);
11 } catch(e) { 11 } catch(e) {
12 return; 12 return;
13 } 13 }
14 for (var i = 0; i < names.length; ++i) { 14 for (var i = 0; i < names.length; ++i) {
15 var name = names[i]; 15 var name = names[i];
16 if (typeof object === "function") { 16 if (typeof object === "function") {
17 if (name === "length" || 17 if (name === "length" ||
18 name === "name" || 18 name === "name" ||
19 name === "arguments" || 19 name === "arguments" ||
20 name === "caller" || 20 name === "caller" ||
21 name === "prototype") { 21 name === "prototype") {
22 continue; 22 continue;
23 } 23 }
24 } 24 }
25 // Avoid endless recursion. 25 // Avoid endless recursion.
26 if (this_name === "prototype" && name === "constructor") continue; 26 if (this_name === "prototype" && name === "constructor") continue;
27 // Avoid needless duplication.
28 if (this_name === "__PROTO__" && name === "constructor") continue;
27 // Could get this from the parent, but having it locally is easier. 29 // Could get this from the parent, but having it locally is easier.
28 var property = { "name": name }; 30 var property = { "name": name };
29 try { 31 try {
30 var value = object[name]; 32 var value = object[name];
31 } catch(e) { 33 } catch(e) {
32 property.type = "getter"; 34 property.type = "getter";
33 result[name] = property; 35 result[name] = property;
34 continue; 36 continue;
35 } 37 }
36 var type = typeof value; 38 var type = typeof value;
37 property.type = type; 39 property.type = type;
38 if (type === "function") { 40 if (type === "function") {
39 property.length = value.length; 41 property.length = value.length;
40 property.prototype = GetProperties("prototype", value.prototype); 42 property.prototype = GetProperties("prototype", value.prototype);
41 } 43 }
42 property.properties = GetProperties(name, value); 44 if (type === "string" || type === "number") {
45 property.value = value;
46 } else {
47 property.properties = GetProperties(name, value);
48 }
43 result[name] = property; 49 result[name] = property;
44 } 50 }
51 // Print the __proto__ if it's not the default Object prototype.
52 if (typeof object === "object" && object.__proto__ !== null &&
53 !object.__proto__.hasOwnProperty("__proto__")) {
54 result.__PROTO__ = GetProperties("__PROTO__", object.__proto__);
55 }
45 return result; 56 return result;
46 }; 57 };
47 58
48 var g = GetProperties("", global, ""); 59 var g = GetProperties("", global, "");
49 print(JSON.stringify(g, undefined, 2)); 60 print(JSON.stringify(g, undefined, 2));
50 61
51 })(this); // Must wrap in anonymous closure or it'll detect itself as builtin. 62 })(this); // Must wrap in anonymous closure or it'll detect itself as builtin.
OLDNEW
« 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