Ignore:
Timestamp:
Jan 21, 2016, 8:21:36 PM (9 years ago)
Author:
Yusuke Suzuki
Message:

[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:
File:
1 edited

Legend:

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

    r192937 r195439  
    244244    int createContinueStatement(const JSTokenLocation&, int, int) { return StatementResult; }
    245245    int createContinueStatement(const JSTokenLocation&, const Identifier*, int, int) { return StatementResult; }
    246     int createTryStatement(const JSTokenLocation&, int, const Identifier*, int, int, int, int, VariableEnvironment&) { return StatementResult; }
     246    int createTryStatement(const JSTokenLocation&, int, int, int, int, int, int, VariableEnvironment&) { return StatementResult; }
    247247    int createSwitchStatement(const JSTokenLocation&, int, int, int, int, int, int, VariableEnvironment&) { return StatementResult; }
    248248    int createWhileStatement(const JSTokenLocation&, int, int, int, int) { return StatementResult; }
Note: See TracChangeset for help on using the changeset viewer.