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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | src/v8natives.js » ('j') | src/v8natives.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/harmony-object.js
diff --git a/src/harmony-object.js b/src/harmony-object.js
new file mode 100644
index 0000000000000000000000000000000000000000..529184d30f4b6161f99593b30b7289209779c5a9
--- /dev/null
+++ b/src/harmony-object.js
@@ -0,0 +1,50 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+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.
+
+(function() {
+
+"use strict";
+
+%CheckIsBootstrapping();
+
+var GlobalObject = global.Object;
+
+// ES6, draft 04-03-15, section 19.1.2.1
+function ObjectAssign(target, sources) {
+ var to = TO_OBJECT_INLINE(target);
+ var argsLen = %_ArgumentsLength();
+ if (argsLen < 2) return to;
+
+ for (var i = 1; i < argsLen; ++i) {
+ var nextSource = %_Arguments(i);
+ if (IS_NULL_OR_UNDEFINED(nextSource)) {
+ continue;
+ }
+
+ var from = TO_OBJECT_INLINE(nextSource);
+ var keys = $ownPropertyKeys(from);
+ var len = keys.length;
+
+ for (var j = 0; j < len; ++j) {
+ var key = keys[j];
+ 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
+ var propValue = from[key];
+ to[key] = propValue;
+ }
+ }
+ }
+ return to;
+}
+
+// Set up non-enumerable functions on the Object object.
+$installFunctions(GlobalObject, DONT_ENUM, [
+ "assign", ObjectAssign
+]);
+
+$objectAssign = ObjectAssign;
+
+})();
« 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