OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // - NumberMirror | 128 // - NumberMirror |
129 // - StringMirror | 129 // - StringMirror |
130 // - ObjectMirror | 130 // - ObjectMirror |
131 // - FunctionMirror | 131 // - FunctionMirror |
132 // - UnresolvedFunctionMirror | 132 // - UnresolvedFunctionMirror |
133 // - ArrayMirror | 133 // - ArrayMirror |
134 // - DateMirror | 134 // - DateMirror |
135 // - RegExpMirror | 135 // - RegExpMirror |
136 // - ErrorMirror | 136 // - ErrorMirror |
137 // - PropertyMirror | 137 // - PropertyMirror |
138 // - InterceptorPropertyMirror | |
139 // - AccessorMirror | |
140 // - FrameMirror | 138 // - FrameMirror |
141 // - ScriptMirror | 139 // - ScriptMirror |
142 | 140 |
143 | 141 |
144 /** | 142 /** |
145 * Base class for all mirror objects. | 143 * Base class for all mirror objects. |
146 * @param {string} type The type of the mirror | 144 * @param {string} type The type of the mirror |
147 * @constructor | 145 * @constructor |
148 */ | 146 */ |
149 function Mirror(type) { | 147 function Mirror(type) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 /** | 265 /** |
268 * Check whether the mirror reflects a property. | 266 * Check whether the mirror reflects a property. |
269 * @returns {boolean} True if the mirror reflects a property | 267 * @returns {boolean} True if the mirror reflects a property |
270 */ | 268 */ |
271 Mirror.prototype.isProperty = function() { | 269 Mirror.prototype.isProperty = function() { |
272 return this instanceof PropertyMirror; | 270 return this instanceof PropertyMirror; |
273 } | 271 } |
274 | 272 |
275 | 273 |
276 /** | 274 /** |
277 * Check whether the mirror reflects a property from an interceptor. | |
278 * @returns {boolean} True if the mirror reflects a property from an | |
279 * interceptor | |
280 */ | |
281 Mirror.prototype.isInterceptorProperty = function() { | |
282 return this instanceof InterceptorPropertyMirror; | |
283 } | |
284 | |
285 | |
286 /** | |
287 * Check whether the mirror reflects an accessor. | |
288 * @returns {boolean} True if the mirror reflects an accessor | |
289 */ | |
290 Mirror.prototype.isAccessor = function() { | |
291 return this instanceof AccessorMirror; | |
292 } | |
293 | |
294 | |
295 /** | |
296 * Check whether the mirror reflects a stack frame. | 275 * Check whether the mirror reflects a stack frame. |
297 * @returns {boolean} True if the mirror reflects a stack frame | 276 * @returns {boolean} True if the mirror reflects a stack frame |
298 */ | 277 */ |
299 Mirror.prototype.isFrame = function() { | 278 Mirror.prototype.isFrame = function() { |
300 return this instanceof FrameMirror; | 279 return this instanceof FrameMirror; |
301 } | 280 } |
302 | 281 |
303 | 282 |
304 /** | 283 /** |
305 * Check whether the mirror reflects a script. | 284 * Check whether the mirror reflects a script. |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 value | 491 value |
513 * @return {Array} Property names for this object | 492 * @return {Array} Property names for this object |
514 */ | 493 */ |
515 ObjectMirror.prototype.propertyNames = function(kind, limit) { | 494 ObjectMirror.prototype.propertyNames = function(kind, limit) { |
516 // Find kind and limit and allocate array for the result | 495 // Find kind and limit and allocate array for the result |
517 kind = kind || PropertyKind.Named | PropertyKind.Indexed; | 496 kind = kind || PropertyKind.Named | PropertyKind.Indexed; |
518 | 497 |
519 var propertyNames; | 498 var propertyNames; |
520 var elementNames; | 499 var elementNames; |
521 var total = 0; | 500 var total = 0; |
| 501 |
| 502 // Find all the named properties. |
522 if (kind & PropertyKind.Named) { | 503 if (kind & PropertyKind.Named) { |
| 504 // Get the local property names. |
523 propertyNames = %DebugLocalPropertyNames(this.value_); | 505 propertyNames = %DebugLocalPropertyNames(this.value_); |
524 total += propertyNames.length; | 506 total += propertyNames.length; |
| 507 |
| 508 // Get names for named interceptor properties if any. |
| 509 if (this.hasNamedInterceptor() && (kind & PropertyKind.Named)) { |
| 510 var namedInterceptorNames = |
| 511 %DebugNamedInterceptorPropertyNames(this.value_); |
| 512 if (namedInterceptorNames) { |
| 513 propertyNames = propertyNames.concat(namedInterceptorNames); |
| 514 total += namedInterceptorNames.length; |
| 515 } |
| 516 } |
525 } | 517 } |
| 518 |
| 519 // Find all the indexed properties. |
526 if (kind & PropertyKind.Indexed) { | 520 if (kind & PropertyKind.Indexed) { |
527 elementNames = %DebugLocalElementNames(this.value_) | 521 // Get the local element names. |
| 522 elementNames = %DebugLocalElementNames(this.value_); |
528 total += elementNames.length; | 523 total += elementNames.length; |
| 524 |
| 525 // Get names for indexed interceptor properties. |
| 526 if (this.hasIndexedInterceptor() && (kind & PropertyKind.Indexed)) { |
| 527 var indexedInterceptorNames = |
| 528 %DebugIndexedInterceptorElementNames(this.value_); |
| 529 if (indexedInterceptorNames) { |
| 530 elementNames = elementNames.concat(indexedInterceptorNames); |
| 531 total += indexedInterceptorNames.length; |
| 532 } |
| 533 } |
529 } | 534 } |
530 limit = Math.min(limit || total, total); | 535 limit = Math.min(limit || total, total); |
531 | 536 |
532 var names = new Array(limit); | 537 var names = new Array(limit); |
533 var index = 0; | 538 var index = 0; |
534 | 539 |
535 // Copy names for named properties. | 540 // Copy names for named properties. |
536 if (kind & PropertyKind.Named) { | 541 if (kind & PropertyKind.Named) { |
537 for (var i = 0; index < limit && i < propertyNames.length; i++) { | 542 for (var i = 0; index < limit && i < propertyNames.length; i++) { |
538 names[index++] = propertyNames[i]; | 543 names[index++] = propertyNames[i]; |
(...skipping 23 matching lines...) Expand all Loading... |
562 var names = this.propertyNames(kind, limit); | 567 var names = this.propertyNames(kind, limit); |
563 var properties = new Array(names.length); | 568 var properties = new Array(names.length); |
564 for (var i = 0; i < names.length; i++) { | 569 for (var i = 0; i < names.length; i++) { |
565 properties[i] = this.property(names[i]); | 570 properties[i] = this.property(names[i]); |
566 } | 571 } |
567 | 572 |
568 return properties; | 573 return properties; |
569 }; | 574 }; |
570 | 575 |
571 | 576 |
572 /** | |
573 * Return the interceptor property names for this object. | |
574 * @param {number} kind Indicate whether named, indexed or both kinds of | |
575 * interceptor properties are requested | |
576 * @param {number} limit Limit the number of names returend to the specified | |
577 value | |
578 * @return {Array} interceptor property names for this object | |
579 */ | |
580 ObjectMirror.prototype.interceptorPropertyNames = function(kind, limit) { | |
581 // Find kind. | |
582 kind = kind || PropertyKind.Named | PropertyKind.Indexed; | |
583 var namedInterceptorNames; | |
584 var indexedInterceptorNames; | |
585 | |
586 // Get names for named interceptor properties. | |
587 if (this.hasNamedInterceptor() && kind & PropertyKind.Named) { | |
588 namedInterceptorNames = %DebugNamedInterceptorPropertyNames(this.value_); | |
589 } | |
590 | |
591 // Get names for indexed interceptor properties. | |
592 if (this.hasIndexedInterceptor() && kind & PropertyKind.Indexed) { | |
593 indexedInterceptorNames = %DebugIndexedInterceptorElementNames(this.value_); | |
594 } | |
595 | |
596 // Return either retult or both concattenated. | |
597 if (namedInterceptorNames && indexedInterceptorNames) { | |
598 return namedInterceptorNames.concat(indexedInterceptorNames); | |
599 } else if (namedInterceptorNames) { | |
600 return namedInterceptorNames; | |
601 } else if (indexedInterceptorNames) { | |
602 return indexedInterceptorNames; | |
603 } else { | |
604 return new Array(0); | |
605 } | |
606 }; | |
607 | |
608 | |
609 /** | |
610 * Return interceptor properties this object. | |
611 * @param {number} opt_kind Indicate whether named, indexed or both kinds of | |
612 * interceptor properties are requested | |
613 * @param {Array} opt_names Limit the number of properties returned to the | |
614 specified value | |
615 * @return {Array} properties this object as an array of PropertyMirror objects | |
616 */ | |
617 ObjectMirror.prototype.interceptorProperties = function(opt_kind, opt_names) { | |
618 // Find kind. | |
619 var kind = opt_kind || PropertyKind.Named | PropertyKind.Indexed; | |
620 var namedInterceptorProperties; | |
621 var indexedInterceptorProperties; | |
622 | |
623 // Get values for named interceptor properties. | |
624 if (kind & PropertyKind.Named) { | |
625 var names = opt_names || this.interceptorPropertyNames(PropertyKind.Named); | |
626 namedInterceptorProperties = new Array(names.length); | |
627 for (i = 0; i < names.length; i++) { | |
628 var value = %DebugNamedInterceptorPropertyValue(this.value_, names[i]); | |
629 namedInterceptorProperties[i] = new InterceptorPropertyMirror(this, names[
i], value); | |
630 } | |
631 } | |
632 | |
633 // Get values for indexed interceptor properties. | |
634 if (kind & PropertyKind.Indexed) { | |
635 var names = opt_names || this.interceptorPropertyNames(PropertyKind.Indexed)
; | |
636 indexedInterceptorProperties = new Array(names.length); | |
637 for (i = 0; i < names.length; i++) { | |
638 // Don't try to get the value if the name is not a number. | |
639 if (IS_NUMBER(names[i])) { | |
640 var value = %DebugIndexedInterceptorElementValue(this.value_, names[i]); | |
641 indexedInterceptorProperties[i] = new InterceptorPropertyMirror(this, na
mes[i], value); | |
642 } | |
643 } | |
644 } | |
645 | |
646 // Return either result or both concattenated. | |
647 if (namedInterceptorProperties && indexedInterceptorProperties) { | |
648 return namedInterceptorProperties.concat(indexedInterceptorProperties); | |
649 } else if (namedInterceptorProperties) { | |
650 return namedInterceptorProperties; | |
651 } else { | |
652 return indexedInterceptorProperties; | |
653 } | |
654 }; | |
655 | |
656 | |
657 ObjectMirror.prototype.property = function(name) { | 577 ObjectMirror.prototype.property = function(name) { |
658 var details = %DebugGetPropertyDetails(this.value_, %ToString(name)); | 578 var details = %DebugGetPropertyDetails(this.value_, %ToString(name)); |
659 if (details) { | 579 if (details) { |
660 return new PropertyMirror(this, name, details[0], details[1]); | 580 return new PropertyMirror(this, name, details); |
661 } | 581 } |
662 | 582 |
663 // Nothing found. | 583 // Nothing found. |
664 return new UndefinedMirror(); | 584 return new UndefinedMirror(); |
665 }; | 585 }; |
666 | 586 |
667 | 587 |
668 | 588 |
669 /** | 589 /** |
670 * Try to find a property from its value. | 590 * Try to find a property from its value. |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 | 806 |
887 ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index, opt_
to_index) { | 807 ArrayMirror.prototype.indexedPropertiesFromRange = function(opt_from_index, opt_
to_index) { |
888 var from_index = opt_from_index || 0; | 808 var from_index = opt_from_index || 0; |
889 var to_index = opt_to_index || this.length() - 1; | 809 var to_index = opt_to_index || this.length() - 1; |
890 if (from_index > to_index) return new Array(); | 810 if (from_index > to_index) return new Array(); |
891 var values = new Array(to_index - from_index + 1); | 811 var values = new Array(to_index - from_index + 1); |
892 for (var i = from_index; i <= to_index; i++) { | 812 for (var i = from_index; i <= to_index; i++) { |
893 var details = %DebugGetPropertyDetails(this.value_, %ToString(i)); | 813 var details = %DebugGetPropertyDetails(this.value_, %ToString(i)); |
894 var value; | 814 var value; |
895 if (details) { | 815 if (details) { |
896 value = new PropertyMirror(this, i, details[0], details[1]); | 816 value = new PropertyMirror(this, i, details); |
897 } else { | 817 } else { |
898 value = new UndefinedMirror(); | 818 value = new UndefinedMirror(); |
899 } | 819 } |
900 values[i - from_index] = value; | 820 values[i - from_index] = value; |
901 } | 821 } |
902 return values; | 822 return values; |
903 } | 823 } |
904 | 824 |
905 | 825 |
906 /** | 826 /** |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 str = '#<an Error>'; | 924 str = '#<an Error>'; |
1005 } | 925 } |
1006 return str; | 926 return str; |
1007 } | 927 } |
1008 | 928 |
1009 | 929 |
1010 /** | 930 /** |
1011 * Base mirror object for properties. | 931 * Base mirror object for properties. |
1012 * @param {ObjectMirror} mirror The mirror object having this property | 932 * @param {ObjectMirror} mirror The mirror object having this property |
1013 * @param {string} name The name of the property | 933 * @param {string} name The name of the property |
1014 * @param {Object} value The value of the property | 934 * @param {Array} details Details about the property |
1015 * @constructor | 935 * @constructor |
1016 * @extends Mirror | 936 * @extends Mirror |
1017 */ | 937 */ |
1018 function PropertyMirror(mirror, name, value, details) { | 938 function PropertyMirror(mirror, name, details) { |
1019 Mirror.call(this, PROPERTY_TYPE); | 939 Mirror.call(this, PROPERTY_TYPE); |
1020 this.mirror_ = mirror; | 940 this.mirror_ = mirror; |
1021 this.name_ = name; | 941 this.name_ = name; |
1022 this.value_ = value; | 942 this.value_ = details[0]; |
1023 this.details_ = details; | 943 this.details_ = details[1]; |
| 944 if (details.length > 2) { |
| 945 this.exception_ = details[2] |
| 946 this.getter_ = details[3]; |
| 947 this.setter_ = details[4]; |
| 948 } |
1024 } | 949 } |
1025 inherits(PropertyMirror, Mirror); | 950 inherits(PropertyMirror, Mirror); |
1026 | 951 |
1027 | 952 |
1028 PropertyMirror.prototype.isReadOnly = function() { | 953 PropertyMirror.prototype.isReadOnly = function() { |
1029 return (this.attributes() & PropertyAttribute.ReadOnly) != 0; | 954 return (this.attributes() & PropertyAttribute.ReadOnly) != 0; |
1030 } | 955 } |
1031 | 956 |
1032 | 957 |
1033 PropertyMirror.prototype.isEnum = function() { | 958 PropertyMirror.prototype.isEnum = function() { |
(...skipping 15 matching lines...) Expand all Loading... |
1049 for (var i = 0; i < this.name_.length; i++) { | 974 for (var i = 0; i < this.name_.length; i++) { |
1050 if (this.name_[i] < '0' || '9' < this.name_[i]) { | 975 if (this.name_[i] < '0' || '9' < this.name_[i]) { |
1051 return false; | 976 return false; |
1052 } | 977 } |
1053 } | 978 } |
1054 return true; | 979 return true; |
1055 } | 980 } |
1056 | 981 |
1057 | 982 |
1058 PropertyMirror.prototype.value = function() { | 983 PropertyMirror.prototype.value = function() { |
1059 if (this.propertyType() == PropertyType.Callbacks) { | 984 return MakeMirror(this.value_); |
1060 // TODO(1242933): AccessorMirror should have getter/setter values. | 985 } |
1061 return new AccessorMirror(); | 986 |
1062 } else if (this.type() == PropertyType.Interceptor) { | 987 |
1063 return new UndefinedMirror(); | 988 /** |
1064 } else { | 989 * Returns whether this property value is an exception. |
1065 return MakeMirror(this.value_); | 990 * @return {booolean} True if this property value is an exception |
1066 } | 991 */ |
| 992 PropertyMirror.prototype.isException = function() { |
| 993 return this.exception_ ? true : false; |
1067 } | 994 } |
1068 | 995 |
1069 | 996 |
1070 PropertyMirror.prototype.attributes = function() { | 997 PropertyMirror.prototype.attributes = function() { |
1071 return %DebugPropertyAttributesFromDetails(this.details_); | 998 return %DebugPropertyAttributesFromDetails(this.details_); |
1072 } | 999 } |
1073 | 1000 |
1074 | 1001 |
1075 PropertyMirror.prototype.propertyType = function() { | 1002 PropertyMirror.prototype.propertyType = function() { |
1076 return %DebugPropertyTypeFromDetails(this.details_); | 1003 return %DebugPropertyTypeFromDetails(this.details_); |
1077 } | 1004 } |
1078 | 1005 |
1079 | 1006 |
1080 PropertyMirror.prototype.insertionIndex = function() { | 1007 PropertyMirror.prototype.insertionIndex = function() { |
1081 return %DebugPropertyIndexFromDetails(this.details_); | 1008 return %DebugPropertyIndexFromDetails(this.details_); |
1082 } | 1009 } |
1083 | 1010 |
1084 | 1011 |
1085 /** | 1012 /** |
1086 * Mirror object for interceptor named properties. | 1013 * Returns whether this property has a getter defined through __defineGetter__. |
1087 * @param {ObjectMirror} mirror The mirror object having this property | 1014 * @return {booolean} True if this property has a getter |
1088 * @param {String} name The name of the property | |
1089 * @param {value} value The value of the property | |
1090 * @constructor | |
1091 * @extends PropertyMirror | |
1092 */ | 1015 */ |
1093 function InterceptorPropertyMirror(mirror, name, value) { | 1016 PropertyMirror.prototype.hasGetter = function() { |
1094 PropertyMirror.call(this, mirror, name, value, PropertyType.Interceptor); | 1017 return this.getter_ ? true : false; |
1095 } | |
1096 inherits(InterceptorPropertyMirror, PropertyMirror); | |
1097 | |
1098 | |
1099 /** | |
1100 * Mirror object for property accessors. | |
1101 * @param {Function} getter The getter function for this accessor | |
1102 * @param {Function} setter The setter function for this accessor | |
1103 * @constructor | |
1104 * @extends Mirror | |
1105 */ | |
1106 function AccessorMirror(getter, setter) { | |
1107 Mirror.call(this, ACCESSOR_TYPE); | |
1108 this.getter_ = getter; | |
1109 this.setter_ = setter; | |
1110 } | |
1111 inherits(AccessorMirror, Mirror); | |
1112 | |
1113 | |
1114 /** | |
1115 * Returns whether this accessor is native or not. A native accessor is either | |
1116 * a VM buildin or provided through the API. A non native accessor is defined | |
1117 * in JavaScript using the __defineGetter__ and/or __defineGetter__ functions. | |
1118 * @return {boolean} True is the accessor is native | |
1119 */ | |
1120 AccessorMirror.prototype.isNative = function() { | |
1121 return IS_UNDEFINED(this.getter_) && IS_UNDEFINED(this.setter_); | |
1122 } | 1018 } |
1123 | 1019 |
1124 | 1020 |
1125 /** | 1021 /** |
1126 * Returns a mirror for the function of a non native getter. | 1022 * Returns whether this property has a setter defined through __defineSetter__. |
1127 * @return {FunctionMirror} Function mirror for the getter set using | 1023 * @return {booolean} True if this property has a setter |
1128 * __defineGetter__. | |
1129 */ | 1024 */ |
1130 AccessorMirror.prototype.getter = function(details) { | 1025 PropertyMirror.prototype.hasSetter = function() { |
1131 return MakeMirror(this.getter_); | 1026 return this.setter_ ? true : false; |
1132 } | 1027 } |
1133 | 1028 |
1134 | 1029 |
1135 /** | 1030 /** |
1136 * Returns a mirror for the function of a non native setter. | 1031 * Returns the getter for this property defined through __defineGetter__. |
1137 * @return {FunctionMirror} Function mirror for the getter set using | 1032 * @return {Mirror} FunctionMirror reflecting the getter function or |
1138 * __defineSetter__. | 1033 * UndefinedMirror if there is no getter for this property |
1139 */ | 1034 */ |
1140 AccessorMirror.prototype.setter = function(details) { | 1035 PropertyMirror.prototype.getter = function() { |
1141 return MakeMirror(this.setter_); | 1036 if (this.hasGetter()) { |
| 1037 return MakeMirror(this.getter_); |
| 1038 } else { |
| 1039 return new UndefinedMirror(); |
| 1040 } |
1142 } | 1041 } |
1143 | 1042 |
1144 | 1043 |
| 1044 /** |
| 1045 * Returns the setter for this property defined through __defineSetter__. |
| 1046 * @return {Mirror} FunctionMirror reflecting the setter function or |
| 1047 * UndefinedMirror if there is no setter for this property |
| 1048 */ |
| 1049 PropertyMirror.prototype.setter = function() { |
| 1050 if (this.hasSetter()) { |
| 1051 return MakeMirror(this.setter_); |
| 1052 } else { |
| 1053 return new UndefinedMirror(); |
| 1054 } |
| 1055 } |
| 1056 |
| 1057 |
| 1058 /** |
| 1059 * Returns whether this property is natively implemented by the host or a set |
| 1060 * through JavaScript code. |
| 1061 * @return {boolean} True if the property is |
| 1062 * UndefinedMirror if there is no setter for this property |
| 1063 */ |
| 1064 PropertyMirror.prototype.isNative = function() { |
| 1065 return (this.propertyType() == PropertyType.Interceptor) || |
| 1066 ((this.propertyType() == PropertyType.Callbacks) && |
| 1067 !this.hasGetter() && !this.hasSetter()); |
| 1068 } |
| 1069 |
| 1070 |
1145 const kFrameDetailsFrameIdIndex = 0; | 1071 const kFrameDetailsFrameIdIndex = 0; |
1146 const kFrameDetailsReceiverIndex = 1; | 1072 const kFrameDetailsReceiverIndex = 1; |
1147 const kFrameDetailsFunctionIndex = 2; | 1073 const kFrameDetailsFunctionIndex = 2; |
1148 const kFrameDetailsArgumentCountIndex = 3; | 1074 const kFrameDetailsArgumentCountIndex = 3; |
1149 const kFrameDetailsLocalCountIndex = 4; | 1075 const kFrameDetailsLocalCountIndex = 4; |
1150 const kFrameDetailsSourcePositionIndex = 5; | 1076 const kFrameDetailsSourcePositionIndex = 5; |
1151 const kFrameDetailsConstructCallIndex = 6; | 1077 const kFrameDetailsConstructCallIndex = 6; |
1152 const kFrameDetailsDebuggerFrameIndex = 7; | 1078 const kFrameDetailsDebuggerFrameIndex = 7; |
1153 const kFrameDetailsFirstDynamicIndex = 8; | 1079 const kFrameDetailsFirstDynamicIndex = 8; |
1154 | 1080 |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 if (!mirror.isArray()) { | 1651 if (!mirror.isArray()) { |
1726 kind |= PropertyKind.Indexed | 1652 kind |= PropertyKind.Indexed |
1727 } | 1653 } |
1728 var propertyNames = mirror.propertyNames(kind); | 1654 var propertyNames = mirror.propertyNames(kind); |
1729 var x = new Array(propertyNames.length); | 1655 var x = new Array(propertyNames.length); |
1730 for (var i = 0; i < propertyNames.length; i++) { | 1656 for (var i = 0; i < propertyNames.length; i++) { |
1731 x[i] = mirror.property(propertyNames[i]).toJSONProtocol(false); | 1657 x[i] = mirror.property(propertyNames[i]).toJSONProtocol(false); |
1732 } | 1658 } |
1733 content.push(MakeJSONPair_('properties', ArrayToJSONArray_(x))); | 1659 content.push(MakeJSONPair_('properties', ArrayToJSONArray_(x))); |
1734 | 1660 |
1735 // Add interceptor properties. | |
1736 propertyNames = mirror.interceptorPropertyNames(); | |
1737 var x = new Array(propertyNames.length); | |
1738 for (var i = 0; i < propertyNames.length; i++) { | |
1739 x[i] = properties[i].toJSONProtocol(details); | |
1740 } | |
1741 content.push(MakeJSONPair_('interceptorProperties', ArrayToJSONArray_(x))); | |
1742 | |
1743 // For arrays the indexed properties are added separately and the length is | 1661 // For arrays the indexed properties are added separately and the length is |
1744 // added as well. | 1662 // added as well. |
1745 if (mirror.isArray()) { | 1663 if (mirror.isArray()) { |
1746 var propertyNames = mirror.propertyNames(PropertyKind.Indexed); | 1664 var propertyNames = mirror.propertyNames(PropertyKind.Indexed); |
1747 var x = new Array(propertyNames.length); | 1665 var x = new Array(propertyNames.length); |
1748 for (var i = 0; i < propertyNames.length; i++) { | 1666 for (var i = 0; i < propertyNames.length; i++) { |
1749 x[i] = mirror.property(propertyNames[i]).toJSONProtocol(false); | 1667 x[i] = mirror.property(propertyNames[i]).toJSONProtocol(false); |
1750 } | 1668 } |
1751 content.push(MakeJSONPair_('indexedProperties', ArrayToJSONArray_(x))); | 1669 content.push(MakeJSONPair_('indexedProperties', ArrayToJSONArray_(x))); |
1752 | 1670 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1942 /** | 1860 /** |
1943 * Convert a Date to ISO 8601 format. To avoid depending on the Date object | 1861 * Convert a Date to ISO 8601 format. To avoid depending on the Date object |
1944 * this method calls the functions in date.js directly and not through the | 1862 * this method calls the functions in date.js directly and not through the |
1945 * value. | 1863 * value. |
1946 * @param {Date} value The Date value to format as JSON | 1864 * @param {Date} value The Date value to format as JSON |
1947 * @return {string} JSON formatted Date value | 1865 * @return {string} JSON formatted Date value |
1948 */ | 1866 */ |
1949 function DateToJSON_(value) { | 1867 function DateToJSON_(value) { |
1950 return '"' + DateToISO8601_(value) + '"'; | 1868 return '"' + DateToISO8601_(value) + '"'; |
1951 } | 1869 } |
OLD | NEW |