Skip to content
  • oliver@apple.com's avatar
    Support unprefixed deconstructing assignment · 2bae57ad
    oliver@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=124172
    
    Reviewed by Mark Lam.
    
    Source/JavaScriptCore:
    
    Add support for unprefixed descontructive assignment.
    
    Happily non-reference types on the left hand side of an assignment
    are a runtime error, so we're able to defer validation of the binding
    pattern to codegen time when we're already doing a lot more work.
    
    We're also able to predicate our attempt to parse on the existence of
    '[' or '{' as they are not as common as other constructs.
    
    * bytecompiler/NodesCodegen.cpp:
    (JSC::ArrayPatternNode::emitDirectBinding):
    * parser/ASTBuilder.h:
    * parser/Parser.cpp:
    (JSC::::createBindingPattern):
    (JSC::::tryParseDeconstructionPatternExpression):
    (JSC::::parseDeconstructionPattern):
    (JSC::::parseForStatement):
    (JSC::::parseAssignmentExpression):
    * parser/Parser.h:
    (JSC::Parser::createSavePoint):
    (JSC::Parser::restoreSavePoint):
    * parser/SyntaxChecker.h:
    
    LayoutTests:
    
    Add and expand testing of destructuring assignment
    
    * js/basic-for-of-expected.txt:
    * js/destructuring-assignment-expected.txt:
    * js/parser-syntax-check-expected.txt:
    * js/script-tests/basic-for-of.js:
    * js/script-tests/destructuring-assignment.js:
    (testDestructuring):
    * js/script-tests/parser-syntax-check.js:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159139 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    2bae57ad