Ignore:
Timestamp:
Jan 21, 2016, 8:21:36 PM (10 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/Nodes.h

    r193766 r195439  
    15271527        using ParserArenaDeletable::operator new;
    15281528
    1529         TryNode(const JSTokenLocation&, StatementNode* tryBlock, const Identifier& exceptionIdent, StatementNode* catchBlock, VariableEnvironment& catchEnvironment, StatementNode* finallyBlock);
     1529        TryNode(const JSTokenLocation&, StatementNode* tryBlock, DestructuringPatternNode* catchPattern, StatementNode* catchBlock, VariableEnvironment& catchEnvironment, StatementNode* finallyBlock);
    15301530
    15311531    private:
     
    15331533
    15341534        StatementNode* m_tryBlock;
    1535         const Identifier& m_thrownValueIdent;
     1535        DestructuringPatternNode* m_catchPattern;
    15361536        StatementNode* m_catchBlock;
    15371537        StatementNode* m_finallyBlock;
Note: See TracChangeset for help on using the changeset viewer.