Changeset 72186 in webkit for trunk/JavaScriptCore/yarr/RegexInterpreter.cpp
- Timestamp:
- Nov 17, 2010, 3:03:40 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/yarr/RegexInterpreter.cpp
r72140 r72186 197 197 } 198 198 199 int readPair() 200 { 201 ASSERT(pos + 1 < length); 202 return input[pos] | input[pos + 1] << 16; 203 } 204 199 205 int readChecked(int position) 200 206 { … … 262 268 { 263 269 return (pos + position) == length; 270 } 271 272 bool isNotAvailableInput(int position) 273 { 274 return (pos + position) > length; 264 275 } 265 276 … … 994 1005 } 995 1006 1007 void lookupForBeginChars() 1008 { 1009 int character; 1010 bool firstSingleCharFound; 1011 1012 while (true) { 1013 if (input.isNotAvailableInput(2)) 1014 return; 1015 1016 firstSingleCharFound = false; 1017 1018 character = input.readPair(); 1019 1020 for (unsigned i = 0; i < pattern->m_beginChars.size(); ++i) { 1021 BeginChar bc = pattern->m_beginChars[i]; 1022 1023 if (!firstSingleCharFound && bc.value <= 0xFFFF) { 1024 firstSingleCharFound = true; 1025 character &= 0xFFFF; 1026 } 1027 1028 if ((character | bc.mask) == bc.value) 1029 return; 1030 } 1031 1032 input.next(); 1033 } 1034 } 1035 996 1036 #define MATCH_NEXT() { ++context->term; goto matchAgain; } 997 1037 #define BACKTRACK() { --context->term; goto backtrack; } 998 1038 #define currentTerm() (disjunction->terms[context->term]) 999 JSRegExpResult matchDisjunction(ByteDisjunction* disjunction, DisjunctionContext* context, bool btrack = false )1039 JSRegExpResult matchDisjunction(ByteDisjunction* disjunction, DisjunctionContext* context, bool btrack = false, bool isBody = false) 1000 1040 { 1001 1041 if (!--remainingMatchCount) … … 1004 1044 if (btrack) 1005 1045 BACKTRACK(); 1046 1047 if (pattern->m_containsBeginChars && isBody) 1048 lookupForBeginChars(); 1006 1049 1007 1050 context->matchBegin = input.getPos(); … … 1169 1212 1170 1213 input.next(); 1214 1215 if (pattern->m_containsBeginChars && isBody) 1216 lookupForBeginChars(); 1217 1171 1218 context->matchBegin = input.getPos(); 1172 1219 … … 1285 1332 DisjunctionContext* context = allocDisjunctionContext(pattern->m_body.get()); 1286 1333 1287 JSRegExpResult result = matchDisjunction(pattern->m_body.get(), context );1334 JSRegExpResult result = matchDisjunction(pattern->m_body.get(), context, false, true); 1288 1335 if (result == JSRegExpMatch) { 1289 1336 output[0] = context->matchBegin;
Note:
See TracChangeset
for help on using the changeset viewer.