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 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
| |
25 if (!IS_UNDEFINED(desc) && desc.enumerable) { | |
26 var propValue = from[key]; | |
27 %SetProperty(to, key, propValue, kStrictMode); | |
28 } | |
29 } | |
30 } | |
31 return to; | |
32 } | |
33 | |
34 | |
35 function HarmonyObjectExtendObjectPrototype() { | |
36 %CheckIsBootstrapping(); | |
37 | |
38 // Set up non-enumerable functions on the Object object. | |
39 InstallFunctions($Object, DONT_ENUM, $Array( | |
40 "assign", ObjectAssign | |
41 )); | |
42 } | |
43 | |
44 HarmonyObjectExtendObjectPrototype(); | |
OLD | NEW |