Ignore:
Timestamp:
Aug 3, 2016, 12:50:40 AM (9 years ago)
Author:
[email protected]
Message:

Implement nested rest destructuring w.r.t the ES7 spec
https://bugs.webkit.org/show_bug.cgi?id=160423

Reviewed by Filip Pizlo.

JSTests:

  • stress/destructuring-rest-element.js: Added.

(assert):
(test):
(arr):
(eq):
(gen):
(fakeGen.return.Symbol.iterator):
(fakeGen):

  • stress/rest-elements.js:

(testSyntaxError.String.raw):

  • stress/rest-parameter-is-destructuring.js: Added.

(assert):
(test):
(foo):
(bar):

  • test262.yaml:

Source/JavaScriptCore:

The spec has updated the BindingRestElement grammar production to be:
BindingRestElement:

BindingIdentifier
BindingingPattern.

It used to only allow BindingIdentifier in the grammar production.
I've updated our engine to account for this. The semantics are exactly
what you'd expect. For example:
let [a, ...[b, ...c]] = expr();
means that we create an array for the first rest element ...[b, ...c]
and then perform the binding of [b, ...c] to that array. And so on,
applied recursively through the pattern.

  • bytecompiler/NodesCodegen.cpp:

(JSC::RestParameterNode::collectBoundIdentifiers):
(JSC::RestParameterNode::toString):
(JSC::RestParameterNode::bindValue):
(JSC::RestParameterNode::emit):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createBindingLocation):
(JSC::ASTBuilder::createRestParameter):
(JSC::ASTBuilder::createAssignmentElement):

  • parser/NodeConstructors.h:

(JSC::AssignmentElementNode::AssignmentElementNode):
(JSC::RestParameterNode::RestParameterNode):
(JSC::DestructuringAssignmentNode::DestructuringAssignmentNode):

  • parser/Nodes.h:

(JSC::RestParameterNode::name): Deleted.

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseDestructuringPattern):
(JSC::Parser<LexerType>::parseFormalParameters):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::operatorStackPop):

LayoutTests:

  • js/parser-syntax-check-expected.txt:
  • js/script-tests/parser-syntax-check.js:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/SyntaxChecker.h

    r203499 r204078  
    355355        return BindingDestructuring;
    356356    }
    357     RestPattern createRestParameter(const Identifier&, size_t, const JSTextPosition&, const JSTextPosition&)
     357    RestPattern createRestParameter(DestructuringPattern, size_t)
    358358    {
    359359        return RestParameter;
Note: See TracChangeset for help on using the changeset viewer.