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

Unified Diff: src/v8natives.js

Issue 141913002: ES6: Implement Object.setPrototypeOf (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index e987baf6d6b36ff3708c770a76ab8f463b657a46..71b1e4880b7bd75fb7a9e95f25697e7323651861 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1015,6 +1015,24 @@ function ObjectGetPrototypeOf(obj) {
return %GetPrototype(obj);
}
+// ES6 section 19.1.2.19.
+function ObjectSetPrototypeOf(obj, proto) {
+ if (IS_NULL_OR_UNDEFINED(obj) && !IS_UNDETECTABLE(obj)) {
arv (Not doing code reviews) 2014/01/17 17:43:23 The ES6 spec uses CheckObjectCoercible. It comes u
Dmitry Lomov (no reviews) 2014/01/17 20:17:36 Agreed, good idea.
+ throw MakeTypeError("called_on_null_or_undefined",
+ ["Object.setPrototypeOf"]);
+ }
+
+ if (proto !== null && !IS_SPEC_OBJECT(proto)) {
+ throw MakeTypeError("proto_object_or_null", [proto]);
+ }
+
+ if (IS_SPEC_OBJECT(obj)) {
+ %SetPrototype(obj, proto);
+ }
+
+ return obj;
+}
+
// ES5 section 15.2.3.3
function ObjectGetOwnPropertyDescriptor(obj, p) {
@@ -1443,6 +1461,7 @@ function SetUpObject() {
"defineProperties", ObjectDefineProperties,
"freeze", ObjectFreeze,
"getPrototypeOf", ObjectGetPrototypeOf,
+ "setPrototypeOf", ObjectSetPrototypeOf,
"getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
"getOwnPropertyNames", ObjectGetOwnPropertyNames,
// getOwnPropertySymbols is added in symbol.js.

Powered by Google App Engine
This is Rietveld 408576698