Chromium Code Reviews| Index: src/harmony-object.js |
| diff --git a/src/harmony-object.js b/src/harmony-object.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f352e75041cbd5b12d5d0ff3d77d35f851973761 |
| --- /dev/null |
| +++ b/src/harmony-object.js |
| @@ -0,0 +1,43 @@ |
| +// 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]; |
| + if (ObjectPropertyIsEnumerableJS(from, key)) { |
|
arv (Not doing code reviews)
2014/12/02 19:16:06
You can do %_CallFunction here so you do not need
caitp (gmail)
2014/12/02 19:39:01
Done --- It's much harder to read like this though
|
| + var propValue = from[key]; |
| + %SetProperty(to, key, propValue, kStrictMode); |
|
arv (Not doing code reviews)
2014/12/02 19:16:06
I don't think this needs a runtime.
to[key] = pro
caitp (gmail)
2014/12/02 19:39:01
Done.
|
| + } |
| + } |
| + } |
| + return to; |
| +} |
| + |
| + |
| +function HarmonyObjectExtendObjectPrototype() { |
| + %CheckIsBootstrapping(); |
| + |
| + // Set up non-enumerable functions on the Object object. |
| + InstallFunctions($Object, DONT_ENUM, $Array( |
| + "assign", ObjectAssign |
| + )); |
| +} |
| + |
| +HarmonyObjectExtendObjectPrototype(); |