Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1100)

Side by Side Diff: src/v8natives.js

Issue 291153005: Consistently say 'own' property (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add new files Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/stub-cache.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 237
238 // ECMA-262 - 15.2.4.5 238 // ECMA-262 - 15.2.4.5
239 function ObjectHasOwnProperty(V) { 239 function ObjectHasOwnProperty(V) {
240 if (%IsJSProxy(this)) { 240 if (%IsJSProxy(this)) {
241 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 241 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
242 if (IS_SYMBOL(V)) return false; 242 if (IS_SYMBOL(V)) return false;
243 243
244 var handler = %GetHandler(this); 244 var handler = %GetHandler(this);
245 return CallTrap1(handler, "hasOwn", DerivedHasOwnTrap, ToName(V)); 245 return CallTrap1(handler, "hasOwn", DerivedHasOwnTrap, ToName(V));
246 } 246 }
247 return %HasLocalProperty(TO_OBJECT_INLINE(this), ToName(V)); 247 return %HasOwnProperty(TO_OBJECT_INLINE(this), ToName(V));
248 } 248 }
249 249
250 250
251 // ECMA-262 - 15.2.4.6 251 // ECMA-262 - 15.2.4.6
252 function ObjectIsPrototypeOf(V) { 252 function ObjectIsPrototypeOf(V) {
253 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf"); 253 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf");
254 if (!IS_SPEC_OBJECT(V)) return false; 254 if (!IS_SPEC_OBJECT(V)) return false;
255 return %IsInPrototypeChain(this, V); 255 return %IsInPrototypeChain(this, V);
256 } 256 }
257 257
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 325
326 function ObjectKeys(obj) { 326 function ObjectKeys(obj) {
327 if (!IS_SPEC_OBJECT(obj)) { 327 if (!IS_SPEC_OBJECT(obj)) {
328 throw MakeTypeError("called_on_non_object", ["Object.keys"]); 328 throw MakeTypeError("called_on_non_object", ["Object.keys"]);
329 } 329 }
330 if (%IsJSProxy(obj)) { 330 if (%IsJSProxy(obj)) {
331 var handler = %GetHandler(obj); 331 var handler = %GetHandler(obj);
332 var names = CallTrap0(handler, "keys", DerivedKeysTrap); 332 var names = CallTrap0(handler, "keys", DerivedKeysTrap);
333 return ToNameArray(names, "keys", false); 333 return ToNameArray(names, "keys", false);
334 } 334 }
335 return %LocalKeys(obj); 335 return %OwnKeys(obj);
336 } 336 }
337 337
338 338
339 // ES5 8.10.1. 339 // ES5 8.10.1.
340 function IsAccessorDescriptor(desc) { 340 function IsAccessorDescriptor(desc) {
341 if (IS_UNDEFINED(desc)) return false; 341 if (IS_UNDEFINED(desc)) return false;
342 return desc.hasGetter() || desc.hasSetter(); 342 return desc.hasGetter() || desc.hasSetter();
343 } 343 }
344 344
345 345
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 throw MakeTypeError("proxy_non_object_prop_names", [obj, trap]); 1018 throw MakeTypeError("proxy_non_object_prop_names", [obj, trap]);
1019 } 1019 }
1020 var n = ToUint32(obj.length); 1020 var n = ToUint32(obj.length);
1021 var array = new $Array(n); 1021 var array = new $Array(n);
1022 var realLength = 0; 1022 var realLength = 0;
1023 var names = { __proto__: null }; // TODO(rossberg): use sets once ready. 1023 var names = { __proto__: null }; // TODO(rossberg): use sets once ready.
1024 for (var index = 0; index < n; index++) { 1024 for (var index = 0; index < n; index++) {
1025 var s = ToName(obj[index]); 1025 var s = ToName(obj[index]);
1026 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 1026 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
1027 if (IS_SYMBOL(s) && !includeSymbols) continue; 1027 if (IS_SYMBOL(s) && !includeSymbols) continue;
1028 if (%HasLocalProperty(names, s)) { 1028 if (%HasOwnProperty(names, s)) {
1029 throw MakeTypeError("proxy_repeated_prop_name", [obj, trap, s]); 1029 throw MakeTypeError("proxy_repeated_prop_name", [obj, trap, s]);
1030 } 1030 }
1031 array[index] = s; 1031 array[index] = s;
1032 ++realLength; 1032 ++realLength;
1033 names[s] = 0; 1033 names[s] = 0;
1034 } 1034 }
1035 array.length = realLength; 1035 array.length = realLength;
1036 return array; 1036 return array;
1037 } 1037 }
1038 1038
1039 1039
1040 function ObjectGetOwnPropertyKeys(obj, symbolsOnly) { 1040 function ObjectGetOwnPropertyKeys(obj, symbolsOnly) {
1041 var nameArrays = new InternalArray(); 1041 var nameArrays = new InternalArray();
1042 var filter = symbolsOnly ? 1042 var filter = symbolsOnly ?
1043 PROPERTY_ATTRIBUTES_STRING | PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL : 1043 PROPERTY_ATTRIBUTES_STRING | PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL :
1044 PROPERTY_ATTRIBUTES_SYMBOLIC; 1044 PROPERTY_ATTRIBUTES_SYMBOLIC;
1045 1045
1046 // Find all the indexed properties. 1046 // Find all the indexed properties.
1047 1047
1048 // Only get the local element names if we want to include string keys. 1048 // Only get own element names if we want to include string keys.
1049 if (!symbolsOnly) { 1049 if (!symbolsOnly) {
1050 var localElementNames = %GetLocalElementNames(obj); 1050 var ownElementNames = %GetOwnElementNames(obj);
1051 for (var i = 0; i < localElementNames.length; ++i) { 1051 for (var i = 0; i < ownElementNames.length; ++i) {
1052 localElementNames[i] = %_NumberToString(localElementNames[i]); 1052 ownElementNames[i] = %_NumberToString(ownElementNames[i]);
1053 } 1053 }
1054 nameArrays.push(localElementNames); 1054 nameArrays.push(ownElementNames);
1055 1055
1056 // Get names for indexed interceptor properties. 1056 // Get names for indexed interceptor properties.
1057 var interceptorInfo = %GetInterceptorInfo(obj); 1057 var interceptorInfo = %GetInterceptorInfo(obj);
1058 if ((interceptorInfo & 1) != 0) { 1058 if ((interceptorInfo & 1) != 0) {
1059 var indexedInterceptorNames = %GetIndexedInterceptorElementNames(obj); 1059 var indexedInterceptorNames = %GetIndexedInterceptorElementNames(obj);
1060 if (!IS_UNDEFINED(indexedInterceptorNames)) { 1060 if (!IS_UNDEFINED(indexedInterceptorNames)) {
1061 nameArrays.push(indexedInterceptorNames); 1061 nameArrays.push(indexedInterceptorNames);
1062 } 1062 }
1063 } 1063 }
1064 } 1064 }
1065 1065
1066 // Find all the named properties. 1066 // Find all the named properties.
1067 1067
1068 // Get the local property names. 1068 // Get own property names.
1069 nameArrays.push(%GetLocalPropertyNames(obj, filter)); 1069 nameArrays.push(%GetOwnPropertyNames(obj, filter));
1070 1070
1071 // Get names for named interceptor properties if any. 1071 // Get names for named interceptor properties if any.
1072 if ((interceptorInfo & 2) != 0) { 1072 if ((interceptorInfo & 2) != 0) {
1073 var namedInterceptorNames = 1073 var namedInterceptorNames =
1074 %GetNamedInterceptorPropertyNames(obj); 1074 %GetNamedInterceptorPropertyNames(obj);
1075 if (!IS_UNDEFINED(namedInterceptorNames)) { 1075 if (!IS_UNDEFINED(namedInterceptorNames)) {
1076 nameArrays.push(namedInterceptorNames); 1076 nameArrays.push(namedInterceptorNames);
1077 } 1077 }
1078 } 1078 }
1079 1079
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 DefineProxyProperty(obj, name, attributesClone, true); 1149 DefineProxyProperty(obj, name, attributesClone, true);
1150 // The following would implement the spec as in the current proposal, 1150 // The following would implement the spec as in the current proposal,
1151 // but after recent comments on es-discuss, is most likely obsolete. 1151 // but after recent comments on es-discuss, is most likely obsolete.
1152 /* 1152 /*
1153 var defineObj = FromGenericPropertyDescriptor(desc); 1153 var defineObj = FromGenericPropertyDescriptor(desc);
1154 var names = ObjectGetOwnPropertyNames(attributes); 1154 var names = ObjectGetOwnPropertyNames(attributes);
1155 var standardNames = 1155 var standardNames =
1156 {value: 0, writable: 0, get: 0, set: 0, enumerable: 0, configurable: 0}; 1156 {value: 0, writable: 0, get: 0, set: 0, enumerable: 0, configurable: 0};
1157 for (var i = 0; i < names.length; i++) { 1157 for (var i = 0; i < names.length; i++) {
1158 var N = names[i]; 1158 var N = names[i];
1159 if (!(%HasLocalProperty(standardNames, N))) { 1159 if (!(%HasOwnProperty(standardNames, N))) {
1160 var attr = GetOwnPropertyJS(attributes, N); 1160 var attr = GetOwnPropertyJS(attributes, N);
1161 DefineOwnProperty(descObj, N, attr, true); 1161 DefineOwnProperty(descObj, N, attr, true);
1162 } 1162 }
1163 } 1163 }
1164 // This is really confusing the types, but it is what the proxies spec 1164 // This is really confusing the types, but it is what the proxies spec
1165 // currently requires: 1165 // currently requires:
1166 desc = descObj; 1166 desc = descObj;
1167 */ 1167 */
1168 } else { 1168 } else {
1169 var desc = ToPropertyDescriptor(attributes); 1169 var desc = ToPropertyDescriptor(attributes);
1170 DefineOwnProperty(obj, name, desc, true); 1170 DefineOwnProperty(obj, name, desc, true);
1171 } 1171 }
1172 return obj; 1172 return obj;
1173 } 1173 }
1174 1174
1175 1175
1176 function GetOwnEnumerablePropertyNames(properties) { 1176 function GetOwnEnumerablePropertyNames(properties) {
1177 var names = new InternalArray(); 1177 var names = new InternalArray();
1178 for (var key in properties) { 1178 for (var key in properties) {
1179 if (%HasLocalProperty(properties, key)) { 1179 if (%HasOwnProperty(properties, key)) {
1180 names.push(key); 1180 names.push(key);
1181 } 1181 }
1182 } 1182 }
1183 return names; 1183 return names;
1184 } 1184 }
1185 1185
1186 1186
1187 // ES5 section 15.2.3.7. 1187 // ES5 section 15.2.3.7.
1188 function ObjectDefineProperties(obj, properties) { 1188 function ObjectDefineProperties(obj, properties) {
1189 if (!IS_SPEC_OBJECT(obj)) { 1189 if (!IS_SPEC_OBJECT(obj)) {
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 %SetCode($Function, FunctionConstructor); 1855 %SetCode($Function, FunctionConstructor);
1856 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM); 1856 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
1857 1857
1858 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1858 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1859 "bind", FunctionBind, 1859 "bind", FunctionBind,
1860 "toString", FunctionToString 1860 "toString", FunctionToString
1861 )); 1861 ));
1862 } 1862 }
1863 1863
1864 SetUpFunction(); 1864 SetUpFunction();
OLDNEW
« no previous file with comments | « src/stub-cache.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698