Changeset 225695 in webkit for trunk/Source/JavaScriptCore/yarr/YarrPattern.cpp
- Timestamp:
- Dec 8, 2017, 12:32:42 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/yarr/YarrPattern.cpp
r225683 r225695 829 829 term.frameLocation = currentCallFrameSize; 830 830 if (term.quantityMaxCount == 1 && !term.parentheses.isCopy) { 831 if (term.quantityType != QuantifierFixedCount) 832 currentCallFrameSize += YarrStackSpaceForBackTrackInfoParenthesesOnce; 831 currentCallFrameSize += YarrStackSpaceForBackTrackInfoParenthesesOnce; 833 832 error = setupDisjunctionOffsets(term.parentheses.disjunction, currentCallFrameSize, currentInputPosition.unsafeGet(), currentCallFrameSize); 834 833 if (error) … … 846 845 } else { 847 846 term.inputPosition = currentInputPosition.unsafeGet(); 848 unsigned ignoredCallFrameSize;849 error = setupDisjunctionOffsets(term.parentheses.disjunction, 0, currentInputPosition.unsafeGet(), ignoredCallFrameSize);847 currentCallFrameSize += YarrStackSpaceForBackTrackInfoParentheses; 848 error = setupDisjunctionOffsets(term.parentheses.disjunction, currentCallFrameSize, currentInputPosition.unsafeGet(), currentCallFrameSize); 850 849 if (error) 851 850 return error; 852 currentCallFrameSize += YarrStackSpaceForBackTrackInfoParentheses;853 851 } 854 852 // Fixed count of 1 could be accepted, if they have a fixed size *AND* if all alternatives are of the same length. … … 1186 1184 } 1187 1185 1188 staticvoid indentForNestingLevel(PrintStream& out, unsigned nestingDepth)1186 void indentForNestingLevel(PrintStream& out, unsigned nestingDepth) 1189 1187 { 1190 1188 out.print(" "); … … 1193 1191 } 1194 1192 1195 staticvoid dumpUChar32(PrintStream& out, UChar32 c)1193 void dumpUChar32(PrintStream& out, UChar32 c) 1196 1194 { 1197 1195 if (c >= ' '&& c <= 0xff) … … 1199 1197 else 1200 1198 out.printf("0x%04x", c); 1199 } 1200 1201 void dumpCharacterClass(PrintStream& out, YarrPattern* pattern, CharacterClass* characterClass) 1202 { 1203 if (characterClass == pattern->anyCharacterClass()) 1204 out.print("<any character>"); 1205 else if (characterClass == pattern->newlineCharacterClass()) 1206 out.print("<newline>"); 1207 else if (characterClass == pattern->digitsCharacterClass()) 1208 out.print("<digits>"); 1209 else if (characterClass == pattern->spacesCharacterClass()) 1210 out.print("<whitespace>"); 1211 else if (characterClass == pattern->wordcharCharacterClass()) 1212 out.print("<word>"); 1213 else if (characterClass == pattern->wordUnicodeIgnoreCaseCharCharacterClass()) 1214 out.print("<unicode ignore case>"); 1215 else if (characterClass == pattern->nondigitsCharacterClass()) 1216 out.print("<non-digits>"); 1217 else if (characterClass == pattern->nonspacesCharacterClass()) 1218 out.print("<non-whitespace>"); 1219 else if (characterClass == pattern->nonwordcharCharacterClass()) 1220 out.print("<non-word>"); 1221 else if (characterClass == pattern->nonwordUnicodeIgnoreCaseCharCharacterClass()) 1222 out.print("<unicode non-ignore case>"); 1223 else { 1224 bool needMatchesRangesSeperator = false; 1225 1226 auto dumpMatches = [&] (const char* prefix, Vector<UChar32> matches) { 1227 size_t matchesSize = matches.size(); 1228 if (matchesSize) { 1229 if (needMatchesRangesSeperator) 1230 out.print(","); 1231 needMatchesRangesSeperator = true; 1232 1233 out.print(prefix, ":("); 1234 for (size_t i = 0; i < matchesSize; ++i) { 1235 if (i) 1236 out.print(","); 1237 dumpUChar32(out, matches[i]); 1238 } 1239 out.print(")"); 1240 } 1241 }; 1242 1243 auto dumpRanges = [&] (const char* prefix, Vector<CharacterRange> ranges) { 1244 size_t rangeSize = ranges.size(); 1245 if (rangeSize) { 1246 if (needMatchesRangesSeperator) 1247 out.print(","); 1248 needMatchesRangesSeperator = true; 1249 1250 out.print(prefix, " ranges:("); 1251 for (size_t i = 0; i < rangeSize; ++i) { 1252 if (i) 1253 out.print(","); 1254 CharacterRange range = ranges[i]; 1255 out.print("("); 1256 dumpUChar32(out, range.begin); 1257 out.print(".."); 1258 dumpUChar32(out, range.end); 1259 out.print(")"); 1260 } 1261 out.print(")"); 1262 } 1263 }; 1264 1265 out.print("["); 1266 dumpMatches("ASCII", characterClass->m_matches); 1267 dumpRanges("ASCII", characterClass->m_ranges); 1268 dumpMatches("Unicode", characterClass->m_matchesUnicode); 1269 dumpRanges("Unicode", characterClass->m_rangesUnicode); 1270 out.print("]"); 1271 } 1201 1272 } 1202 1273 … … 1240 1311 indentForNestingLevel(out, nestingDepth); 1241 1312 1242 if (invert() && (type != TypeParenthesesSubpattern && type != TypeParentheticalAssertion)) 1243 out.print("not "); 1313 if (type != TypeParenthesesSubpattern && type != TypeParentheticalAssertion) { 1314 if (invert()) 1315 out.print("not "); 1316 } 1244 1317 1245 1318 switch (type) { … … 1255 1328 case TypePatternCharacter: 1256 1329 out.printf("character "); 1330 out.printf("inputPosition %u ", inputPosition); 1257 1331 if (thisPattern->ignoreCase() && isASCIIAlpha(patternCharacter)) { 1258 1332 dumpUChar32(out, toASCIIUpper(patternCharacter)); … … 1376 1450 out.print(",terminal"); 1377 1451 1378 if (quantityMaxCount != 1 || parentheses.isCopy || quantityType != QuantifierFixedCount) 1379 out.println(",frame location ", frameLocation); 1380 else 1381 out.println(); 1452 out.println(",frame location ", frameLocation); 1382 1453 1383 1454 if (parentheses.disjunction->m_alternatives.size() > 1) { 1384 1455 indentForNestingLevel(out, nestingDepth + 1); 1385 1456 unsigned alternativeFrameLocation = frameLocation; 1386 if (quantity Type != QuantifierFixedCount)1457 if (quantityMaxCount == 1 && !parentheses.isCopy) 1387 1458 alternativeFrameLocation += YarrStackSpaceForBackTrackInfoParenthesesOnce; 1459 else if (parentheses.isTerminal) 1460 alternativeFrameLocation += YarrStackSpaceForBackTrackInfoParenthesesTerminal; 1461 else 1462 alternativeFrameLocation += YarrStackSpaceForBackTrackInfoParentheses; 1388 1463 out.println("alternative list,frame location ", alternativeFrameLocation); 1389 1464 } … … 1462 1537 } 1463 1538 out.print(":\n"); 1539 if (m_body->m_callFrameSize) 1540 out.print(" callframe size: ", m_body->m_callFrameSize, "\n"); 1464 1541 m_body->dump(out, this); 1465 1542 }
Note:
See TracChangeset
for help on using the changeset viewer.