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 // 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 // Handle id counters. | 5 // Handle id counters. |
6 var next_handle_ = 0; | 6 var next_handle_ = 0; |
7 var next_transient_handle_ = -1; | 7 var next_transient_handle_ = -1; |
8 | 8 |
9 // Mirror cache. | 9 // Mirror cache. |
10 var mirror_cache_ = []; | 10 var mirror_cache_ = []; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 // Maximum length when sending strings through the JSON protocol. | 165 // Maximum length when sending strings through the JSON protocol. |
166 var kMaxProtocolStringLength = 80; | 166 var kMaxProtocolStringLength = 80; |
167 | 167 |
168 // Different kind of properties. | 168 // Different kind of properties. |
169 var PropertyKind = {}; | 169 var PropertyKind = {}; |
170 PropertyKind.Named = 1; | 170 PropertyKind.Named = 1; |
171 PropertyKind.Indexed = 2; | 171 PropertyKind.Indexed = 2; |
172 | 172 |
173 | 173 |
174 // A copy of the PropertyType enum from global.h | 174 // A copy of the PropertyType enum from property-details.h |
175 var PropertyType = {}; | 175 var PropertyType = {}; |
176 PropertyType.Normal = 0; | 176 PropertyType.Normal = 0; |
177 PropertyType.Field = 1; | 177 PropertyType.Field = 1; |
178 PropertyType.Constant = 2; | 178 PropertyType.Constant = 2; |
179 PropertyType.Callbacks = 3; | 179 PropertyType.Callbacks = 3; |
180 PropertyType.Handler = 4; | 180 PropertyType.Handler = 4; |
181 PropertyType.Interceptor = 5; | 181 PropertyType.Interceptor = 5; |
182 PropertyType.Transition = 6; | 182 PropertyType.Nonexistent = 6; |
183 PropertyType.Nonexistent = 7; | |
184 | 183 |
185 | 184 |
186 // Different attributes for a property. | 185 // Different attributes for a property. |
187 var PropertyAttribute = {}; | 186 var PropertyAttribute = {}; |
188 PropertyAttribute.None = NONE; | 187 PropertyAttribute.None = NONE; |
189 PropertyAttribute.ReadOnly = READ_ONLY; | 188 PropertyAttribute.ReadOnly = READ_ONLY; |
190 PropertyAttribute.DontEnum = DONT_ENUM; | 189 PropertyAttribute.DontEnum = DONT_ENUM; |
191 PropertyAttribute.DontDelete = DONT_DELETE; | 190 PropertyAttribute.DontDelete = DONT_DELETE; |
192 | 191 |
193 | 192 |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 }; | 676 }; |
678 | 677 |
679 | 678 |
680 ObjectMirror.prototype.hasIndexedInterceptor = function() { | 679 ObjectMirror.prototype.hasIndexedInterceptor = function() { |
681 // Get information on interceptors for this object. | 680 // Get information on interceptors for this object. |
682 var x = %GetInterceptorInfo(this.value_); | 681 var x = %GetInterceptorInfo(this.value_); |
683 return (x & 1) != 0; | 682 return (x & 1) != 0; |
684 }; | 683 }; |
685 | 684 |
686 | 685 |
| 686 // Get all own property names except for private symbols. |
| 687 function TryGetPropertyNames(object) { |
| 688 try { |
| 689 // TODO(yangguo): Should there be a special debugger implementation of |
| 690 // %GetOwnPropertyNames that doesn't perform access checks? |
| 691 return %GetOwnPropertyNames(object, PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL); |
| 692 } catch (e) { |
| 693 // Might have hit a failed access check. |
| 694 return []; |
| 695 } |
| 696 } |
| 697 |
| 698 |
687 /** | 699 /** |
688 * Return the property names for this object. | 700 * Return the property names for this object. |
689 * @param {number} kind Indicate whether named, indexed or both kinds of | 701 * @param {number} kind Indicate whether named, indexed or both kinds of |
690 * properties are requested | 702 * properties are requested |
691 * @param {number} limit Limit the number of names returend to the specified | 703 * @param {number} limit Limit the number of names returend to the specified |
692 value | 704 value |
693 * @return {Array} Property names for this object | 705 * @return {Array} Property names for this object |
694 */ | 706 */ |
695 ObjectMirror.prototype.propertyNames = function(kind, limit) { | 707 ObjectMirror.prototype.propertyNames = function(kind, limit) { |
696 // Find kind and limit and allocate array for the result | 708 // Find kind and limit and allocate array for the result |
697 kind = kind || PropertyKind.Named | PropertyKind.Indexed; | 709 kind = kind || PropertyKind.Named | PropertyKind.Indexed; |
698 | 710 |
699 var propertyNames; | 711 var propertyNames; |
700 var elementNames; | 712 var elementNames; |
701 var total = 0; | 713 var total = 0; |
702 | 714 |
703 // Find all the named properties. | 715 // Find all the named properties. |
704 if (kind & PropertyKind.Named) { | 716 if (kind & PropertyKind.Named) { |
705 // Get all own property names except for private symbols. | 717 propertyNames = TryGetPropertyNames(this.value_); |
706 propertyNames = | |
707 %GetOwnPropertyNames(this.value_, PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL); | |
708 total += propertyNames.length; | 718 total += propertyNames.length; |
709 | 719 |
710 // Get names for named interceptor properties if any. | 720 // Get names for named interceptor properties if any. |
711 if (this.hasNamedInterceptor() && (kind & PropertyKind.Named)) { | 721 if (this.hasNamedInterceptor() && (kind & PropertyKind.Named)) { |
712 var namedInterceptorNames = | 722 var namedInterceptorNames = |
713 %GetNamedInterceptorPropertyNames(this.value_); | 723 %GetNamedInterceptorPropertyNames(this.value_); |
714 if (namedInterceptorNames) { | 724 if (namedInterceptorNames) { |
715 propertyNames = propertyNames.concat(namedInterceptorNames); | 725 propertyNames = propertyNames.concat(namedInterceptorNames); |
716 total += namedInterceptorNames.length; | 726 total += namedInterceptorNames.length; |
717 } | 727 } |
(...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2869 } | 2879 } |
2870 if (!NUMBER_IS_FINITE(value)) { | 2880 if (!NUMBER_IS_FINITE(value)) { |
2871 if (value > 0) { | 2881 if (value > 0) { |
2872 return 'Infinity'; | 2882 return 'Infinity'; |
2873 } else { | 2883 } else { |
2874 return '-Infinity'; | 2884 return '-Infinity'; |
2875 } | 2885 } |
2876 } | 2886 } |
2877 return value; | 2887 return value; |
2878 } | 2888 } |
OLD | NEW |