[ES6] Catch parameter should accept BindingPattern
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jan 2016 04:21:36 +0000 (04:21 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jan 2016 04:21:36 +0000 (04:21 +0000)
commit2dd9053100f0b3689a0c38a73214bd3a354ccd80
tree0a19906d3a6a638a15de6550414e1d32cd4c26af
parentceff0142d1073c6437588b0f324749bc11ccac79
[ES6] Catch parameter should accept BindingPattern
https://bugs.webkit.org/show_bug.cgi?id=152385

Reviewed by Saam Barati.

Source/JavaScriptCore:

This patch implements destructuring in catch parameter.
Catch parameter accepts binding pattern and binding identifier.
It creates lexical bindings. And "yield" and "let" are specially
handled as is the same to function parameters.

In addition to that, we make destructuring parsing errors more descriptive.

* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitPushCatchScope):
* bytecompiler/BytecodeGenerator.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::TryNode::emitBytecode):
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createTryStatement):
* parser/NodeConstructors.h:
(JSC::TryNode::TryNode):
* parser/Nodes.h:
* parser/Parser.cpp:
(JSC::Parser<LexerType>::createBindingPattern):
(JSC::Parser<LexerType>::tryParseDestructuringPatternExpression):
(JSC::Parser<LexerType>::parseBindingOrAssignmentElement):
(JSC::destructuringKindToVariableKindName):
(JSC::Parser<LexerType>::parseDestructuringPattern):
(JSC::Parser<LexerType>::parseTryStatement):
(JSC::Parser<LexerType>::parseFormalParameters):
(JSC::Parser<LexerType>::parseFunctionParameters):
* parser/Parser.h:
(JSC::Parser::destructuringKindFromDeclarationType):
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createTryStatement):
* tests/es6.yaml:
* tests/es6/destructuring_in_catch_heads.js: Added.
(test):
* tests/stress/catch-parameter-destructuring.js: Added.
(shouldBe):
(shouldThrow):
(prototype.call):
(catch):
(shouldThrow.try.throw.get error):
(initialize):
(array):
(generator.gen):
(generator):
* tests/stress/catch-parameter-syntax.js: Added.
(testSyntax):
(testSyntaxError):
* tests/stress/reserved-word-with-escape.js:
(testSyntaxError.String.raw.a):
(String.raw.SyntaxError.Cannot.use.the.keyword.string_appeared_here.as.a.name):
* tests/stress/yield-named-variable.js:

LayoutTests:

* js/dom/reserved-words-as-property-expected.txt:
* js/let-syntax-expected.txt:
* js/mozilla/strict/12.14.1-expected.txt:
* js/mozilla/strict/script-tests/12.14.1.js:
* sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T10-expected.txt:
* sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T13-expected.txt:
* sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T5-expected.txt:
* sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T7-expected.txt:
* sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T8-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195439 268f45cc-cd09-0410-ab3c-d52691b4dbfc
26 files changed:
LayoutTests/ChangeLog
LayoutTests/js/dom/reserved-words-as-property-expected.txt
LayoutTests/js/let-syntax-expected.txt
LayoutTests/js/mozilla/strict/12.14.1-expected.txt
LayoutTests/js/mozilla/strict/script-tests/12.14.1.js
LayoutTests/sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T10-expected.txt
LayoutTests/sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T13-expected.txt
LayoutTests/sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T5-expected.txt
LayoutTests/sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T7-expected.txt
LayoutTests/sputnik/Conformance/12_Statement/12.14_The_try_Statement/S12.14_A16_T8-expected.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
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_in_catch_heads.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/catch-parameter-destructuring.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/catch-parameter-syntax.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/reserved-word-with-escape.js
Source/JavaScriptCore/tests/stress/yield-named-variable.js