Ignore:
Timestamp:
Feb 26, 2012, 2:51:38 PM (13 years ago)
Author:
[email protected]
Message:

StringLiteral and NumericLiteral are allowed as ObjectLiteral getter / setter name
https://bugs.webkit.org/show_bug.cgi?id=79571

Patch by Yusuke Suzuki <Yusuke Suzuki> on 2012-02-26
Reviewed by Gavin Barraclough.

Source/JavaScriptCore:

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createGetterOrSetterProperty):

  • parser/Parser.cpp:

(JSC::::parseProperty):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createGetterOrSetterProperty):

LayoutTests:

  • fast/js/property-getters-and-setters-expected.txt:
  • fast/js/script-tests/property-getters-and-setters.js:

(o9.string_appeared_here.7.get string_appeared_here):
(o9.set string_appeared_here):
(get shouldBe):
(o10.string_appeared_here.7.get 42):
(o10.set 42):

  • platform/chromium/fast/js/property-getters-and-setters-expected.txt:
File:
1 edited

Legend:

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

    r108259 r108935  
    12051205        }
    12061206        failIfFalse(wasIdent);
    1207         matchOrFail(IDENT);
    12081207        const Identifier* accessorName = 0;
    12091208        TreeFormalParameterList parameters = 0;
     
    12191218        else
    12201219            fail();
    1221         failIfFalse((parseFunctionInfo<FunctionNeedsName, false>(context, accessorName, parameters, body, openBracePos, closeBracePos, bodyStartLine)));
    1222         return context.template createGetterOrSetterProperty<complete>(m_lexer->lastLineNumber(), type, accessorName, parameters, body, openBracePos, closeBracePos, bodyStartLine, m_lastLine);
     1220        const Identifier* stringPropertyName = 0;
     1221        double numericPropertyName = 0;
     1222        if (m_token.m_type == IDENT || m_token.m_type == STRING)
     1223            stringPropertyName = m_token.m_data.ident;
     1224        else if (m_token.m_type == NUMBER)
     1225            numericPropertyName = m_token.m_data.doubleValue;
     1226        else
     1227            fail();
     1228        next();
     1229        failIfFalse((parseFunctionInfo<FunctionNoRequirements, false>(context, accessorName, parameters, body, openBracePos, closeBracePos, bodyStartLine)));
     1230        if (stringPropertyName)
     1231            return context.template createGetterOrSetterProperty<complete>(m_lexer->lastLineNumber(), type, stringPropertyName, parameters, body, openBracePos, closeBracePos, bodyStartLine, m_lastLine);
     1232        return context.template createGetterOrSetterProperty<complete>(const_cast<JSGlobalData*>(m_globalData), m_lexer->lastLineNumber(), type, numericPropertyName, parameters, body, openBracePos, closeBracePos, bodyStartLine, m_lastLine);
    12231233    }
    12241234    case NUMBER: {
Note: See TracChangeset for help on using the changeset viewer.