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

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: Rebase + IIFE Created 5 years, 7 months 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
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 var $objectAssign;
arv (Not doing code reviews) 2015/05/06 15:35:48 This is never used. I think the idea is to only "e
caitp (gmail) 2015/05/06 15:40:26 Acknowledged.
7
8 (function() {
9
10 "use strict";
11
12 %CheckIsBootstrapping();
13
14 var GlobalObject = global.Object;
15
16 // ES6, draft 04-03-15, section 19.1.2.1
17 function ObjectAssign(target, sources) {
18 var to = TO_OBJECT_INLINE(target);
19 var argsLen = %_ArgumentsLength();
20 if (argsLen < 2) return to;
21
22 for (var i = 1; i < argsLen; ++i) {
23 var nextSource = %_Arguments(i);
24 if (IS_NULL_OR_UNDEFINED(nextSource)) {
25 continue;
26 }
27
28 var from = TO_OBJECT_INLINE(nextSource);
29 var keys = $ownPropertyKeys(from);
30 var len = keys.length;
31
32 for (var j = 0; j < len; ++j) {
33 var key = keys[j];
34 if (%_CallFunction(from, key, $propertyIsEnumerable)) {
arv (Not doing code reviews) 2015/05/06 15:35:48 I wonder if this does anything extra over [[GetOwn
caitp (gmail) 2015/05/06 15:40:26 I can't remember why went with this, maybe [[GetOw
caitp (gmail) 2015/05/06 15:42:59 Wait no, $propertyIsEnumerable looks like it's a b
arv (Not doing code reviews) 2015/05/06 15:44:34 Maybe we could have something even lower level her
35 var propValue = from[key];
36 to[key] = propValue;
37 }
38 }
39 }
40 return to;
41 }
42
43 // Set up non-enumerable functions on the Object object.
44 $installFunctions(GlobalObject, DONT_ENUM, [
45 "assign", ObjectAssign
46 ]);
47
48 $objectAssign = ObjectAssign;
49
50 })();
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/v8natives.js » ('j') | src/v8natives.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698