OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 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 // This file relies on the fact that the following declarations have been made | 5 // This file relies on the fact that the following declarations have been made |
6 // in runtime.js: | 6 // in runtime.js: |
7 // var $Object = global.Object; | 7 // var $Object = global.Object; |
8 // var $Boolean = global.Boolean; | 8 // var $Boolean = global.Boolean; |
9 // var $Number = global.Number; | 9 // var $Number = global.Number; |
10 // var $Function = global.Function; | 10 // var $Function = global.Function; |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 } | 1031 } |
1032 array[index] = s; | 1032 array[index] = s; |
1033 ++realLength; | 1033 ++realLength; |
1034 names[s] = 0; | 1034 names[s] = 0; |
1035 } | 1035 } |
1036 array.length = realLength; | 1036 array.length = realLength; |
1037 return array; | 1037 return array; |
1038 } | 1038 } |
1039 | 1039 |
1040 | 1040 |
1041 function ObjectGetOwnPropertyKeys(obj, symbolsOnly) { | 1041 function ObjectGetOwnPropertyKeys(obj, filter) { |
1042 var nameArrays = new InternalArray(); | 1042 var nameArrays = new InternalArray(); |
1043 var filter = symbolsOnly ? | 1043 filter = (filter || PROPERTY_ATTRIBUTES_NONE) |
rossberg
2014/09/10 07:37:59
Please remove the defaulting and make sure that it
caitp (gmail)
2014/09/10 16:54:11
`filter |= PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL` wou
| |
1044 PROPERTY_ATTRIBUTES_STRING | PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL : | 1044 | PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL; |
1045 PROPERTY_ATTRIBUTES_SYMBOLIC; | |
1046 | 1045 |
1047 // Find all the indexed properties. | 1046 // Find all the indexed properties. |
1048 | 1047 |
1049 // Only get own element names if we want to include string keys. | 1048 // Only get own element names if we want to include string keys. |
1050 if (!symbolsOnly) { | 1049 if ((filter & PROPERTY_ATTRIBUTES_STRING) === 0) { |
1051 var ownElementNames = %GetOwnElementNames(obj); | 1050 var ownElementNames = %GetOwnElementNames(obj); |
1052 for (var i = 0; i < ownElementNames.length; ++i) { | 1051 for (var i = 0; i < ownElementNames.length; ++i) { |
1053 ownElementNames[i] = %_NumberToString(ownElementNames[i]); | 1052 ownElementNames[i] = %_NumberToString(ownElementNames[i]); |
1054 } | 1053 } |
1055 nameArrays.push(ownElementNames); | 1054 nameArrays.push(ownElementNames); |
1056 | 1055 |
1057 // Get names for indexed interceptor properties. | 1056 // Get names for indexed interceptor properties. |
1058 var interceptorInfo = %GetInterceptorInfo(obj); | 1057 var interceptorInfo = %GetInterceptorInfo(obj); |
1059 if ((interceptorInfo & 1) != 0) { | 1058 if ((interceptorInfo & 1) != 0) { |
1060 var indexedInterceptorNames = %GetIndexedInterceptorElementNames(obj); | 1059 var indexedInterceptorNames = %GetIndexedInterceptorElementNames(obj); |
(...skipping 21 matching lines...) Expand all Loading... | |
1082 %Apply(InternalArray.prototype.concat, | 1081 %Apply(InternalArray.prototype.concat, |
1083 nameArrays[0], nameArrays, 1, nameArrays.length - 1); | 1082 nameArrays[0], nameArrays, 1, nameArrays.length - 1); |
1084 | 1083 |
1085 // Property names are expected to be unique strings, | 1084 // Property names are expected to be unique strings, |
1086 // but interceptors can interfere with that assumption. | 1085 // but interceptors can interfere with that assumption. |
1087 if (interceptorInfo != 0) { | 1086 if (interceptorInfo != 0) { |
1088 var seenKeys = { __proto__: null }; | 1087 var seenKeys = { __proto__: null }; |
1089 var j = 0; | 1088 var j = 0; |
1090 for (var i = 0; i < propertyNames.length; ++i) { | 1089 for (var i = 0; i < propertyNames.length; ++i) { |
1091 var name = propertyNames[i]; | 1090 var name = propertyNames[i]; |
1092 if (symbolsOnly) { | 1091 |
1093 if (!IS_SYMBOL(name) || IS_PRIVATE(name)) continue; | 1092 if (IS_SYMBOL(name)) { |
1093 if ((filter & PROPERTY_ATTRIBUTES_SYMBOLIC) || IS_PRIVATE(name)) { | |
1094 continue; | |
1095 } | |
1094 } else { | 1096 } else { |
1095 if (IS_SYMBOL(name)) continue; | 1097 if (filter & PROPERTY_ATTRIBUTES_STRING) continue; |
1096 name = ToString(name); | 1098 name = ToString(name); |
1097 } | 1099 } |
1100 | |
1098 if (seenKeys[name]) continue; | 1101 if (seenKeys[name]) continue; |
1099 seenKeys[name] = true; | 1102 seenKeys[name] = true; |
1100 propertyNames[j++] = name; | 1103 propertyNames[j++] = name; |
1101 } | 1104 } |
1102 propertyNames.length = j; | 1105 propertyNames.length = j; |
1103 } | 1106 } |
1104 | 1107 |
1105 return propertyNames; | 1108 return propertyNames; |
1106 } | 1109 } |
1107 | 1110 |
1108 | 1111 |
1109 // ES5 section 15.2.3.4. | 1112 // ES5 section 15.2.3.4. |
1110 function ObjectGetOwnPropertyNames(obj) { | 1113 function ObjectGetOwnPropertyNames(obj) { |
1111 if (!IS_SPEC_OBJECT(obj)) { | 1114 if (!IS_SPEC_OBJECT(obj)) { |
1112 throw MakeTypeError("called_on_non_object", ["Object.getOwnPropertyNames"]); | 1115 throw MakeTypeError("called_on_non_object", ["Object.getOwnPropertyNames"]); |
1113 } | 1116 } |
1114 // Special handling for proxies. | 1117 // Special handling for proxies. |
1115 if (%IsJSProxy(obj)) { | 1118 if (%IsJSProxy(obj)) { |
1116 var handler = %GetHandler(obj); | 1119 var handler = %GetHandler(obj); |
1117 var names = CallTrap0(handler, "getOwnPropertyNames", UNDEFINED); | 1120 var names = CallTrap0(handler, "getOwnPropertyNames", UNDEFINED); |
1118 return ToNameArray(names, "getOwnPropertyNames", false); | 1121 return ToNameArray(names, "getOwnPropertyNames", false); |
1119 } | 1122 } |
1120 | 1123 |
1121 return ObjectGetOwnPropertyKeys(obj, false); | 1124 return ObjectGetOwnPropertyKeys(obj, PROPERTY_ATTRIBUTES_SYMBOLIC); |
1122 } | 1125 } |
1123 | 1126 |
1124 | 1127 |
1125 // ES5 section 15.2.3.5. | 1128 // ES5 section 15.2.3.5. |
1126 function ObjectCreate(proto, properties) { | 1129 function ObjectCreate(proto, properties) { |
1127 if (!IS_SPEC_OBJECT(proto) && proto !== null) { | 1130 if (!IS_SPEC_OBJECT(proto) && proto !== null) { |
1128 throw MakeTypeError("proto_object_or_null", [proto]); | 1131 throw MakeTypeError("proto_object_or_null", [proto]); |
1129 } | 1132 } |
1130 var obj = {}; | 1133 var obj = {}; |
1131 %InternalSetPrototype(obj, proto); | 1134 %InternalSetPrototype(obj, proto); |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1901 } | 1904 } |
1902 if (!IS_SPEC_FUNCTION(method)) { | 1905 if (!IS_SPEC_FUNCTION(method)) { |
1903 throw MakeTypeError('not_iterable', [obj]); | 1906 throw MakeTypeError('not_iterable', [obj]); |
1904 } | 1907 } |
1905 var iterator = %_CallFunction(obj, method); | 1908 var iterator = %_CallFunction(obj, method); |
1906 if (!IS_SPEC_OBJECT(iterator)) { | 1909 if (!IS_SPEC_OBJECT(iterator)) { |
1907 throw MakeTypeError('not_an_iterator', [iterator]); | 1910 throw MakeTypeError('not_an_iterator', [iterator]); |
1908 } | 1911 } |
1909 return iterator; | 1912 return iterator; |
1910 } | 1913 } |
OLD | NEW |