Changeset 192768 in webkit
- Timestamp:
- Nov 24, 2015 5:43:14 PM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r192766 r192768 1 2015-11-24 Caitlin Potter <caitp@igalia.com> 2 3 [JSC] support Computed Property Names in destructuring Patterns 4 https://bugs.webkit.org/show_bug.cgi?id=151494 5 6 Reviewed by Saam Barati. 7 8 Add support for computed property names in destructuring BindingPatterns 9 and AssignmentPatterns. 10 11 Productions BindingProperty(1) and AssignmentProperty(2) allow for any valid 12 PropertName(3), including ComputedPropertyName(4) 13 14 1: http://tc39.github.io/ecma262/#prod-BindingProperty 15 2: http://tc39.github.io/ecma262/#prod-AssignmentProperty 16 3: http://tc39.github.io/ecma262/#prod-PropertyName 17 4: http://tc39.github.io/ecma262/#prod-ComputedPropertyName 18 19 * bytecompiler/NodesCodegen.cpp: 20 (JSC::ObjectPatternNode::bindValue): 21 * parser/ASTBuilder.h: 22 (JSC::ASTBuilder::appendObjectPatternEntry): 23 * parser/Nodes.h: 24 (JSC::ObjectPatternNode::appendEntry): 25 * parser/Parser.cpp: 26 (JSC::Parser<LexerType>::parseDestructuringPattern): 27 * parser/SyntaxChecker.h: 28 (JSC::SyntaxChecker::operatorStackPop): 29 * tests/es6.yaml: 30 * tests/es6/destructuring_assignment_computed_properties.js: Added. 31 (test): 32 (test.computeName): 33 (test.loadValue): 34 (test.out.get a): 35 (test.out.set a): 36 (test.out.get b): 37 (test.out.set b): 38 (test.out.get c): 39 (test.out.set c): 40 (test.get var): 41 1 42 2015-11-24 Commit Queue <commit-queue@webkit.org> 2 43 -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r192671 r192768 3341 3341 auto& target = m_targetPatterns[i]; 3342 3342 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 3344 3350 if (target.defaultValue) 3345 3351 assignDefaultValueIfUndefined(generator, temp.get(), target.defaultValue); -
trunk/Source/JavaScriptCore/parser/ASTBuilder.h
r192671 r192768 852 852 node->appendEntry(location, identifier, wasString, pattern, defaultValue); 853 853 } 854 854 855 void appendObjectPatternEntry(ObjectPattern node, const JSTokenLocation& location, ExpressionNode* propertyExpression, DestructuringPattern pattern, ExpressionNode* defaultValue) 856 { 857 node->appendEntry(location, propertyExpression, pattern, defaultValue); 858 } 859 855 860 BindingPattern createBindingLocation(const JSTokenLocation&, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end, AssignmentContext context) 856 861 { -
trunk/Source/JavaScriptCore/parser/Nodes.h
r192671 r192768 2018 2018 void appendEntry(const JSTokenLocation&, const Identifier& identifier, bool wasString, DestructuringPatternNode* pattern, ExpressionNode* defaultValue) 2019 2019 { 2020 m_targetPatterns.append(Entry{ identifier, wasString, pattern, defaultValue }); 2020 m_targetPatterns.append(Entry{ identifier, nullptr, wasString, pattern, defaultValue }); 2021 } 2022 2023 void appendEntry(const JSTokenLocation&, ExpressionNode* propertyExpression, DestructuringPatternNode* pattern, ExpressionNode* defaultValue) 2024 { 2025 m_targetPatterns.append(Entry{ Identifier(), propertyExpression, false, pattern, defaultValue }); 2021 2026 } 2022 2027 … … 2027 2032 struct Entry { 2028 2033 const Identifier& propertyName; 2034 ExpressionNode* propertyExpression; 2029 2035 bool wasString; 2030 2036 DestructuringPatternNode* pattern; -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r192695 r192768 862 862 863 863 const Identifier* propertyName = nullptr; 864 TreeExpression propertyExpression = 0; 864 865 TreeDestructuringPattern innerPattern = 0; 865 866 JSTokenLocation location = m_token.m_location; … … 883 884 propertyName = m_token.m_data.ident; 884 885 wasString = true; 886 break; 887 case OPENBRACKET: 888 next(); 889 propertyExpression = parseAssignmentExpression(context); 890 failIfFalse(propertyExpression, "Cannot parse computed property name"); 891 matchOrFail(CLOSEBRACKET, "Expected ']' to end end a computed property name"); 885 892 break; 886 893 default: … … 909 916 failIfFalse(innerPattern, "Cannot parse this destructuring pattern"); 910 917 TreeExpression defaultValue = parseDefaultValueForDestructuringPattern(context); 911 ASSERT(propertyName); 912 context.appendObjectPatternEntry(objectPattern, location, wasString, *propertyName, innerPattern, defaultValue); 918 if (propertyExpression) 919 context.appendObjectPatternEntry(objectPattern, location, propertyExpression, innerPattern, defaultValue); 920 else { 921 ASSERT(propertyName); 922 context.appendObjectPatternEntry(objectPattern, location, wasString, *propertyName, innerPattern, defaultValue); 923 } 913 924 } while (consume(COMMA)); 914 925 -
trunk/Source/JavaScriptCore/parser/SyntaxChecker.h
r192671 r192768 344 344 { 345 345 } 346 void appendObjectPatternEntry(ArrayPattern, const JSTokenLocation&, Expression, DestructuringPattern, Expression) 347 { 348 } 349 346 350 DestructuringPattern createBindingLocation(const JSTokenLocation&, const Identifier&, const JSTextPosition&, const JSTextPosition&, AssignmentContext) 347 351 { -
trunk/Source/JavaScriptCore/tests/es6.yaml
r192671 r192768 217 217 - path: es6/destructuring_assignment_non_simple_target.js 218 218 cmd: runES6 :normal 219 - path: es6/destructuring_assignment_computed_properties.js 220 cmd: runES6 :normal 221 - path: es6/destructuring_assignment_computed_property_simple.js 222 cmd: runES6 :normal 223 - path: es6/destructuring_assignment_computed_property_default.js 224 cmd: runES6 :normal 219 225 - path: es6/destructuring_initializer_scoping.js 220 226 cmd: runES6 :normal … … 746 752 cmd: runES6 :fail 747 753 - path: es6/destructuring_computed_properties.js 748 cmd: runES6 : fail754 cmd: runES6 :normal 749 755 - path: es6/destructuring_defaults_in_parameters_separate_scope.js 750 756 cmd: runES6 :fail
Note: See TracChangeset
for help on using the changeset viewer.