Ignore:
Timestamp:
Mar 5, 2015, 5:16:25 PM (10 years ago)
Author:
[email protected]
Message:

Source/JavaScriptCore:
ES6: Object Literal Extensions - Shorthand Properties (Identifiers)
https://bugs.webkit.org/show_bug.cgi?id=142353

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2015-03-05
Reviewed by Geoffrey Garen.

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseProperty):
Parsing an identifier property followed by a comma or end brace treat
as a shorthand property and create a property that has the same
property name as the identifier name and value of a variable with that
identifier. Otherwise, fall through to getter/setter parsing.

LayoutTests:
Web Inspector: Follow-up fixes to ObjectTreeBaseTreeElement
https://bugs.webkit.org/show_bug.cgi?id=142367

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2015-03-05
Reviewed by Geoffrey Garen.

  • js/object-literal-shorthand-construction-expected.txt: Added.
  • js/object-literal-shorthand-construction.html: Added.
  • js/script-tests/object-literal-shorthand-construction.js: Added.

(equivalent):
(testShorthandConstructionEquivalent):
(testShorthandConstructionNotEquivalent):
Tests specifically for new literal construction with shorthands.

  • sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T1-expected.txt:
  • sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T2-expected.txt:
  • sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.4_The_for_in_Statement/S12.6.4_A15-expected.txt:

These tests use object literal shorthand construction syntax and expected
failures. The tests now fail differently, so just rebase their results.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r180813 r181121  
    18701870template <class TreeBuilder> TreeExpression Parser<LexerType>::parseBinaryExpression(TreeBuilder& context)
    18711871{
    1872    
    18731872    int operandStackDepth = 0;
    18741873    int operatorStackDepth = 0;
     
    19291928        else
    19301929            nextExpectIdentifier(LexerFlagsIgnoreReservedWords | TreeBuilder::DontBuildKeywords);
    1931        
     1930
    19321931        if (match(COLON)) {
    19331932            next();
     
    19371936            return context.createProperty(ident, node, PropertyNode::Constant, complete);
    19381937        }
     1938
    19391939        failIfFalse(wasIdent, "Expected an identifier as property name");
     1940
     1941        if (match(COMMA) || match(CLOSEBRACE)) {
     1942            JSTextPosition start = tokenStartPosition();
     1943            JSTokenLocation location(tokenLocation());
     1944            currentScope()->useVariable(ident, m_vm->propertyNames->eval == *ident);
     1945            TreeExpression node = context.createResolve(location, ident, start);
     1946            return context.createProperty(ident, node, PropertyNode::Constant, complete);
     1947        }
     1948
    19401949        PropertyNode::Type type;
    19411950        if (*ident == m_vm->propertyNames->get)
Note: See TracChangeset for help on using the changeset viewer.