Index: src/harmony-object.js |
diff --git a/src/harmony-object.js b/src/harmony-object.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..190f0a6acc1e8e930d45a4923c3bdfc399088055 |
--- /dev/null |
+++ b/src/harmony-object.js |
@@ -0,0 +1,44 @@ |
+// Copyright 2014 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+// |
+ |
+// ES6, draft 10-14-14, section 19.1.2.1 |
+function ObjectAssign(target, sources) { |
+ var to = ToObject(target); |
+ var argsLen = %_ArgumentsLength(); |
+ if (argsLen < 2) return to; |
+ |
+ for (var i = 1; i < argsLen; ++i) { |
+ var nextSource = %_Arguments(i); |
+ if (IS_NULL_OR_UNDEFINED(nextSource)) { |
+ continue; |
+ } |
+ |
+ var from = ToObject(nextSource); |
+ var keys = ObjectGetOwnPropertyKeys(from); |
+ var len = keys.length; |
+ |
+ for (var j = 0; j < len; ++j) { |
+ var key = keys[j]; |
+ var desc = ObjectGetOwnPropertyDescriptor(from, key); |
arv (Not doing code reviews)
2014/12/02 14:41:19
I believe we an use ObjectPropertyIsEnumerable her
caitp (gmail)
2014/12/02 18:32:08
did these earlier --- I slightly modified the way
|
+ if (!IS_UNDEFINED(desc) && desc.enumerable) { |
+ var propValue = from[key]; |
+ %SetProperty(to, key, propValue, kStrictMode); |
+ } |
+ } |
+ } |
+ return to; |
+} |
+ |
+ |
+function HarmonyObjectExtendObjectPrototype() { |
+ %CheckIsBootstrapping(); |
+ |
+ // Set up non-enumerable functions on the Object object. |
+ InstallFunctions($Object, DONT_ENUM, $Array( |
+ "assign", ObjectAssign |
+ )); |
+} |
+ |
+HarmonyObjectExtendObjectPrototype(); |