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

Unified Diff: src/v8natives.js

Issue 13533004: Make __proto__ a real JavaScript accessor property. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add regression test for issue 2606. Created 7 years, 9 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/regress/regress-2606.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index d9dc09651e65d7654ef1ee2e9193dc8a2d47f38b..8481b67a246bdb2f8f819034720534ff19c94d7e 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -61,7 +61,7 @@ function InstallFunctions(object, attributes, functions) {
}
-// Helper function to install a getter only property.
+// Helper function to install a getter-only accessor property.
function InstallGetter(object, name, getter) {
%FunctionSetName(getter, name);
%FunctionRemovePrototype(getter);
@@ -70,6 +70,12 @@ function InstallGetter(object, name, getter) {
}
+// Helper function to install a getter/setter accessor property/
rossberg 2013/04/03 13:42:23 Nit: / -> . at the end
Michael Starzinger 2013/04/04 09:48:02 Done.
+function InstallGetterSetter(object, name, getter, setter) {
rossberg 2013/04/03 13:42:23 Maybe cook up names that make clear that this func
Michael Starzinger 2013/04/04 09:48:02 Done. Oops, totally missed the boilerplate to adap
+ %DefineOrRedefineAccessorProperty(object, name, getter, setter, DONT_ENUM);
+}
+
+
// Prevents changes to the prototype of a built-in function.
// The "prototype" property of the function object is made non-configurable,
// and the prototype object is made non-extensible. The latter prevents
@@ -1326,6 +1332,18 @@ function ObjectIs(obj1, obj2) {
}
+// Harmony __proto__ getter.
+function ObjectGetProto() {
+ return %GetPrototype(this);
+}
+
+
+// Harmony __proto__ setter.
+function ObjectSetProto(obj) {
+ return %SetPrototype(this, obj);
+}
+
+
%SetCode($Object, function(x) {
if (%_IsConstructCall()) {
if (x == null) return this;
@@ -1336,14 +1354,16 @@ function ObjectIs(obj1, obj2) {
}
});
-%SetExpectedNumberOfProperties($Object, 4);
// ----------------------------------------------------------------------------
// Object
function SetUpObject() {
%CheckIsBootstrapping();
- // Set Up non-enumerable functions on the Object.prototype object.
+
+ %SetExpectedNumberOfProperties($Object, 4);
+
+ // Set up non-enumerable functions on the Object.prototype object.
InstallFunctions($Object.prototype, DONT_ENUM, $Array(
"toString", ObjectToString,
"toLocaleString", ObjectToLocaleString,
@@ -1356,6 +1376,10 @@ function SetUpObject() {
"__defineSetter__", ObjectDefineSetter,
"__lookupSetter__", ObjectLookupSetter
));
+ InstallGetterSetter($Object.prototype, "__proto__",
+ ObjectGetProto, ObjectSetProto);
+
+ // Set up non-enumerable functions in the Object object.
InstallFunctions($Object, DONT_ENUM, $Array(
"keys", ObjectKeys,
"create", ObjectCreate,
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/regress/regress-2606.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698