Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: src/harmony-object.js

Issue 548833002: [es6] implement Object.assign (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove pendingException, move behind harmony-object flag, fix Symbol properties Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/flag-definitions.h ('k') | test/mjsunit/harmony/object-assign.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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();
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | test/mjsunit/harmony/object-assign.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698