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

Unified Diff: src/harmony-typedarray.js

Issue 660863003: Implement .of() on typed arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed nits Created 6 years, 1 month 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 | « no previous file | test/mjsunit/harmony/typedarrays-of.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/harmony-typedarray.js
diff --git a/src/harmony-typedarray.js b/src/harmony-typedarray.js
index 0129f38d507cd0f8d0483a5ba3bbed8a04a2d773..014206c4cba8400cf745b9295d5cb223695ad6cb 100644
--- a/src/harmony-typedarray.js
+++ b/src/harmony-typedarray.js
@@ -58,6 +58,17 @@ function NAMEForEach(f /* thisArg */) { // length == 1
%_CallFunction(new_receiver, TO_OBJECT_INLINE(element), i, this, f);
}
}
+
+// ES6 draft 08-24-14, section 22.2.2.2
+function NAMEOf() { // length == 0
+ var length = %_ArgumentsLength();
+ var array = new this(length);
+ for (var i = 0; i < length; i++) {
+ array[i] = %_Arguments(i);
+ }
+ return array;
+}
+
endmacro
TYPED_ARRAYS(TYPED_ARRAY_HARMONY_ADDITIONS)
@@ -67,6 +78,11 @@ function HarmonyTypedArrayExtendPrototypes() {
macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
%CheckIsBootstrapping();
+ // Set up non-enumerable functions on the object.
+ InstallFunctions(global.NAME, DONT_ENUM | DONT_DELETE | READ_ONLY, $Array(
+ "of", NAMEOf
+ ));
+
// Set up non-enumerable functions on the prototype object.
InstallFunctions(global.NAME.prototype, DONT_ENUM, $Array(
"forEach", NAMEForEach
« no previous file with comments | « no previous file | test/mjsunit/harmony/typedarrays-of.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698