Ignore:
Timestamp:
Mar 21, 2013, 1:06:26 PM (12 years ago)
Author:
[email protected]
Message:

Fix lexer charPosition computation when "rewind"ing the lexer.
https://bugs.webkit.org/show_bug.cgi?id=112952.

Reviewed by Michael Saboff.

Changed the Lexer to no longer keep a m_charPosition. Instead, we compute
currentCharPosition() from m_code and m_codeStartPlusOffset, where
m_codeStartPlusOffset is the SourceProvider m_codeStart + the SourceCode
start offset. This ensures that the charPosition is always in sync with
m_code.

  • parser/Lexer.cpp:

(JSC::::setCode):
(JSC::::internalShift):
(JSC::::shift):
(JSC::::lex):

  • parser/Lexer.h:

(JSC::Lexer::currentCharPosition):
(JSC::::lexExpectIdentifier):

File:
1 edited

Legend:

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

    r146318 r146505  
    547547
    548548    m_source = &source;
    549     m_code = m_codeStart + source.startOffset();
     549    m_codeStartPlusOffset = m_codeStart + source.startOffset();
     550    m_code = m_codeStartPlusOffset;
    550551    m_codeEnd = m_codeStart + source.endOffset();
    551552    m_error = false;
    552553    m_atLineStart = true;
    553     m_charPosition = 0;
    554554    m_lexErrorMessage = String();
    555555   
     
    568568{
    569569    m_code += shiftAmount;
    570     m_charPosition += shiftAmount;
    571570    m_current = *m_code;
    572571}
     
    580579    if (LIKELY(m_code < m_codeEnd))
    581580        m_current = *m_code;
    582     ++m_charPosition;
    583581}
    584582
     
    13201318   
    13211319    tokenLocation->startOffset = currentOffset();
    1322     tokenLocation->charPosition = m_charPosition;
     1320    tokenLocation->charPosition = currentCharPosition();
    13231321
    13241322    CharacterType type;
Note: See TracChangeset for help on using the changeset viewer.