diff options
Diffstat (limited to 'Source/JavaScriptCore/parser/Lexer.h')
-rw-r--r-- | Source/JavaScriptCore/parser/Lexer.h | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/Source/JavaScriptCore/parser/Lexer.h b/Source/JavaScriptCore/parser/Lexer.h index 81558fa96..41f1f8553 100644 --- a/Source/JavaScriptCore/parser/Lexer.h +++ b/Source/JavaScriptCore/parser/Lexer.h @@ -1,6 +1,6 @@ /* * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved. * Copyright (C) 2010 Zoltan Herczeg (zherczeg@inf.u-szeged.hu) * * This library is free software; you can redistribute it and/or @@ -67,8 +67,6 @@ enum LexerFlags { LexexFlagsDontBuildKeywords = 4 }; -class RegExp; - template <typename T> class Lexer { WTF_MAKE_NONCOPYABLE(Lexer); @@ -110,10 +108,10 @@ public: m_code = m_codeStart + offset; m_buffer8.resize(0); m_buffer16.resize(0); - // Faster than an if-else sequence - m_current = -1; if (LIKELY(m_code < m_codeEnd)) m_current = *m_code; + else + m_current = 0; } void setLineNumber(int line) { @@ -133,11 +131,12 @@ private: void append16(const UChar* characters, size_t length) { m_buffer16.append(characters, length); } ALWAYS_INLINE void shift(); - ALWAYS_INLINE int peek(int offset); - int getUnicodeCharacter(); + ALWAYS_INLINE bool atEnd() const; + ALWAYS_INLINE T peek(int offset) const; + int parseFourDigitUnicodeHex(); void shiftLineTerminator(); - UString getInvalidCharMessage(); + UString invalidCharacterMessage() const; ALWAYS_INLINE const T* currentCharacter() const; ALWAYS_INLINE int currentOffset() const { return m_code - m_codeStart; } ALWAYS_INLINE void setOffsetFromCharOffset(const T* charOffset) { setOffset(charOffset - m_codeStart); } @@ -171,7 +170,6 @@ private: Vector<LChar> m_buffer8; Vector<UChar> m_buffer16; bool m_terminator; - bool m_delimited; // encountered delimiter like "'" and "}" on last run int m_lastToken; const SourceCode* m_source; @@ -183,8 +181,7 @@ private: bool m_error; UString m_lexErrorMessage; - // current and following unicode characters (int to allow for -1 for end-of-file marker) - int m_current; + T m_current; IdentifierArena* m_arena; @@ -285,7 +282,7 @@ ALWAYS_INLINE JSTokenType Lexer<T>::lexExpectIdentifier(JSTokenData* tokenData, goto slowCase; m_current = *ptr; } else - m_current = -1; + m_current = 0; m_code = ptr; |