OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 // | |
5 | |
6 // ES6, draft 10-14-14, section 19.1.2.1 | |
7 function ObjectAssign(target, sources) { | |
8 var to = ToObject(target); | |
9 var argsLen = %_ArgumentsLength(); | |
10 if (argsLen < 2) return to; | |
11 | |
12 for (var i = 1; i < argsLen; ++i) { | |
13 var nextSource = %_Arguments(i); | |
14 if (IS_NULL_OR_UNDEFINED(nextSource)) { | |
15 continue; | |
16 } | |
17 | |
18 var from = ToObject(nextSource); | |
19 var keys = ObjectGetOwnPropertyKeys(from); | |
20 var len = keys.length; | |
21 | |
22 for (var j = 0; j < len; ++j) { | |
23 var key = keys[j]; | |
24 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
| |
25 var propValue = from[key]; | |
26 %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.
| |
27 } | |
28 } | |
29 } | |
30 return to; | |
31 } | |
32 | |
33 | |
34 function HarmonyObjectExtendObjectPrototype() { | |
35 %CheckIsBootstrapping(); | |
36 | |
37 // Set up non-enumerable functions on the Object object. | |
38 InstallFunctions($Object, DONT_ENUM, $Array( | |
39 "assign", ObjectAssign | |
40 )); | |
41 } | |
42 | |
43 HarmonyObjectExtendObjectPrototype(); | |
OLD | NEW |