OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 return this.substr(0, str.length) == str; | 34 return this.substr(0, str.length) == str; |
35 }; | 35 }; |
36 | 36 |
37 function log10(num) { | 37 function log10(num) { |
38 return Math.log(num)/Math.log(10); | 38 return Math.log(num)/Math.log(10); |
39 } | 39 } |
40 | 40 |
41 function ToInspectableObject(obj) { | 41 function ToInspectableObject(obj) { |
42 if (!obj && typeof obj === 'object') { | 42 if (!obj && typeof obj === 'object') { |
43 return void 0; | 43 return UNDEFINED; |
44 } else { | 44 } else { |
45 return Object(obj); | 45 return Object(obj); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 function GetCompletions(global, last, full) { | 49 function GetCompletions(global, last, full) { |
50 var full_tokens = full.split(); | 50 var full_tokens = full.split(); |
51 full = full_tokens.pop(); | 51 full = full_tokens.pop(); |
52 var parts = full.split('.'); | 52 var parts = full.split('.'); |
53 parts.pop(); | 53 parts.pop(); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 var args; | 326 var args; |
327 if (pos == -1) { | 327 if (pos == -1) { |
328 cmd = cmd_line; | 328 cmd = cmd_line; |
329 args = ''; | 329 args = ''; |
330 } else { | 330 } else { |
331 cmd = cmd_line.slice(0, pos); | 331 cmd = cmd_line.slice(0, pos); |
332 args = cmd_line.slice(pos).replace(/^\s+|\s+$/g, ''); | 332 args = cmd_line.slice(pos).replace(/^\s+|\s+$/g, ''); |
333 } | 333 } |
334 | 334 |
335 if ((cmd === undefined) || !cmd) { | 335 if ((cmd === undefined) || !cmd) { |
336 this.request_ = void 0; | 336 this.request_ = UNDEFINED; |
337 return; | 337 return; |
338 } | 338 } |
339 | 339 |
340 last_cmd = cmd; | 340 last_cmd = cmd; |
341 | 341 |
342 // Switch on command. | 342 // Switch on command. |
343 switch (cmd) { | 343 switch (cmd) { |
344 case 'continue': | 344 case 'continue': |
345 case 'c': | 345 case 'c': |
346 this.request_ = this.continueCommandToJSONRequest_(args); | 346 this.request_ = this.continueCommandToJSONRequest_(args); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 this.request_ = this.v8FlagsToJSONRequest_(args); | 485 this.request_ = this.v8FlagsToJSONRequest_(args); |
486 break; | 486 break; |
487 | 487 |
488 case 'gc': | 488 case 'gc': |
489 this.request_ = this.gcToJSONRequest_(args); | 489 this.request_ = this.gcToJSONRequest_(args); |
490 break; | 490 break; |
491 | 491 |
492 case 'trace': | 492 case 'trace': |
493 case 'tr': | 493 case 'tr': |
494 // Return undefined to indicate command handled internally (no JSON). | 494 // Return undefined to indicate command handled internally (no JSON). |
495 this.request_ = void 0; | 495 this.request_ = UNDEFINED; |
496 this.traceCommand_(args); | 496 this.traceCommand_(args); |
497 break; | 497 break; |
498 | 498 |
499 case 'help': | 499 case 'help': |
500 case '?': | 500 case '?': |
501 this.helpCommand_(args); | 501 this.helpCommand_(args); |
502 // Return undefined to indicate command handled internally (no JSON). | 502 // Return undefined to indicate command handled internally (no JSON). |
503 this.request_ = void 0; | 503 this.request_ = UNDEFINED; |
504 break; | 504 break; |
505 | 505 |
506 default: | 506 default: |
507 throw new Error('Unknown command "' + cmd + '"'); | 507 throw new Error('Unknown command "' + cmd + '"'); |
508 } | 508 } |
509 } | 509 } |
510 | 510 |
511 DebugRequest.prototype.JSONRequest = function() { | 511 DebugRequest.prototype.JSONRequest = function() { |
512 return this.request_; | 512 return this.request_; |
513 }; | 513 }; |
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2117 var content = []; | 2117 var content = []; |
2118 for (var key in object) { | 2118 for (var key in object) { |
2119 // Only consider string keys. | 2119 // Only consider string keys. |
2120 if (typeof key == 'string') { | 2120 if (typeof key == 'string') { |
2121 var property_value = object[key]; | 2121 var property_value = object[key]; |
2122 | 2122 |
2123 // Format the value based on its type. | 2123 // Format the value based on its type. |
2124 var property_value_json; | 2124 var property_value_json; |
2125 switch (typeof property_value) { | 2125 switch (typeof property_value) { |
2126 case 'object': | 2126 case 'object': |
2127 if (property_value === null) { | 2127 if (IS_NULL(property_value)) { |
2128 property_value_json = 'null'; | 2128 property_value_json = 'null'; |
2129 } else if (typeof property_value.toJSONProtocol == 'function') { | 2129 } else if (typeof property_value.toJSONProtocol == 'function') { |
2130 property_value_json = property_value.toJSONProtocol(true); | 2130 property_value_json = property_value.toJSONProtocol(true); |
2131 } else if (property_value.constructor.name == 'Array'){ | 2131 } else if (property_value.constructor.name == 'Array'){ |
2132 property_value_json = SimpleArrayToJSON_(property_value); | 2132 property_value_json = SimpleArrayToJSON_(property_value); |
2133 } else { | 2133 } else { |
2134 property_value_json = SimpleObjectToJSON_(property_value); | 2134 property_value_json = SimpleObjectToJSON_(property_value); |
2135 } | 2135 } |
2136 break; | 2136 break; |
2137 | 2137 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2210 return "undefined"; | 2210 return "undefined"; |
2211 case "boolean": | 2211 case "boolean": |
2212 case "number": | 2212 case "number": |
2213 case "function": | 2213 case "function": |
2214 return x.toString(); | 2214 return x.toString(); |
2215 case "string": | 2215 case "string": |
2216 return "\"" + x.toString() + "\""; | 2216 return "\"" + x.toString() + "\""; |
2217 case "symbol": | 2217 case "symbol": |
2218 return "Symbol(" + (x.name ? Stringify(x.name, depth) : "") + ")" | 2218 return "Symbol(" + (x.name ? Stringify(x.name, depth) : "") + ")" |
2219 case "object": | 2219 case "object": |
2220 if (x === null) return "null"; | 2220 if (IS_NULL(x)) return "null"; |
2221 if (x.constructor && x.constructor.name === "Array") { | 2221 if (x.constructor && x.constructor.name === "Array") { |
2222 var elems = []; | 2222 var elems = []; |
2223 for (var i = 0; i < x.length; ++i) { | 2223 for (var i = 0; i < x.length; ++i) { |
2224 elems.push( | 2224 elems.push( |
2225 {}.hasOwnProperty.call(x, i) ? Stringify(x[i], depth - 1) : ""); | 2225 {}.hasOwnProperty.call(x, i) ? Stringify(x[i], depth - 1) : ""); |
2226 } | 2226 } |
2227 return "[" + elems.join(", ") + "]"; | 2227 return "[" + elems.join(", ") + "]"; |
2228 } | 2228 } |
2229 try { | 2229 try { |
2230 var string = String(x); | 2230 var string = String(x); |
2231 if (string && string !== "[object Object]") return string; | 2231 if (string && string !== "[object Object]") return string; |
2232 } catch(e) {} | 2232 } catch(e) {} |
2233 var props = []; | 2233 var props = []; |
2234 for (var name in x) { | 2234 for (var name in x) { |
2235 var desc = Object.getOwnPropertyDescriptor(x, name); | 2235 var desc = Object.getOwnPropertyDescriptor(x, name); |
2236 if (desc === void 0) continue; | 2236 if (IS_UNDEFINED(desc)) continue; |
2237 if ("value" in desc) { | 2237 if ("value" in desc) { |
2238 props.push(name + ": " + Stringify(desc.value, depth - 1)); | 2238 props.push(name + ": " + Stringify(desc.value, depth - 1)); |
2239 } | 2239 } |
2240 if ("get" in desc) { | 2240 if ("get" in desc) { |
2241 var getter = desc.get.toString(); | 2241 var getter = desc.get.toString(); |
2242 props.push("get " + name + getter.slice(getter.indexOf('('))); | 2242 props.push("get " + name + getter.slice(getter.indexOf('('))); |
2243 } | 2243 } |
2244 if ("set" in desc) { | 2244 if ("set" in desc) { |
2245 var setter = desc.set.toString(); | 2245 var setter = desc.set.toString(); |
2246 props.push("set " + name + setter.slice(setter.indexOf('('))); | 2246 props.push("set " + name + setter.slice(setter.indexOf('('))); |
2247 } | 2247 } |
2248 } | 2248 } |
2249 return "{" + props.join(", ") + "}"; | 2249 return "{" + props.join(", ") + "}"; |
2250 default: | 2250 default: |
2251 return "[crazy non-standard shit]"; | 2251 return "[crazy non-standard shit]"; |
2252 } | 2252 } |
2253 } | 2253 } |
OLD | NEW |