Timestamp:
Feb 19, 2015, 4:20:54 PM (10 years ago)
Author:
[email protected]
Message:

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.
File:
1 added

Note: See TracChangeset for help on using the changeset viewer.