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 "use strict"; | 4 "use strict"; |
5 | 5 |
6 // Handle id counters. | 6 // Handle id counters. |
7 var next_handle_ = 0; | 7 var next_handle_ = 0; |
8 var next_transient_handle_ = -1; | 8 var next_transient_handle_ = -1; |
9 | 9 |
10 // Mirror cache. | 10 // Mirror cache. |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 | 897 |
898 /** | 898 /** |
899 * Return the internal properties of the value, such as [[PrimitiveValue]] of | 899 * Return the internal properties of the value, such as [[PrimitiveValue]] of |
900 * scalar wrapper objects, properties of the bound function and properties of | 900 * scalar wrapper objects, properties of the bound function and properties of |
901 * the promise. | 901 * the promise. |
902 * This method is done static to be accessible from Debug API with the bare | 902 * This method is done static to be accessible from Debug API with the bare |
903 * values without mirrors. | 903 * values without mirrors. |
904 * @return {Array} array (possibly empty) of InternalProperty instances | 904 * @return {Array} array (possibly empty) of InternalProperty instances |
905 */ | 905 */ |
906 ObjectMirror.GetInternalProperties = function(value) { | 906 ObjectMirror.GetInternalProperties = function(value) { |
907 var properties = %DebugGetInternalProperties(value); | 907 if (IS_STRING_WRAPPER(value) || IS_NUMBER_WRAPPER(value) || |
908 var result = []; | 908 IS_BOOLEAN_WRAPPER(value)) { |
909 for (var i = 0; i < properties.length; i += 2) { | 909 var primitiveValue = %_ValueOf(value); |
910 result.push(new InternalPropertyMirror(properties[i], properties[i + 1])); | 910 return [new InternalPropertyMirror("[[PrimitiveValue]]", primitiveValue)]; |
| 911 } else if (IS_FUNCTION(value)) { |
| 912 var bindings = %BoundFunctionGetBindings(value); |
| 913 var result = []; |
| 914 if (bindings && IS_ARRAY(bindings)) { |
| 915 result.push(new InternalPropertyMirror("[[TargetFunction]]", |
| 916 bindings[0])); |
| 917 result.push(new InternalPropertyMirror("[[BoundThis]]", bindings[1])); |
| 918 var boundArgs = []; |
| 919 for (var i = 2; i < bindings.length; i++) { |
| 920 boundArgs.push(bindings[i]); |
| 921 } |
| 922 result.push(new InternalPropertyMirror("[[BoundArgs]]", boundArgs)); |
| 923 } |
| 924 return result; |
| 925 } else if (IS_MAP_ITERATOR(value) || IS_SET_ITERATOR(value)) { |
| 926 var details = IS_MAP_ITERATOR(value) ? %MapIteratorDetails(value) |
| 927 : %SetIteratorDetails(value); |
| 928 var kind; |
| 929 switch (details[2]) { |
| 930 case 1: kind = "keys"; break; |
| 931 case 2: kind = "values"; break; |
| 932 case 3: kind = "entries"; break; |
| 933 } |
| 934 var result = [ |
| 935 new InternalPropertyMirror("[[IteratorHasMore]]", details[0]), |
| 936 new InternalPropertyMirror("[[IteratorIndex]]", details[1]) |
| 937 ]; |
| 938 if (kind) { |
| 939 result.push(new InternalPropertyMirror("[[IteratorKind]]", kind)); |
| 940 } |
| 941 return result; |
| 942 } else if (IS_GENERATOR(value)) { |
| 943 return [ |
| 944 new InternalPropertyMirror("[[GeneratorStatus]]", |
| 945 GeneratorGetStatus_(value)), |
| 946 new InternalPropertyMirror("[[GeneratorFunction]]", |
| 947 %GeneratorGetFunction(value)), |
| 948 new InternalPropertyMirror("[[GeneratorReceiver]]", |
| 949 %GeneratorGetReceiver(value)) |
| 950 ]; |
| 951 } else if (ObjectIsPromise(value)) { |
| 952 return [ |
| 953 new InternalPropertyMirror("[[PromiseStatus]]", PromiseGetStatus_(value)), |
| 954 new InternalPropertyMirror("[[PromiseValue]]", PromiseGetValue_(value)) |
| 955 ]; |
911 } | 956 } |
912 return result; | 957 return []; |
913 } | 958 } |
914 | 959 |
915 | 960 |
916 /** | 961 /** |
917 * Mirror object for functions. | 962 * Mirror object for functions. |
918 * @param {function} value The function object reflected by this mirror. | 963 * @param {function} value The function object reflected by this mirror. |
919 * @constructor | 964 * @constructor |
920 * @extends ObjectMirror | 965 * @extends ObjectMirror |
921 */ | 966 */ |
922 function FunctionMirror(value) { | 967 function FunctionMirror(value) { |
(...skipping 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3017 } | 3062 } |
3018 if (!NUMBER_IS_FINITE(value)) { | 3063 if (!NUMBER_IS_FINITE(value)) { |
3019 if (value > 0) { | 3064 if (value > 0) { |
3020 return 'Infinity'; | 3065 return 'Infinity'; |
3021 } else { | 3066 } else { |
3022 return '-Infinity'; | 3067 return '-Infinity'; |
3023 } | 3068 } |
3024 } | 3069 } |
3025 return value; | 3070 return value; |
3026 } | 3071 } |
OLD | NEW |