Index: src/js/v8natives.js |
diff --git a/src/js/v8natives.js b/src/js/v8natives.js |
index 44be9419766b49424e1c522af9cb82c7032c4ff7..be7271b1f061dcf61b7b04e815cebc327edd7b58 100644 |
--- a/src/js/v8natives.js |
+++ b/src/js/v8natives.js |
@@ -142,6 +142,52 @@ |
return %PropertyIsEnumerable(TO_OBJECT(this), P); |
} |
+ |
+// Extensions for providing property getters and setters. |
+function ObjectDefineGetter(name, fun) { |
+ var receiver = this; |
+ if (IS_NULL(receiver) || IS_UNDEFINED(receiver)) { |
+ receiver = %GlobalProxy(ObjectDefineGetter); |
+ } |
+ if (!IS_CALLABLE(fun)) { |
+ throw MakeTypeError(kObjectGetterExpectingFunction); |
+ } |
+ var desc = {get: fun, enumerable: true, configurable: true}; |
+ %reflect_define_property(receiver, name, desc); |
+} |
+ |
+ |
+function ObjectLookupGetter(name) { |
+ var receiver = this; |
+ if (IS_NULL(receiver) || IS_UNDEFINED(receiver)) { |
+ receiver = %GlobalProxy(ObjectLookupGetter); |
+ } |
+ return %LookupAccessor(TO_OBJECT(receiver), TO_NAME(name), GETTER); |
+} |
+ |
+ |
+function ObjectDefineSetter(name, fun) { |
+ var receiver = this; |
+ if (IS_NULL(receiver) || IS_UNDEFINED(receiver)) { |
+ receiver = %GlobalProxy(ObjectDefineSetter); |
+ } |
+ if (!IS_CALLABLE(fun)) { |
+ throw MakeTypeError(kObjectSetterExpectingFunction); |
+ } |
+ var desc = {set: fun, enumerable: true, configurable: true}; |
+ %reflect_define_property(receiver, name, desc); |
+} |
+ |
+ |
+function ObjectLookupSetter(name) { |
+ var receiver = this; |
+ if (IS_NULL(receiver) || IS_UNDEFINED(receiver)) { |
+ receiver = %GlobalProxy(ObjectLookupSetter); |
+ } |
+ return %LookupAccessor(TO_OBJECT(receiver), TO_NAME(name), SETTER); |
+} |
+ |
+ |
// ES6 7.3.9 |
function GetMethod(obj, p) { |
var func = obj[p]; |
@@ -150,6 +196,7 @@ |
throw MakeTypeError(kCalledNonCallable, typeof func); |
} |
+ |
// ES6 section 19.1.2.18. |
function ObjectSetPrototypeOf(obj, proto) { |
CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf"); |
@@ -164,6 +211,7 @@ |
return obj; |
} |
+ |
// ES6 B.2.2.1.1 |
function ObjectGetProto() { |
@@ -207,10 +255,10 @@ |
"valueOf", ObjectValueOf, |
"isPrototypeOf", ObjectIsPrototypeOf, |
"propertyIsEnumerable", ObjectPropertyIsEnumerable, |
- // __defineGetter__ is added in bootstrapper.cc. |
- // __lookupGetter__ is added in bootstrapper.cc. |
- // __defineSetter__ is added in bootstrapper.cc. |
- // __lookupSetter__ is added in bootstrapper.cc. |
+ "__defineGetter__", ObjectDefineGetter, |
+ "__lookupGetter__", ObjectLookupGetter, |
+ "__defineSetter__", ObjectDefineSetter, |
+ "__lookupSetter__", ObjectLookupSetter |
]); |
utils.InstallGetterSetter( |
GlobalObject.prototype, "__proto__", ObjectGetProto, ObjectSetProto); |