[JSC] Fix AssignmentElement parsing
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Nov 2015 22:54:46 +0000 (22:54 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Nov 2015 22:54:46 +0000 (22:54 +0000)
commit00177291c7ad4b46be173c6569edc0f96f9e5e91
tree517e5567cbd341c14542cdaf8792df6a62f2eda2
parent0df0a06ce7947403e212b3e044b82baa2078598b
[JSC] Fix AssignmentElement parsing
https://bugs.webkit.org/show_bug.cgi?id=151026

Patch by Caitlin Potter <caitp@igalia.com> on 2015-11-19
Reviewed by Geoffrey Garen.

When parsing an AssignmentPattern, any LeftHandSideExpression which
is a valid assignment target is acceptable.

Additionally, this change minimizes the amount of time spent
re-parsing ObjectLiteral and ArrayLiterals, by parsing as an
Expression first (the common case), and re-parsing only if the
result is a valid ObjectLiteral or ArrayLiteral followed by an `=`,
or if an error specifically indicates that the expression could
have been parsed as an AssignmentPattern.

* bytecompiler/NodesCodegen.cpp:
(JSC::AssignmentElementNode::collectBoundIdentifiers):
(JSC::AssignmentElementNode::bindValue):
(JSC::AssignmentElementNode::toString):
* parser/ASTBuilder.h:
(JSC::ASTBuilder::isAssignmentLocation):
(JSC::ASTBuilder::isObjectLiteral):
(JSC::ASTBuilder::isArrayLiteral):
(JSC::ASTBuilder::isObjectOrArrayLiteral):
(JSC::ASTBuilder::createAssignmentElement):
* parser/NodeConstructors.h:
(JSC::AssignmentElementNode::AssignmentElementNode):
* parser/Nodes.h:
(JSC::ExpressionNode::isObjectLiteral):
(JSC::ExpressionNode::isArrayLiteral):
(JSC::AssignmentElementNode::assignmentTarget):
(JSC::AssignmentElementNode::divotStart):
(JSC::AssignmentElementNode::divotEnd):
* parser/Parser.cpp:
(JSC::Parser<LexerType>::Parser):
(JSC::Parser<LexerType>::createAssignmentElement):
(JSC::Parser<LexerType>::parseBindingOrAssignmentElement):
(JSC::Parser<LexerType>::parseAssignmentElement):
(JSC::Parser<LexerType>::parseDestructuringPattern):
(JSC::Parser<LexerType>::parseAssignmentExpression):
(JSC::Parser<LexerType>::parseProperty):
* parser/Parser.h:
(JSC::Parser::ExpressionErrorClassifier::ExpressionErrorClassifier):
(JSC::Parser::ExpressionErrorClassifier::~ExpressionErrorClassifier):
(JSC::Parser::ExpressionErrorClassifier::classifyExpressionError):
(JSC::Parser::ExpressionErrorClassifier::indicatesPossiblePattern):
(JSC::Parser::classifyExpressionError):
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::operatorStackPop):
* tests/es6.yaml:
* tests/es6/destructuring_assignment_non_simple_target.js: Added.
(test.):
(test):
* tests/es6/destructuring_initializer_scoping.js: Added.
(test.tester):
* tests/stress/destructuring-assignment-syntax.js: Added.
(testSyntax):
(testSyntaxError):
* tests/stress/rest-elements.js:
(shouldThrow): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192661 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
Source/JavaScriptCore/parser/ASTBuilder.h
Source/JavaScriptCore/parser/NodeConstructors.h
Source/JavaScriptCore/parser/Nodes.h
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/Parser.h
Source/JavaScriptCore/parser/SyntaxChecker.h
Source/JavaScriptCore/tests/es6.yaml
Source/JavaScriptCore/tests/es6/destructuring_assignment_non_simple_target.js [new file with mode: 0644]
Source/JavaScriptCore/tests/es6/destructuring_initializer_scoping.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/destructuring-assignment-syntax.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/regress-151324.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/rest-elements.js