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

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: Rebased 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') | src/v8natives.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 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();
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698