OLD | NEW |
1 // Copyright 2006-2012 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2012 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 var UNDEFINED_TYPE = 'undefined'; | 147 var UNDEFINED_TYPE = 'undefined'; |
148 var NULL_TYPE = 'null'; | 148 var NULL_TYPE = 'null'; |
149 var BOOLEAN_TYPE = 'boolean'; | 149 var BOOLEAN_TYPE = 'boolean'; |
150 var NUMBER_TYPE = 'number'; | 150 var NUMBER_TYPE = 'number'; |
151 var STRING_TYPE = 'string'; | 151 var STRING_TYPE = 'string'; |
152 var OBJECT_TYPE = 'object'; | 152 var OBJECT_TYPE = 'object'; |
153 var FUNCTION_TYPE = 'function'; | 153 var FUNCTION_TYPE = 'function'; |
154 var REGEXP_TYPE = 'regexp'; | 154 var REGEXP_TYPE = 'regexp'; |
155 var ERROR_TYPE = 'error'; | 155 var ERROR_TYPE = 'error'; |
156 var PROPERTY_TYPE = 'property'; | 156 var PROPERTY_TYPE = 'property'; |
| 157 var INTERNAL_PROPERTY_TYPE = 'internalProperty'; |
157 var FRAME_TYPE = 'frame'; | 158 var FRAME_TYPE = 'frame'; |
158 var SCRIPT_TYPE = 'script'; | 159 var SCRIPT_TYPE = 'script'; |
159 var CONTEXT_TYPE = 'context'; | 160 var CONTEXT_TYPE = 'context'; |
160 var SCOPE_TYPE = 'scope'; | 161 var SCOPE_TYPE = 'scope'; |
161 | 162 |
162 // Maximum length when sending strings through the JSON protocol. | 163 // Maximum length when sending strings through the JSON protocol. |
163 var kMaxProtocolStringLength = 80; | 164 var kMaxProtocolStringLength = 80; |
164 | 165 |
165 // Different kind of properties. | 166 // Different kind of properties. |
166 var PropertyKind = {}; | 167 var PropertyKind = {}; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // - NumberMirror | 206 // - NumberMirror |
206 // - StringMirror | 207 // - StringMirror |
207 // - ObjectMirror | 208 // - ObjectMirror |
208 // - FunctionMirror | 209 // - FunctionMirror |
209 // - UnresolvedFunctionMirror | 210 // - UnresolvedFunctionMirror |
210 // - ArrayMirror | 211 // - ArrayMirror |
211 // - DateMirror | 212 // - DateMirror |
212 // - RegExpMirror | 213 // - RegExpMirror |
213 // - ErrorMirror | 214 // - ErrorMirror |
214 // - PropertyMirror | 215 // - PropertyMirror |
| 216 // - InternalPropertyMirror |
215 // - FrameMirror | 217 // - FrameMirror |
216 // - ScriptMirror | 218 // - ScriptMirror |
217 | 219 |
218 | 220 |
219 /** | 221 /** |
220 * Base class for all mirror objects. | 222 * Base class for all mirror objects. |
221 * @param {string} type The type of the mirror | 223 * @param {string} type The type of the mirror |
222 * @constructor | 224 * @constructor |
223 */ | 225 */ |
224 function Mirror(type) { | 226 function Mirror(type) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 /** | 353 /** |
352 * Check whether the mirror reflects a property. | 354 * Check whether the mirror reflects a property. |
353 * @returns {boolean} True if the mirror reflects a property | 355 * @returns {boolean} True if the mirror reflects a property |
354 */ | 356 */ |
355 Mirror.prototype.isProperty = function() { | 357 Mirror.prototype.isProperty = function() { |
356 return this instanceof PropertyMirror; | 358 return this instanceof PropertyMirror; |
357 }; | 359 }; |
358 | 360 |
359 | 361 |
360 /** | 362 /** |
| 363 * Check whether the mirror reflects an internal property. |
| 364 * @returns {boolean} True if the mirror reflects an internal property |
| 365 */ |
| 366 Mirror.prototype.isInternalProperty = function() { |
| 367 return this instanceof InternalPropertyMirror; |
| 368 }; |
| 369 |
| 370 |
| 371 /** |
361 * Check whether the mirror reflects a stack frame. | 372 * Check whether the mirror reflects a stack frame. |
362 * @returns {boolean} True if the mirror reflects a stack frame | 373 * @returns {boolean} True if the mirror reflects a stack frame |
363 */ | 374 */ |
364 Mirror.prototype.isFrame = function() { | 375 Mirror.prototype.isFrame = function() { |
365 return this instanceof FrameMirror; | 376 return this instanceof FrameMirror; |
366 }; | 377 }; |
367 | 378 |
368 | 379 |
369 /** | 380 /** |
370 * Check whether the mirror reflects a script. | 381 * Check whether the mirror reflects a script. |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 ObjectMirror.prototype.prototypeObject = function() { | 598 ObjectMirror.prototype.prototypeObject = function() { |
588 return MakeMirror(%DebugGetProperty(this.value_, 'prototype')); | 599 return MakeMirror(%DebugGetProperty(this.value_, 'prototype')); |
589 }; | 600 }; |
590 | 601 |
591 | 602 |
592 ObjectMirror.prototype.protoObject = function() { | 603 ObjectMirror.prototype.protoObject = function() { |
593 return MakeMirror(%DebugGetPrototype(this.value_)); | 604 return MakeMirror(%DebugGetPrototype(this.value_)); |
594 }; | 605 }; |
595 | 606 |
596 | 607 |
597 /** | |
598 * Return the primitive value if this is object of Boolean, Number or String | |
599 * type (but not Date). Otherwise return undefined. | |
600 */ | |
601 ObjectMirror.prototype.primitiveValue = function() { | |
602 if (!IS_STRING_WRAPPER(this.value_) && !IS_NUMBER_WRAPPER(this.value_) && | |
603 !IS_BOOLEAN_WRAPPER(this.value_)) { | |
604 return void 0; | |
605 } | |
606 var primitiveValue = %_ValueOf(this.value_); | |
607 if (IS_UNDEFINED(primitiveValue)) { | |
608 return void 0; | |
609 } | |
610 return MakeMirror(primitiveValue); | |
611 }; | |
612 | |
613 | |
614 ObjectMirror.prototype.hasNamedInterceptor = function() { | 608 ObjectMirror.prototype.hasNamedInterceptor = function() { |
615 // Get information on interceptors for this object. | 609 // Get information on interceptors for this object. |
616 var x = %GetInterceptorInfo(this.value_); | 610 var x = %GetInterceptorInfo(this.value_); |
617 return (x & 2) != 0; | 611 return (x & 2) != 0; |
618 }; | 612 }; |
619 | 613 |
620 | 614 |
621 ObjectMirror.prototype.hasIndexedInterceptor = function() { | 615 ObjectMirror.prototype.hasIndexedInterceptor = function() { |
622 // Get information on interceptors for this object. | 616 // Get information on interceptors for this object. |
623 var x = %GetInterceptorInfo(this.value_); | 617 var x = %GetInterceptorInfo(this.value_); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 } | 688 } |
695 | 689 |
696 return names; | 690 return names; |
697 }; | 691 }; |
698 | 692 |
699 | 693 |
700 /** | 694 /** |
701 * Return the properties for this object as an array of PropertyMirror objects. | 695 * Return the properties for this object as an array of PropertyMirror objects. |
702 * @param {number} kind Indicate whether named, indexed or both kinds of | 696 * @param {number} kind Indicate whether named, indexed or both kinds of |
703 * properties are requested | 697 * properties are requested |
704 * @param {number} limit Limit the number of properties returend to the | 698 * @param {number} limit Limit the number of properties returned to the |
705 specified value | 699 specified value |
706 * @return {Array} Property mirrors for this object | 700 * @return {Array} Property mirrors for this object |
707 */ | 701 */ |
708 ObjectMirror.prototype.properties = function(kind, limit) { | 702 ObjectMirror.prototype.properties = function(kind, limit) { |
709 var names = this.propertyNames(kind, limit); | 703 var names = this.propertyNames(kind, limit); |
710 var properties = new Array(names.length); | 704 var properties = new Array(names.length); |
711 for (var i = 0; i < names.length; i++) { | 705 for (var i = 0; i < names.length; i++) { |
712 properties[i] = this.property(names[i]); | 706 properties[i] = this.property(names[i]); |
713 } | 707 } |
714 | 708 |
715 return properties; | 709 return properties; |
716 }; | 710 }; |
717 | 711 |
718 | 712 |
| 713 /** |
| 714 * Return the internal properties for this object as an array of |
| 715 * InternalPropertyMirror objects. |
| 716 * @return {Array} Property mirrors for this object |
| 717 */ |
| 718 ObjectMirror.prototype.internalProperties = function() { |
| 719 return ObjectMirror.GetInternalProperties(this.value_); |
| 720 } |
| 721 |
| 722 |
719 ObjectMirror.prototype.property = function(name) { | 723 ObjectMirror.prototype.property = function(name) { |
720 var details = %DebugGetPropertyDetails(this.value_, %ToString(name)); | 724 var details = %DebugGetPropertyDetails(this.value_, %ToString(name)); |
721 if (details) { | 725 if (details) { |
722 return new PropertyMirror(this, name, details); | 726 return new PropertyMirror(this, name, details); |
723 } | 727 } |
724 | 728 |
725 // Nothing found. | 729 // Nothing found. |
726 return GetUndefinedMirror(); | 730 return GetUndefinedMirror(); |
727 }; | 731 }; |
728 | 732 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 name = ctor.name(); | 787 name = ctor.name(); |
784 if (!name) { | 788 if (!name) { |
785 name = this.className(); | 789 name = this.className(); |
786 } | 790 } |
787 } | 791 } |
788 return '#<' + name + '>'; | 792 return '#<' + name + '>'; |
789 }; | 793 }; |
790 | 794 |
791 | 795 |
792 /** | 796 /** |
| 797 * Return the internal properties of the value, such as [[PrimitiveValue]] of |
| 798 * scalar wrapper objects and properties of the bound function. |
| 799 * This method is done static to be accessible from Debug API with the bare |
| 800 * values without mirrors. |
| 801 * @return {Array} array (possibly empty) of InternalProperty instances |
| 802 */ |
| 803 ObjectMirror.GetInternalProperties = function(value) { |
| 804 /* |
| 805 if (IS_STRING_WRAPPER(value) || IS_NUMBER_WRAPPER(value) || |
| 806 IS_BOOLEAN_WRAPPER(value)) { |
| 807 var primitiveValue = %_ValueOf(value); |
| 808 return [new InternalPropertyMirror("[[PrimitiveValue]]", primitiveValue)]; |
| 809 } else if (IS_FUNCTION(value)) { |
| 810 var bindings = %BoundFunctionGetBindings(value); |
| 811 var result = []; |
| 812 if (bindings && IS_ARRAY(bindings)) { |
| 813 result.push(new InternalPropertyMirror("[[TargetFunction]]", |
| 814 bindings[0])); |
| 815 result.push(new InternalPropertyMirror("[[BoundThis]]", bindings[1])); |
| 816 var boundArgs = []; |
| 817 for (var i = 2; i < bindings.length; i++) { |
| 818 boundArgs.push(bindings[i]); |
| 819 } |
| 820 result.push(new InternalPropertyMirror("[[BoundArgs]]", boundArgs)); |
| 821 } |
| 822 return result; |
| 823 } |
| 824 */ |
| 825 return []; |
| 826 } |
| 827 |
| 828 |
| 829 /** |
793 * Mirror object for functions. | 830 * Mirror object for functions. |
794 * @param {function} value The function object reflected by this mirror. | 831 * @param {function} value The function object reflected by this mirror. |
795 * @constructor | 832 * @constructor |
796 * @extends ObjectMirror | 833 * @extends ObjectMirror |
797 */ | 834 */ |
798 function FunctionMirror(value) { | 835 function FunctionMirror(value) { |
799 %_CallFunction(this, value, FUNCTION_TYPE, ObjectMirror); | 836 %_CallFunction(this, value, FUNCTION_TYPE, ObjectMirror); |
800 this.resolved_ = true; | 837 this.resolved_ = true; |
801 } | 838 } |
802 inherits(FunctionMirror, ObjectMirror); | 839 inherits(FunctionMirror, ObjectMirror); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 * @return {boolean} True if the property is | 1298 * @return {boolean} True if the property is |
1262 * UndefinedMirror if there is no setter for this property | 1299 * UndefinedMirror if there is no setter for this property |
1263 */ | 1300 */ |
1264 PropertyMirror.prototype.isNative = function() { | 1301 PropertyMirror.prototype.isNative = function() { |
1265 return (this.propertyType() == PropertyType.Interceptor) || | 1302 return (this.propertyType() == PropertyType.Interceptor) || |
1266 ((this.propertyType() == PropertyType.Callbacks) && | 1303 ((this.propertyType() == PropertyType.Callbacks) && |
1267 !this.hasGetter() && !this.hasSetter()); | 1304 !this.hasGetter() && !this.hasSetter()); |
1268 }; | 1305 }; |
1269 | 1306 |
1270 | 1307 |
| 1308 /** |
| 1309 * Mirror object for internal properties. Internal property reflects properties |
| 1310 * not accessible from user code such as [[BoundThis]] in bound function. |
| 1311 * Their names are merely symbolic. |
| 1312 * @param {string} name The name of the property |
| 1313 * @param {value} property value |
| 1314 * @constructor |
| 1315 * @extends Mirror |
| 1316 */ |
| 1317 function InternalPropertyMirror(name, value) { |
| 1318 %_CallFunction(this, INTERNAL_PROPERTY_TYPE, Mirror); |
| 1319 this.name_ = name; |
| 1320 this.value_ = value; |
| 1321 } |
| 1322 inherits(InternalPropertyMirror, Mirror); |
| 1323 |
| 1324 |
| 1325 InternalPropertyMirror.prototype.name = function() { |
| 1326 return this.name_; |
| 1327 }; |
| 1328 |
| 1329 |
| 1330 InternalPropertyMirror.prototype.value = function() { |
| 1331 return MakeMirror(this.value_, false); |
| 1332 }; |
| 1333 |
| 1334 |
1271 var kFrameDetailsFrameIdIndex = 0; | 1335 var kFrameDetailsFrameIdIndex = 0; |
1272 var kFrameDetailsReceiverIndex = 1; | 1336 var kFrameDetailsReceiverIndex = 1; |
1273 var kFrameDetailsFunctionIndex = 2; | 1337 var kFrameDetailsFunctionIndex = 2; |
1274 var kFrameDetailsArgumentCountIndex = 3; | 1338 var kFrameDetailsArgumentCountIndex = 3; |
1275 var kFrameDetailsLocalCountIndex = 4; | 1339 var kFrameDetailsLocalCountIndex = 4; |
1276 var kFrameDetailsSourcePositionIndex = 5; | 1340 var kFrameDetailsSourcePositionIndex = 5; |
1277 var kFrameDetailsConstructCallIndex = 6; | 1341 var kFrameDetailsConstructCallIndex = 6; |
1278 var kFrameDetailsAtReturnIndex = 7; | 1342 var kFrameDetailsAtReturnIndex = 7; |
1279 var kFrameDetailsFlagsIndex = 8; | 1343 var kFrameDetailsFlagsIndex = 8; |
1280 var kFrameDetailsFirstDynamicIndex = 9; | 1344 var kFrameDetailsFirstDynamicIndex = 9; |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2031 }; | 2095 }; |
2032 | 2096 |
2033 | 2097 |
2034 /** | 2098 /** |
2035 * Returns a serialization of an object value. The referenced objects are | 2099 * Returns a serialization of an object value. The referenced objects are |
2036 * added to the serialization state. | 2100 * added to the serialization state. |
2037 * | 2101 * |
2038 * @param {Mirror} mirror The mirror to serialize | 2102 * @param {Mirror} mirror The mirror to serialize |
2039 * @returns {String} JSON serialization | 2103 * @returns {String} JSON serialization |
2040 */ | 2104 */ |
2041 JSONProtocolSerializer.prototype.serializeValue = function(mirror) { | 2105 JSONProtocolSerializer.prototype.serializeValue = function xSerializeValue(mirro
r) { |
2042 var json = this.serialize_(mirror, false, true); | 2106 var json = this.serialize_(mirror, false, true); |
2043 return json; | 2107 return json; |
2044 }; | 2108 }; |
2045 | 2109 |
2046 | 2110 |
2047 /** | 2111 /** |
2048 * Returns a serialization of all the objects referenced. | 2112 * Returns a serialization of all the objects referenced. |
2049 * | 2113 * |
2050 * @param {Mirror} mirror The mirror to serialize. | 2114 * @param {Mirror} mirror The mirror to serialize. |
2051 * @returns {Array.<Object>} Array of the referenced objects converted to | 2115 * @returns {Array.<Object>} Array of the referenced objects converted to |
2052 * protcol objects. | 2116 * protcol objects. |
2053 */ | 2117 */ |
2054 JSONProtocolSerializer.prototype.serializeReferencedObjects = function() { | 2118 JSONProtocolSerializer.prototype.serializeReferencedObjects = function xSerializ
eReferencedObjects() { |
2055 // Collect the protocol representation of the referenced objects in an array. | 2119 // Collect the protocol representation of the referenced objects in an array. |
2056 var content = []; | 2120 var content = []; |
2057 | 2121 |
2058 // Get the number of referenced objects. | 2122 // Get the number of referenced objects. |
2059 var count = this.mirrors_.length; | 2123 var count = this.mirrors_.length; |
2060 | 2124 |
2061 for (var i = 0; i < count; i++) { | 2125 for (var i = 0; i < count; i++) { |
2062 content.push(this.serialize_(this.mirrors_[i], false, false)); | 2126 content.push(this.serialize_(this.mirrors_[i], false, false)); |
2063 } | 2127 } |
2064 | 2128 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2131 o.value = mirror.toText(); | 2195 o.value = mirror.toText(); |
2132 break; | 2196 break; |
2133 case OBJECT_TYPE: | 2197 case OBJECT_TYPE: |
2134 o.className = mirror.className(); | 2198 o.className = mirror.className(); |
2135 break; | 2199 break; |
2136 } | 2200 } |
2137 return o; | 2201 return o; |
2138 }; | 2202 }; |
2139 | 2203 |
2140 | 2204 |
2141 JSONProtocolSerializer.prototype.serialize_ = function(mirror, reference, | 2205 JSONProtocolSerializer.prototype.serialize_ = function xSerialize_(mirror, refer
ence, |
2142 details) { | 2206 details) { |
2143 // If serializing a reference to a mirror just return the reference and add | 2207 // If serializing a reference to a mirror just return the reference and add |
2144 // the mirror to the referenced mirrors. | 2208 // the mirror to the referenced mirrors. |
2145 if (reference && | 2209 if (reference && |
2146 (mirror.isValue() || mirror.isScript() || mirror.isContext())) { | 2210 (mirror.isValue() || mirror.isScript() || mirror.isContext())) { |
2147 if (this.inlineRefs_() && mirror.isValue()) { | 2211 if (this.inlineRefs_() && mirror.isValue()) { |
2148 return this.serializeReferenceWithDisplayData_(mirror); | 2212 return this.serializeReferenceWithDisplayData_(mirror); |
2149 } else { | 2213 } else { |
2150 this.add_(mirror); | 2214 this.add_(mirror); |
2151 return {'ref' : mirror.handle()}; | 2215 return {'ref' : mirror.handle()}; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2195 | 2259 |
2196 case OBJECT_TYPE: | 2260 case OBJECT_TYPE: |
2197 case FUNCTION_TYPE: | 2261 case FUNCTION_TYPE: |
2198 case ERROR_TYPE: | 2262 case ERROR_TYPE: |
2199 case REGEXP_TYPE: | 2263 case REGEXP_TYPE: |
2200 // Add object representation. | 2264 // Add object representation. |
2201 this.serializeObject_(mirror, content, details); | 2265 this.serializeObject_(mirror, content, details); |
2202 break; | 2266 break; |
2203 | 2267 |
2204 case PROPERTY_TYPE: | 2268 case PROPERTY_TYPE: |
2205 throw new Error('PropertyMirror cannot be serialized independeltly'); | 2269 case INTERNAL_PROPERTY_TYPE: |
| 2270 throw new Error('PropertyMirror cannot be serialized independently'); |
2206 break; | 2271 break; |
2207 | 2272 |
2208 case FRAME_TYPE: | 2273 case FRAME_TYPE: |
2209 // Add object representation. | 2274 // Add object representation. |
2210 this.serializeFrame_(mirror, content); | 2275 this.serializeFrame_(mirror, content); |
2211 break; | 2276 break; |
2212 | 2277 |
2213 case SCOPE_TYPE: | 2278 case SCOPE_TYPE: |
2214 // Add object representation. | 2279 // Add object representation. |
2215 this.serializeScope_(mirror, content); | 2280 this.serializeScope_(mirror, content); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 | 2336 |
2272 /** | 2337 /** |
2273 * Serialize object information to the following JSON format. | 2338 * Serialize object information to the following JSON format. |
2274 * | 2339 * |
2275 * {"className":"<class name>", | 2340 * {"className":"<class name>", |
2276 * "constructorFunction":{"ref":<number>}, | 2341 * "constructorFunction":{"ref":<number>}, |
2277 * "protoObject":{"ref":<number>}, | 2342 * "protoObject":{"ref":<number>}, |
2278 * "prototypeObject":{"ref":<number>}, | 2343 * "prototypeObject":{"ref":<number>}, |
2279 * "namedInterceptor":<boolean>, | 2344 * "namedInterceptor":<boolean>, |
2280 * "indexedInterceptor":<boolean>, | 2345 * "indexedInterceptor":<boolean>, |
2281 * "properties":[<properties>]} | 2346 * "properties":[<properties>], |
| 2347 * "internalProperties":[<internal properties>]} |
2282 */ | 2348 */ |
2283 JSONProtocolSerializer.prototype.serializeObject_ = function(mirror, content, | 2349 JSONProtocolSerializer.prototype.serializeObject_ = function xSerializeObject_(m
irror, content, |
2284 details) { | 2350 details) { |
2285 // Add general object properties. | 2351 // Add general object properties. |
2286 content.className = mirror.className(); | 2352 content.className = mirror.className(); |
2287 content.constructorFunction = | 2353 content.constructorFunction = |
2288 this.serializeReference(mirror.constructorFunction()); | 2354 this.serializeReference(mirror.constructorFunction()); |
2289 content.protoObject = this.serializeReference(mirror.protoObject()); | 2355 content.protoObject = this.serializeReference(mirror.protoObject()); |
2290 content.prototypeObject = this.serializeReference(mirror.prototypeObject()); | 2356 content.prototypeObject = this.serializeReference(mirror.prototypeObject()); |
2291 | 2357 |
2292 var primitiveValue = mirror.primitiveValue(); | |
2293 if (!IS_UNDEFINED(primitiveValue)) { | |
2294 content.primitiveValue = this.serializeReference(primitiveValue); | |
2295 } | |
2296 | |
2297 // Add flags to indicate whether there are interceptors. | 2358 // Add flags to indicate whether there are interceptors. |
2298 if (mirror.hasNamedInterceptor()) { | 2359 if (mirror.hasNamedInterceptor()) { |
2299 content.namedInterceptor = true; | 2360 content.namedInterceptor = true; |
2300 } | 2361 } |
2301 if (mirror.hasIndexedInterceptor()) { | 2362 if (mirror.hasIndexedInterceptor()) { |
2302 content.indexedInterceptor = true; | 2363 content.indexedInterceptor = true; |
2303 } | 2364 } |
2304 | 2365 |
2305 // Add function specific properties. | 2366 // Add function specific properties. |
2306 if (mirror.isFunction()) { | 2367 if (mirror.isFunction()) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2348 } | 2409 } |
2349 } | 2410 } |
2350 for (var i = 0; i < propertyIndexes.length; i++) { | 2411 for (var i = 0; i < propertyIndexes.length; i++) { |
2351 var propertyMirror = mirror.property(propertyIndexes[i]); | 2412 var propertyMirror = mirror.property(propertyIndexes[i]); |
2352 p[propertyNames.length + i] = this.serializeProperty_(propertyMirror); | 2413 p[propertyNames.length + i] = this.serializeProperty_(propertyMirror); |
2353 if (details) { | 2414 if (details) { |
2354 this.add_(propertyMirror.value()); | 2415 this.add_(propertyMirror.value()); |
2355 } | 2416 } |
2356 } | 2417 } |
2357 content.properties = p; | 2418 content.properties = p; |
| 2419 |
| 2420 var internalProperties = mirror.internalProperties(); |
| 2421 if (internalProperties.length > 0) { |
| 2422 var ip = []; |
| 2423 for (var i = 0; i < internalProperties.length; i++) { |
| 2424 ip.push(this.serializeInternalProperty_(internalProperties[i])); |
| 2425 } |
| 2426 content.internalProperties = ip; |
| 2427 } |
2358 }; | 2428 }; |
2359 | 2429 |
2360 | 2430 |
2361 /** | 2431 /** |
2362 * Serialize location information to the following JSON format: | 2432 * Serialize location information to the following JSON format: |
2363 * | 2433 * |
2364 * "position":"<position>", | 2434 * "position":"<position>", |
2365 * "line":"<line>", | 2435 * "line":"<line>", |
2366 * "column":"<column>", | 2436 * "column":"<column>", |
2367 * | 2437 * |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2415 } | 2485 } |
2416 if (propertyMirror.propertyType() != PropertyType.Normal) { | 2486 if (propertyMirror.propertyType() != PropertyType.Normal) { |
2417 result.propertyType = propertyMirror.propertyType(); | 2487 result.propertyType = propertyMirror.propertyType(); |
2418 } | 2488 } |
2419 result.ref = propertyValue.handle(); | 2489 result.ref = propertyValue.handle(); |
2420 } | 2490 } |
2421 return result; | 2491 return result; |
2422 }; | 2492 }; |
2423 | 2493 |
2424 | 2494 |
| 2495 /** |
| 2496 * Serialize internal property information to the following JSON format for |
| 2497 * building the array of properties. |
| 2498 * |
| 2499 * {"name":"<property name>", |
| 2500 * "ref":<number>} |
| 2501 * |
| 2502 * {"name":"[[BoundThis]]","ref":117} |
| 2503 * |
| 2504 * @param {InternalPropertyMirror} propertyMirror The property to serialize. |
| 2505 * @returns {Object} Protocol object representing the property. |
| 2506 */ |
| 2507 JSONProtocolSerializer.prototype.serializeInternalProperty_ = |
| 2508 function xSerializeInternalProperty_(propertyMirror) { |
| 2509 var result = {}; |
| 2510 |
| 2511 result.name = propertyMirror.name(); |
| 2512 var propertyValue = propertyMirror.value(); |
| 2513 if (this.inlineRefs_() && propertyValue.isValue()) { |
| 2514 result.value = this.serializeReferenceWithDisplayData_(propertyValue); |
| 2515 } else { |
| 2516 result.ref = propertyValue.handle(); |
| 2517 } |
| 2518 return result; |
| 2519 }; |
| 2520 |
| 2521 |
2425 JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) { | 2522 JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) { |
2426 content.index = mirror.index(); | 2523 content.index = mirror.index(); |
2427 content.receiver = this.serializeReference(mirror.receiver()); | 2524 content.receiver = this.serializeReference(mirror.receiver()); |
2428 var func = mirror.func(); | 2525 var func = mirror.func(); |
2429 content.func = this.serializeReference(func); | 2526 content.func = this.serializeReference(func); |
2430 if (func.script()) { | 2527 if (func.script()) { |
2431 content.script = this.serializeReference(func.script()); | 2528 content.script = this.serializeReference(func.script()); |
2432 } | 2529 } |
2433 content.constructCall = mirror.isConstructCall(); | 2530 content.constructCall = mirror.isConstructCall(); |
2434 content.atReturn = mirror.isAtReturn(); | 2531 content.atReturn = mirror.isAtReturn(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2497 } | 2594 } |
2498 if (!NUMBER_IS_FINITE(value)) { | 2595 if (!NUMBER_IS_FINITE(value)) { |
2499 if (value > 0) { | 2596 if (value > 0) { |
2500 return 'Infinity'; | 2597 return 'Infinity'; |
2501 } else { | 2598 } else { |
2502 return '-Infinity'; | 2599 return '-Infinity'; |
2503 } | 2600 } |
2504 } | 2601 } |
2505 return value; | 2602 return value; |
2506 } | 2603 } |
OLD | NEW |