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

Unified Diff: src/v8natives.js

Issue 549050: Implement Object.getOwnPropertyNames constructor property [ES5 section 15.2.3... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/object-get-own-property-names.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
===================================================================
--- src/v8natives.js (revision 3610)
+++ src/v8natives.js (working copy)
@@ -276,7 +276,7 @@
function ObjectKeys(obj) {
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj))
- throw MakeTypeError('object_keys_non_object', [obj]);
+ throw MakeTypeError("obj_ctor_property_non_object", ["keys"]);
return %LocalKeys(obj);
}
@@ -493,23 +493,59 @@
// ES5 section 15.2.3.2.
function ObjectGetPrototypeOf(obj) {
- if (!IS_OBJECT(obj) && !IS_FUNCTION(obj)) {
- throw MakeTypeError("object_get_prototype_non_object", [obj]);
- }
- return obj.__proto__;
+ if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj))
+ throw MakeTypeError("obj_ctor_property_non_object", ["getPrototypeOf"]);
+ return obj.__proto__;
}
// ES5 section 15.2.3.3
function ObjectGetOwnPropertyDescriptor(obj, p) {
- if (!IS_OBJECT(obj) && !IS_FUNCTION(obj)) {
- throw MakeTypeError("object_get_prototype_non_object", [obj]);
- }
+ if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj))
+ throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyDescriptor"]);
var desc = GetOwnProperty(obj, p);
return FromPropertyDescriptor(desc);
}
+// ES5 section 15.2.3.4.
+function ObjectGetOwnPropertyNames(obj) {
+ if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj))
+ throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyNames"]);
+
+ // Find all the indexed properties.
+
+ // Get the local element names.
+ var propertyNames = %GetLocalElementNames(obj);
+
+ // Get names for indexed interceptor properties.
+ if (%GetInterceptorInfo(obj) & 1) {
+ var indexedInterceptorNames =
+ %GetIndexedInterceptorElementNames(obj);
+ if (indexedInterceptorNames) {
+ propertyNames = propertyNames.concat(indexedInterceptorNames);
+ }
+ }
+
+ // Find all the named properties.
+
+ // Get the local property names.
+ propertyNames = propertyNames.concat(%GetLocalPropertyNames(obj));
+
+ // Get names for named interceptor properties if any.
+
+ if (%GetInterceptorInfo(obj) & 2) {
+ var namedInterceptorNames =
+ %GetNamedInterceptorPropertyNames(obj);
+ if (namedInterceptorNames) {
+ propertyNames = propertyNames.concat(namedInterceptorNames);
+ }
+ }
+
+ return propertyNames;
+}
+
+
// ES5 section 15.2.3.5.
function ObjectCreate(proto, properties) {
if (!IS_OBJECT(proto) && !IS_NULL(proto)) {
@@ -576,7 +612,8 @@
"keys", ObjectKeys,
"create", ObjectCreate,
"getPrototypeOf", ObjectGetPrototypeOf,
- "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor
+ "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
+ "getOwnPropertyNames", ObjectGetOwnPropertyNames
));
}
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/object-get-own-property-names.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698