Ignore:
Timestamp:
Nov 24, 2015, 5:43:14 PM (10 years ago)
Author:
[email protected]
Message:

[JSC] support Computed Property Names in destructuring Patterns
https://bugs.webkit.org/show_bug.cgi?id=151494

Patch by Caitlin Potter <[email protected]> on 2015-11-24
Reviewed by Saam Barati.

Add support for computed property names in destructuring BindingPatterns
and AssignmentPatterns.

Productions BindingProperty(1) and AssignmentProperty(2) allow for any valid
PropertName(3), including ComputedPropertyName(4)

1: http://tc39.github.io/ecma262/#prod-BindingProperty
2: http://tc39.github.io/ecma262/#prod-AssignmentProperty
3: http://tc39.github.io/ecma262/#prod-PropertyName
4: http://tc39.github.io/ecma262/#prod-ComputedPropertyName

  • bytecompiler/NodesCodegen.cpp:

(JSC::ObjectPatternNode::bindValue):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::appendObjectPatternEntry):

  • parser/Nodes.h:

(JSC::ObjectPatternNode::appendEntry):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseDestructuringPattern):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::operatorStackPop):

  • tests/es6.yaml:
  • tests/es6/destructuring_assignment_computed_properties.js: Added.

(test):
(test.computeName):
(test.loadValue):
(test.out.get a):
(test.out.set a):
(test.out.get b):
(test.out.set b):
(test.out.get c):
(test.out.set c):
(test.get var):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r192671 r192768  
    33413341        auto& target = m_targetPatterns[i];
    33423342        RefPtr<RegisterID> temp = generator.newTemporary();
    3343         generator.emitGetById(temp.get(), rhs, target.propertyName);
     3343        if (!target.propertyExpression)
     3344            generator.emitGetById(temp.get(), rhs, target.propertyName);
     3345        else {
     3346            RefPtr<RegisterID> propertyName = generator.emitNode(target.propertyExpression);
     3347            generator.emitGetByVal(temp.get(), rhs, propertyName.get());
     3348        }
     3349
    33443350        if (target.defaultValue)
    33453351            assignDefaultValueIfUndefined(generator, temp.get(), target.defaultValue);
Note: See TracChangeset for help on using the changeset viewer.