Index: src/harmony-object.js |
diff --git a/src/harmony-object.js b/src/harmony-object.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..87a0a7d82404d5c19cb3497c4171306ee97b2ce0 |
--- /dev/null |
+++ b/src/harmony-object.js |
@@ -0,0 +1,46 @@ |
+// 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. |
+// |
+ |
+(function() { |
+ |
+"use strict"; |
+ |
+%CheckIsBootstrapping(); |
+ |
+var GlobalObject = global.Object; |
+ |
+// ES6, draft 04-03-15, section 19.1.2.1 |
+function ObjectAssign(target, sources) { |
+ var to = TO_OBJECT_INLINE(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 = TO_OBJECT_INLINE(nextSource); |
+ var keys = $ownPropertyKeys(from); |
+ var len = keys.length; |
+ |
+ for (var j = 0; j < len; ++j) { |
+ var key = keys[j]; |
+ if (%IsPropertyEnumerable(from, key)) { |
+ var propValue = from[key]; |
+ to[key] = propValue; |
+ } |
+ } |
+ } |
+ return to; |
+} |
+ |
+// Set up non-enumerable functions on the Object object. |
+$installFunctions(GlobalObject, DONT_ENUM, [ |
+ "assign", ObjectAssign |
+]); |
+ |
+})(); |