Changeset 38632 in webkit for trunk/JavaScriptCore/parser
- Timestamp:
- Nov 20, 2008, 2:27:34 PM (17 years ago)
- Location:
- trunk/JavaScriptCore/parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/parser/Lexer.cpp
r38390 r38632 58 58 static bool isDecimalDigit(int); 59 59 60 static const size_t initialReadBufferCapacity = 32;61 static const size_t initialStringTableCapacity = 64;62 63 60 Lexer::Lexer(JSGlobalData* globalData) 64 61 : yylineno(1) … … 84 81 m_buffer8.reserveCapacity(initialReadBufferCapacity); 85 82 m_buffer16.reserveCapacity(initialReadBufferCapacity); 86 m_strings.reserveCapacity(initialStringTableCapacity);87 m_identifiers.reserveCapacity(initialStringTableCapacity);88 83 } 89 84 … … 609 604 bool Lexer::isIdentStart(int c) 610 605 { 611 return (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other)) 612 || c == '$' || c == '_'; 606 return isASCIIAlpha(c) || c == '$' || c == '_' || (!isASCII(c) && (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other))); 613 607 } 614 608 615 609 bool Lexer::isIdentPart(int c) 616 610 { 617 return (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other 618 | Mark_NonSpacing | Mark_SpacingCombining | Number_DecimalDigit | Punctuation_Connector)) 619 || c == '$' || c == '_'; 611 return isASCIIAlphanumeric(c) || c == '$' || c == '_' || (!isASCII(c) && (category(c) & (Letter_Uppercase | Letter_Lowercase | Letter_Titlecase | Letter_Modifier | Letter_Other 612 | Mark_NonSpacing | Mark_SpacingCombining | Number_DecimalDigit | Punctuation_Connector))); 620 613 } 621 614 622 615 static bool isDecimalDigit(int c) 623 616 { 624 return (c >= '0' && c <= '9');617 return isASCIIDigit(c); 625 618 } 626 619 627 620 bool Lexer::isHexDigit(int c) 628 621 { 629 return (c >= '0' && c <= '9' 630 || c >= 'a' && c <= 'f' 631 || c >= 'A' && c <= 'F'); 622 return isASCIIHexDigit(c); 632 623 } 633 624 634 625 bool Lexer::isOctalDigit(int c) 635 626 { 636 return (c >= '0' && c <= '7');627 return isASCIIOctalDigit(c); 637 628 } 638 629 … … 889 880 void Lexer::clear() 890 881 { 891 deleteAllValues(m_strings); 892 Vector<UString*> newStrings; 893 newStrings.reserveCapacity(initialStringTableCapacity); 894 m_strings.swap(newStrings); 895 896 deleteAllValues(m_identifiers); 897 Vector<JSC::Identifier*> newIdentifiers; 898 newIdentifiers.reserveCapacity(initialStringTableCapacity); 899 m_identifiers.swap(newIdentifiers); 882 m_identifiers.resize(0); 900 883 901 884 Vector<char> newBuffer8; … … 911 894 } 912 895 913 Identifier* Lexer::makeIdentifier(const Vector<UChar>& buffer)914 {915 JSC::Identifier* identifier = new JSC::Identifier(m_globalData, buffer.data(), buffer.size());916 m_identifiers.append(identifier);917 return identifier;918 }919 920 896 } // namespace JSC -
trunk/JavaScriptCore/parser/Lexer.h
r38205 r38632 24 24 #define Lexer_h 25 25 26 #include "Identifier.h" 26 27 #include "Lookup.h" 27 #include "UString.h" 28 #include "SegmentedVector.h" 29 #include "SourceCode.h" 28 30 #include <wtf/Vector.h> 29 #include "SourceCode.h"30 31 31 32 namespace JSC { 32 33 33 class Identifier;34 34 class RegExp; 35 35 … … 113 113 void record16(UChar); 114 114 115 JSC::Identifier* makeIdentifier(const Vector<UChar>& buffer); 115 JSC::Identifier* makeIdentifier(const Vector<UChar>& buffer) 116 { 117 m_identifiers.append(JSC::Identifier(m_globalData, buffer.data(), buffer.size())); 118 return &m_identifiers.last(); 119 } 120 121 static const size_t initialReadBufferCapacity = 32; 122 static const size_t initialIdentifierTableCapacity = 64; 116 123 117 124 int yylineno; … … 149 156 int m_nextOffset3; 150 157 151 Vector<UString*> m_strings; 152 Vector<JSC::Identifier*> m_identifiers; 158 SegmentedVector<JSC::Identifier, initialIdentifierTableCapacity> m_identifiers; 153 159 154 160 JSGlobalData* m_globalData;
Note:
See TracChangeset
for help on using the changeset viewer.