Changeset 43642 in webkit for trunk/JavaScriptCore/parser/Lexer.cpp
- Timestamp:
- May 13, 2009, 11:14:48 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/parser/Lexer.cpp
r43361 r43642 142 142 } 143 143 144 void Lexer::setCode(const SourceCode& source) 145 { 144 void Lexer::setCode(const SourceCode& source, ParserArena& arena) 145 { 146 m_arena = &arena.identifierArena(); 147 146 148 m_lineNumber = source.firstLine(); 147 149 m_delimited = false; … … 205 207 } 206 208 207 ALWAYS_INLINE Identifier* Lexer::makeIdentifier(const UChar* characters, size_t length) 208 { 209 m_identifiers.append(Identifier(m_globalData, characters, length)); 210 return &m_identifiers.last(); 209 ALWAYS_INLINE const Identifier* Lexer::makeIdentifier(const UChar* characters, size_t length) 210 { 211 return &JSC::makeIdentifier(*m_arena, m_globalData, characters, length); 211 212 } 212 213 … … 909 910 } 910 911 911 bool Lexer::scanRegExp( )912 bool Lexer::scanRegExp(const Identifier*& pattern, const Identifier*& flags, UChar prefix) 912 913 { 913 914 ASSERT(m_buffer16.isEmpty()); 914 915 916 bool lastWasEscape = false; 917 bool inBrackets = false; 918 919 if (prefix) 920 record16(prefix); 921 922 while (true) { 923 if (isLineTerminator(m_current) || m_current == -1) { 924 m_buffer16.resize(0); 925 return false; 926 } 927 if (m_current != '/' || lastWasEscape || inBrackets) { 928 // keep track of '[' and ']' 929 if (!lastWasEscape) { 930 if (m_current == '[' && !inBrackets) 931 inBrackets = true; 932 if (m_current == ']' && inBrackets) 933 inBrackets = false; 934 } 935 record16(m_current); 936 lastWasEscape = !lastWasEscape && m_current == '\\'; 937 } else { // end of regexp 938 pattern = makeIdentifier(m_buffer16.data(), m_buffer16.size()); 939 m_buffer16.resize(0); 940 shift1(); 941 break; 942 } 943 shift1(); 944 } 945 946 while (isIdentPart(m_current)) { 947 record16(m_current); 948 shift1(); 949 } 950 flags = makeIdentifier(m_buffer16.data(), m_buffer16.size()); 951 m_buffer16.resize(0); 952 953 return true; 954 } 955 956 bool Lexer::skipRegExp() 957 { 915 958 bool lastWasEscape = false; 916 959 bool inBrackets = false; … … 927 970 inBrackets = false; 928 971 } 929 record16(m_current);930 972 lastWasEscape = !lastWasEscape && m_current == '\\'; 931 973 } else { // end of regexp 932 m_pattern = UString(m_buffer16); 933 m_buffer16.resize(0); 934 shift1(); 935 break; 936 } 937 shift1(); 938 } 939 940 while (isIdentPart(m_current)) { 941 record16(m_current); 942 shift1(); 943 } 944 m_flags = UString(m_buffer16); 945 m_buffer16.resize(0); 974 shift1(); 975 break; 976 } 977 shift1(); 978 } 979 980 while (isIdentPart(m_current)) 981 shift1(); 946 982 947 983 return true; … … 950 986 void Lexer::clear() 951 987 { 952 m_ identifiers.clear();988 m_arena = 0; 953 989 m_codeWithoutBOMs.clear(); 954 990 … … 962 998 963 999 m_isReparsing = false; 964 965 m_pattern = UString();966 m_flags = UString();967 1000 } 968 1001
Note:
See TracChangeset
for help on using the changeset viewer.