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

Unified Diff: src/v8natives.js

Issue 546032: Enabled es5conform tests for new array methods and corrected errors that was ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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/es5conform/es5conform.status » ('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 3592)
+++ src/v8natives.js (working copy)
@@ -305,6 +305,22 @@
return IsAccessorDescriptor(desc) && IsDataDescriptor(desc);
}
+// ES5 8.10.4
+function FromPropertyDescriptor(desc) {
+ if(IS_UNDEFINED(desc)) return desc;
+ var obj = new $Object();
+ if (IsDataDescriptor(desc)) {
+ obj.value = desc.getValue();
+ obj.writable = desc.isWritable();
+ }
+ if (IsAccessorDescriptor(desc)) {
+ obj.get = desc.getGet();
+ obj.set = desc.getSet();
+ }
+ obj.enumerable = desc.isEnumerable();
+ obj.configurable = desc.isConfigurable();
+ return obj;
+}
// ES5 8.10.5.
function ToPropertyDescriptor(obj) {
@@ -433,6 +449,33 @@
}
+// ES5 section 8.12.1.
+function GetOwnProperty(obj, p) {
+ var desc = new PropertyDescriptor();
+
+ // An array with:
+ // obj is a data property [false, value, Writeable, Enumerable, Configurable]
+ // obj is an accessor [true, Get, Set, Enumerable, Configurable]
+ var props = %GetOwnProperty(ToObject(obj), ToString(p));
+
+ if (IS_UNDEFINED(props))
+ return void 0;
+
+ // This is an accessor
+ if (props[0]) {
+ desc.setGet(props[1]);
+ desc.setSet(props[2]);
+ } else {
+ desc.setValue(props[1]);
+ desc.setWritable(props[2]);
+ }
+ desc.setEnumerable(props[3]);
+ desc.setConfigurable(props[4]);
+
+ return desc;
+}
+
+
// ES5 8.12.9. This version cannot cope with the property p already
// being present on obj.
function DefineOwnProperty(obj, p, desc, should_throw) {
@@ -457,6 +500,16 @@
}
+// 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]);
+ }
+ var desc = GetOwnProperty(obj, p);
+ return FromPropertyDescriptor(desc);
+}
+
+
// ES5 section 15.2.3.5.
function ObjectCreate(proto, properties) {
if (!IS_OBJECT(proto) && !IS_NULL(proto)) {
@@ -522,7 +575,8 @@
InstallFunctions($Object, DONT_ENUM, $Array(
"keys", ObjectKeys,
"create", ObjectCreate,
- "getPrototypeOf", ObjectGetPrototypeOf
+ "getPrototypeOf", ObjectGetPrototypeOf,
+ "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor
));
}
« no previous file with comments | « src/runtime.cc ('k') | test/es5conform/es5conform.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698