ES6: Implement Array.from()
https://bugs.webkit.org/show_bug.cgi?id=141054
<rdar://problem/
19654521>
Reviewed by Filip Pizlo.
Source/JavaScriptCore:
Implement the Array.from() ES6 method
as defined in Section 22.1.2.1 of the specification.
Given that we can't rely on the built-in
global functions or objects to be untainted,
I had to expose a few of them directly to
the function via private names. In particular:
- Math.floor -> @floor
- Math.abs -> @abs
- Number -> @Number
- Array -> @Array
- isFinite -> @isFinite
* builtins/ArrayConstructor.js: Added.
(from): Implementation of Array.from in JavaScript.
* runtime/ArrayConstructor.cpp: Add "from" to the lookup
table for the constructor object.
* runtime/CommonIdentifiers.h: Add the private versions
of the identifiers listed above.
* runtime/JSGlobalObject.cpp: Add the implementations of
those identifiers to the global object (using their
private names).
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalPrivateFuncAbs): Implementation of the abs function.
(JSC::globalPrivateFuncFloor): Implementation of the floor function.
* runtime/JSGlobalObjectFunctions.h:
LayoutTests:
Test for Array.from(). The test has
one expected failure: using from() on a
Set object, which will be addressed in
a followup:
https://bugs.webkit.org/show_bug.cgi?id=141055
* js/array-from-expected.txt: Added.
* js/array-from.html: Added.
* js/script-tests/array-from.js: Added.
* js/Object-getOwnPropertyNames.html: Update results for the new value on the constructor.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180370
268f45cc-cd09-0410-ab3c-
d52691b4dbfc