Ignore:
Timestamp:
Jul 16, 2010, 11:32:42 AM (15 years ago)
Author:
[email protected]
Message:

2010-07-16 Oliver Hunt <[email protected]>

Reviewed by Geoffrey Garen.

ES5 allows use of reserved words as IdentifierName
https://bugs.webkit.org/show_bug.cgi?id=42471

Modify the lexer to allow us to avoid identifying reserved
words in those contexts where they are valid identifiers, and
we know it's safe. Additionally tag the reserved word tokens
so we can easily identify them in those cases where we can't
guarantee that we've skipped reserved word identification.

  • parser/JSParser.cpp: (JSC::JSParser::next): (JSC::JSParser::parseProperty): (JSC::JSParser::parseMemberExpression):
  • parser/JSParser.h: (JSC::):
  • parser/Lexer.cpp: (JSC::Lexer::lex):
  • parser/Lexer.h: (JSC::Lexer::):

2010-07-16 Oliver Hunt <[email protected]>

Reviewed by Geoffrey Garen.

ES5 allows use of reserved words as IdentifierName
https://bugs.webkit.org/show_bug.cgi?id=42471

Add tests to check for correct handling of reserved words with
the ES5 semantics.

  • fast/js/reserved-words-as-property-expected.txt: Added.
  • fast/js/reserved-words-as-property.html: Added.
  • fast/js/script-tests/reserved-words-as-property.js: Added. ():
  • fast/js/sputnik/Conformance/11_Expressions/11.1_Primary_Expressions/11.1.5_Object_Initializer/S11.1.5_A4.1-expected.txt:
  • fast/js/sputnik/Conformance/11_Expressions/11.1_Primary_Expressions/11.1.5_Object_Initializer/S11.1.5_A4.2-expected.txt: These tests are wrong, unsure how to get sputnik tests corrected.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/parser/JSParser.cpp

    r63055 r63566  
    8686
    8787    const JSToken& token() { return m_token; }
    88     void next()
     88    void next(Lexer::LexType lexType = Lexer::IdentifyReservedWords)
    8989    {
    9090        m_lastLine = token().m_info.line;
    9191        m_lastTokenEnd = token().m_info.endOffset;
    9292        m_lexer->setLastLineNumber(m_lastLine);
    93         m_token.m_type = m_lexer->lex(&m_token.m_data, &m_token.m_info);
     93        m_token.m_type = m_lexer->lex(&m_token.m_data, &m_token.m_info, lexType);
    9494        m_tokenCount++;
    9595    }
     
    10921092    bool wasIdent = false;
    10931093    switch (token().m_type) {
     1094    namedProperty:
    10941095    case IDENT:
    10951096        wasIdent = true;
    10961097    case STRING: {
    10971098        const Identifier* ident = token().m_data.ident;
    1098         next();
     1099        next(Lexer::IgnoreReservedWords);
    10991100        if (match(COLON)) {
    11001101            next();
     
    11301131    }
    11311132    default:
    1132         fail();
     1133        failIfFalse(token().m_type & KeywordTokenFlag);
     1134        goto namedProperty;
    11331135    }
    11341136}
     
    14111413        case DOT: {
    14121414            int expressionEnd = lastTokenEnd();
    1413             next();
     1415            next(Lexer::IgnoreReservedWords);
    14141416            matchOrFail(IDENT);
    14151417            base = context.createDotAccess(base, *token().m_data.ident, expressionStart, expressionEnd, tokenEnd());
Note: See TracChangeset for help on using the changeset viewer.