| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/3rdparty/masm/yarr/YarrPattern.h |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | namespace JSC { namespace Yarr { | - | ||||||
| 4 | - | |||||||
| 5 | struct PatternDisjunction; | - | ||||||
| 6 | - | |||||||
| 7 | struct CharacterRange { | - | ||||||
| 8 | UChar begin; | - | ||||||
| 9 | UChar end; | - | ||||||
| 10 | - | |||||||
| 11 | CharacterRange(UChar begin, UChar end) | - | ||||||
| 12 | : begin(begin) | - | ||||||
| 13 | , end(end) | - | ||||||
| 14 | { | - | ||||||
| 15 | } executed 20366 times by 8 tests: end of blockExecuted by:
| 20366 | ||||||
| 16 | }; | - | ||||||
| 17 | - | |||||||
| 18 | struct CharacterClass { | - | ||||||
| 19 | ; | - | ||||||
| 20 | public: | - | ||||||
| 21 | - | |||||||
| 22 | - | |||||||
| 23 | - | |||||||
| 24 | CharacterClass() | - | ||||||
| 25 | : m_table(0) | - | ||||||
| 26 | { | - | ||||||
| 27 | } executed 4532 times by 8 tests: end of blockExecuted by:
| 4532 | ||||||
| 28 | CharacterClass(const char* table, bool inverted) | - | ||||||
| 29 | : m_table(table) | - | ||||||
| 30 | , m_tableInverted(inverted) | - | ||||||
| 31 | { | - | ||||||
| 32 | } executed 1064 times by 3 tests: end of blockExecuted by:
| 1064 | ||||||
| 33 | Vector<UChar> m_matches; | - | ||||||
| 34 | Vector<CharacterRange> m_ranges; | - | ||||||
| 35 | Vector<UChar> m_matchesUnicode; | - | ||||||
| 36 | Vector<CharacterRange> m_rangesUnicode; | - | ||||||
| 37 | - | |||||||
| 38 | const char* m_table; | - | ||||||
| 39 | bool m_tableInverted; | - | ||||||
| 40 | }; | - | ||||||
| 41 | - | |||||||
| 42 | enum QuantifierType { | - | ||||||
| 43 | QuantifierFixedCount, | - | ||||||
| 44 | QuantifierGreedy, | - | ||||||
| 45 | QuantifierNonGreedy, | - | ||||||
| 46 | }; | - | ||||||
| 47 | - | |||||||
| 48 | struct PatternTerm { | - | ||||||
| 49 | enum Type { | - | ||||||
| 50 | TypeAssertionBOL, | - | ||||||
| 51 | TypeAssertionEOL, | - | ||||||
| 52 | TypeAssertionWordBoundary, | - | ||||||
| 53 | TypePatternCharacter, | - | ||||||
| 54 | TypeCharacterClass, | - | ||||||
| 55 | TypeBackReference, | - | ||||||
| 56 | TypeForwardReference, | - | ||||||
| 57 | TypeParenthesesSubpattern, | - | ||||||
| 58 | TypeParentheticalAssertion, | - | ||||||
| 59 | TypeDotStarEnclosure, | - | ||||||
| 60 | } type; | - | ||||||
| 61 | bool m_capture :1; | - | ||||||
| 62 | bool m_invert :1; | - | ||||||
| 63 | union { | - | ||||||
| 64 | UChar patternCharacter; | - | ||||||
| 65 | CharacterClass* characterClass; | - | ||||||
| 66 | unsigned backReferenceSubpatternId; | - | ||||||
| 67 | struct { | - | ||||||
| 68 | PatternDisjunction* disjunction; | - | ||||||
| 69 | unsigned subpatternId; | - | ||||||
| 70 | unsigned lastSubpatternId; | - | ||||||
| 71 | bool isCopy; | - | ||||||
| 72 | bool isTerminal; | - | ||||||
| 73 | } parentheses; | - | ||||||
| 74 | struct { | - | ||||||
| 75 | bool bolAnchor : 1; | - | ||||||
| 76 | bool eolAnchor : 1; | - | ||||||
| 77 | } anchors; | - | ||||||
| 78 | }; | - | ||||||
| 79 | QuantifierType quantityType; | - | ||||||
| 80 | Checked<unsigned> quantityCount; | - | ||||||
| 81 | int inputPosition; | - | ||||||
| 82 | unsigned frameLocation; | - | ||||||
| 83 | - | |||||||
| 84 | PatternTerm(UChar ch) | - | ||||||
| 85 | : type(PatternTerm::TypePatternCharacter) | - | ||||||
| 86 | , m_capture(false) | - | ||||||
| 87 | , m_invert(false) | - | ||||||
| 88 | { | - | ||||||
| 89 | patternCharacter = ch; | - | ||||||
| 90 | quantityType = QuantifierFixedCount; | - | ||||||
| 91 | quantityCount = 1; | - | ||||||
| 92 | } executed 2370145 times by 6 tests: end of blockExecuted by:
| 2370145 | ||||||
| 93 | - | |||||||
| 94 | PatternTerm(CharacterClass* charClass, bool invert) | - | ||||||
| 95 | : type(PatternTerm::TypeCharacterClass) | - | ||||||
| 96 | , m_capture(false) | - | ||||||
| 97 | , m_invert(invert) | - | ||||||
| 98 | { | - | ||||||
| 99 | characterClass = charClass; | - | ||||||
| 100 | quantityType = QuantifierFixedCount; | - | ||||||
| 101 | quantityCount = 1; | - | ||||||
| 102 | } executed 4594 times by 9 tests: end of blockExecuted by:
| 4594 | ||||||
| 103 | - | |||||||
| 104 | PatternTerm(Type type, unsigned subpatternId, PatternDisjunction* disjunction, bool capture = false, bool invert = false) | - | ||||||
| 105 | : type(type) | - | ||||||
| 106 | , m_capture(capture) | - | ||||||
| 107 | , m_invert(invert) | - | ||||||
| 108 | { | - | ||||||
| 109 | parentheses.disjunction = disjunction; | - | ||||||
| 110 | parentheses.subpatternId = subpatternId; | - | ||||||
| 111 | parentheses.isCopy = false; | - | ||||||
| 112 | parentheses.isTerminal = false; | - | ||||||
| 113 | quantityType = QuantifierFixedCount; | - | ||||||
| 114 | quantityCount = 1; | - | ||||||
| 115 | } executed 3575 times by 3 tests: end of blockExecuted by:
| 3575 | ||||||
| 116 | - | |||||||
| 117 | PatternTerm(Type type, bool invert = false) | - | ||||||
| 118 | : type(type) | - | ||||||
| 119 | , m_capture(false) | - | ||||||
| 120 | , m_invert(invert) | - | ||||||
| 121 | { | - | ||||||
| 122 | quantityType = QuantifierFixedCount; | - | ||||||
| 123 | quantityCount = 1; | - | ||||||
| 124 | } executed 1575 times by 5 tests: end of blockExecuted by:
| 1575 | ||||||
| 125 | - | |||||||
| 126 | PatternTerm(unsigned spatternId) | - | ||||||
| 127 | : type(TypeBackReference) | - | ||||||
| 128 | , m_capture(false) | - | ||||||
| 129 | , m_invert(false) | - | ||||||
| 130 | { | - | ||||||
| 131 | backReferenceSubpatternId = spatternId; | - | ||||||
| 132 | quantityType = QuantifierFixedCount; | - | ||||||
| 133 | quantityCount = 1; | - | ||||||
| 134 | } executed 180 times by 1 test: end of blockExecuted by:
| 180 | ||||||
| 135 | - | |||||||
| 136 | PatternTerm(bool bolAnchor, bool eolAnchor) | - | ||||||
| 137 | : type(TypeDotStarEnclosure) | - | ||||||
| 138 | , m_capture(false) | - | ||||||
| 139 | , m_invert(false) | - | ||||||
| 140 | { | - | ||||||
| 141 | anchors.bolAnchor = bolAnchor; | - | ||||||
| 142 | anchors.eolAnchor = eolAnchor; | - | ||||||
| 143 | quantityType = QuantifierFixedCount; | - | ||||||
| 144 | quantityCount = 1; | - | ||||||
| 145 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||
| 146 | - | |||||||
| 147 | static PatternTerm ForwardReference() | - | ||||||
| 148 | { | - | ||||||
| 149 | return executed 80 times by 1 test: PatternTerm(TypeForwardReference);return PatternTerm(TypeForwardReference);Executed by:
executed 80 times by 1 test: return PatternTerm(TypeForwardReference);Executed by:
| 80 | ||||||
| 150 | } | - | ||||||
| 151 | - | |||||||
| 152 | static PatternTerm BOL() | - | ||||||
| 153 | { | - | ||||||
| 154 | return executed 180 times by 5 tests: PatternTerm(TypeAssertionBOL);return PatternTerm(TypeAssertionBOL);Executed by:
executed 180 times by 5 tests: return PatternTerm(TypeAssertionBOL);Executed by:
| 180 | ||||||
| 155 | } | - | ||||||
| 156 | - | |||||||
| 157 | static PatternTerm EOL() | - | ||||||
| 158 | { | - | ||||||
| 159 | return executed 178 times by 5 tests: PatternTerm(TypeAssertionEOL);return PatternTerm(TypeAssertionEOL);Executed by:
executed 178 times by 5 tests: return PatternTerm(TypeAssertionEOL);Executed by:
| 178 | ||||||
| 160 | } | - | ||||||
| 161 | - | |||||||
| 162 | static PatternTerm WordBoundary(bool invert) | - | ||||||
| 163 | { | - | ||||||
| 164 | return executed 1135 times by 1 test: PatternTerm(TypeAssertionWordBoundary, invert);return PatternTerm(TypeAssertionWordBoundary, invert);Executed by:
executed 1135 times by 1 test: return PatternTerm(TypeAssertionWordBoundary, invert);Executed by:
| 1135 | ||||||
| 165 | } | - | ||||||
| 166 | - | |||||||
| 167 | bool invert() | - | ||||||
| 168 | { | - | ||||||
| 169 | return executed 7818 times by 9 tests: m_invert;return m_invert;Executed by:
executed 7818 times by 9 tests: return m_invert;Executed by:
| 7818 | ||||||
| 170 | } | - | ||||||
| 171 | - | |||||||
| 172 | bool capture() | - | ||||||
| 173 | { | - | ||||||
| 174 | return executed 9880 times by 3 tests: m_capture;return m_capture;Executed by:
executed 9880 times by 3 tests: return m_capture;Executed by:
| 9880 | ||||||
| 175 | } | - | ||||||
| 176 | - | |||||||
| 177 | void quantify(unsigned count, QuantifierType type) | - | ||||||
| 178 | { | - | ||||||
| 179 | quantityCount = count; | - | ||||||
| 180 | quantityType = type; | - | ||||||
| 181 | } executed 5211 times by 8 tests: end of blockExecuted by:
| 5211 | ||||||
| 182 | }; | - | ||||||
| 183 | - | |||||||
| 184 | struct PatternAlternative { | - | ||||||
| 185 | ; | - | ||||||
| 186 | public: | - | ||||||
| 187 | PatternAlternative(PatternDisjunction* disjunction) | - | ||||||
| 188 | : m_parent(disjunction) | - | ||||||
| 189 | , m_onceThrough(false) | - | ||||||
| 190 | , m_hasFixedSize(false) | - | ||||||
| 191 | , m_startsWithBOL(false) | - | ||||||
| 192 | , m_containsBOL(false) | - | ||||||
| 193 | { | - | ||||||
| 194 | } executed 1156474 times by 153 tests: end of blockExecuted by:
| 1156474 | ||||||
| 195 | - | |||||||
| 196 | PatternTerm& lastTerm() | - | ||||||
| 197 | { | - | ||||||
| 198 | (!(m_terms.size()) ? (qmlWTFReportAssertionFailure(__FILE__, 233, __PRETTY_FUNCTION__, "m_terms.size()"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
| 199 | return executed 9888 times by 8 tests: m_terms[m_terms.size() - 1];return m_terms[m_terms.size() - 1];Executed by:
executed 9888 times by 8 tests: return m_terms[m_terms.size() - 1];Executed by:
| 9888 | ||||||
| 200 | } | - | ||||||
| 201 | - | |||||||
| 202 | void removeLastTerm() | - | ||||||
| 203 | { | - | ||||||
| 204 | (!(m_terms.size()) ? (qmlWTFReportAssertionFailure(__FILE__, 239, __PRETTY_FUNCTION__, "m_terms.size()"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
| 205 | m_terms.shrink(m_terms.size() - 1); | - | ||||||
| 206 | } never executed: end of block | 0 | ||||||
| 207 | - | |||||||
| 208 | void setOnceThrough() | - | ||||||
| 209 | { | - | ||||||
| 210 | m_onceThrough = true; | - | ||||||
| 211 | } executed 132 times by 5 tests: end of blockExecuted by:
| 132 | ||||||
| 212 | - | |||||||
| 213 | bool onceThrough() | - | ||||||
| 214 | { | - | ||||||
| 215 | return executed 2299174 times by 153 tests: m_onceThrough;return m_onceThrough;Executed by:
executed 2299174 times by 153 tests: return m_onceThrough;Executed by:
| 2299174 | ||||||
| 216 | } | - | ||||||
| 217 | - | |||||||
| 218 | Vector<PatternTerm> m_terms; | - | ||||||
| 219 | PatternDisjunction* m_parent; | - | ||||||
| 220 | unsigned m_minimumSize; | - | ||||||
| 221 | bool m_onceThrough : 1; | - | ||||||
| 222 | bool m_hasFixedSize : 1; | - | ||||||
| 223 | bool m_startsWithBOL : 1; | - | ||||||
| 224 | bool m_containsBOL : 1; | - | ||||||
| 225 | }; | - | ||||||
| 226 | - | |||||||
| 227 | struct PatternDisjunction { | - | ||||||
| 228 | ; | - | ||||||
| 229 | public: | - | ||||||
| 230 | PatternDisjunction(PatternAlternative* parent = 0) | - | ||||||
| 231 | : m_parent(parent) | - | ||||||
| 232 | , m_hasFixedSize(false) | - | ||||||
| 233 | { | - | ||||||
| 234 | } executed 1153678 times by 153 tests: end of blockExecuted by:
| 1153678 | ||||||
| 235 | - | |||||||
| 236 | PatternAlternative* addNewAlternative() | - | ||||||
| 237 | { | - | ||||||
| 238 | PatternAlternative* alternative = new PatternAlternative(this); | - | ||||||
| 239 | m_alternatives.append(adoptPtr(alternative)); | - | ||||||
| 240 | return executed 1154410 times by 153 tests: alternative;return alternative;Executed by:
executed 1154410 times by 153 tests: return alternative;Executed by:
| 1154410 | ||||||
| 241 | } | - | ||||||
| 242 | - | |||||||
| 243 | Vector<OwnPtr<PatternAlternative> > m_alternatives; | - | ||||||
| 244 | PatternAlternative* m_parent; | - | ||||||
| 245 | unsigned m_minimumSize; | - | ||||||
| 246 | unsigned m_callFrameSize; | - | ||||||
| 247 | bool m_hasFixedSize; | - | ||||||
| 248 | }; | - | ||||||
| 249 | - | |||||||
| 250 | - | |||||||
| 251 | - | |||||||
| 252 | - | |||||||
| 253 | - | |||||||
| 254 | CharacterClass* newlineCreate(); | - | ||||||
| 255 | CharacterClass* digitsCreate(); | - | ||||||
| 256 | CharacterClass* spacesCreate(); | - | ||||||
| 257 | CharacterClass* wordcharCreate(); | - | ||||||
| 258 | CharacterClass* nondigitsCreate(); | - | ||||||
| 259 | CharacterClass* nonspacesCreate(); | - | ||||||
| 260 | CharacterClass* nonwordcharCreate(); | - | ||||||
| 261 | - | |||||||
| 262 | struct TermChain { | - | ||||||
| 263 | TermChain(PatternTerm term) | - | ||||||
| 264 | : term(term) | - | ||||||
| 265 | {} never executed: end of block | 0 | ||||||
| 266 | - | |||||||
| 267 | PatternTerm term; | - | ||||||
| 268 | Vector<TermChain> hotTerms; | - | ||||||
| 269 | }; | - | ||||||
| 270 | - | |||||||
| 271 | struct YarrPattern { | - | ||||||
| 272 | YarrPattern(const String& pattern, bool ignoreCase, bool multiline, const char** error); | - | ||||||
| 273 | - | |||||||
| 274 | void reset() | - | ||||||
| 275 | { | - | ||||||
| 276 | m_numSubpatterns = 0; | - | ||||||
| 277 | m_maxBackReference = 0; | - | ||||||
| 278 | - | |||||||
| 279 | m_containsBackreferences = false; | - | ||||||
| 280 | m_containsBOL = false; | - | ||||||
| 281 | - | |||||||
| 282 | newlineCached = 0; | - | ||||||
| 283 | digitsCached = 0; | - | ||||||
| 284 | spacesCached = 0; | - | ||||||
| 285 | wordcharCached = 0; | - | ||||||
| 286 | nondigitsCached = 0; | - | ||||||
| 287 | nonspacesCached = 0; | - | ||||||
| 288 | nonwordcharCached = 0; | - | ||||||
| 289 | - | |||||||
| 290 | m_disjunctions.clear(); | - | ||||||
| 291 | m_userCharacterClasses.clear(); | - | ||||||
| 292 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||
| 293 | - | |||||||
| 294 | bool containsIllegalBackReference() | - | ||||||
| 295 | { | - | ||||||
| 296 | return executed 1150529 times by 153 tests: m_maxBackReference > m_numSubpatterns;return m_maxBackReference > m_numSubpatterns;Executed by:
executed 1150529 times by 153 tests: return m_maxBackReference > m_numSubpatterns;Executed by:
| 1150529 | ||||||
| 297 | } | - | ||||||
| 298 | - | |||||||
| 299 | CharacterClass* newlineCharacterClass() | - | ||||||
| 300 | { | - | ||||||
| 301 | if (!newlineCached
| 274-814 | ||||||
| 302 | m_userCharacterClasses.append(adoptPtr(newlineCached = newlineCreate())); executed 814 times by 5 tests: m_userCharacterClasses.append(adoptPtr(newlineCached = newlineCreate()));Executed by:
| 814 | ||||||
| 303 | return executed 1089 times by 5 tests: newlineCached;return newlineCached;Executed by:
executed 1089 times by 5 tests: return newlineCached;Executed by:
| 1089 | ||||||
| 304 | } | - | ||||||
| 305 | CharacterClass* digitsCharacterClass() | - | ||||||
| 306 | { | - | ||||||
| 307 | if (!digitsCached
| 72-329 | ||||||
| 308 | m_userCharacterClasses.append(adoptPtr(digitsCached = digitsCreate())); executed 329 times by 3 tests: m_userCharacterClasses.append(adoptPtr(digitsCached = digitsCreate()));Executed by:
| 329 | ||||||
| 309 | return executed 402 times by 3 tests: digitsCached;return digitsCached;Executed by:
executed 402 times by 3 tests: return digitsCached;Executed by:
| 402 | ||||||
| 310 | } | - | ||||||
| 311 | CharacterClass* spacesCharacterClass() | - | ||||||
| 312 | { | - | ||||||
| 313 | if (!spacesCached
| 307-1122 | ||||||
| 314 | m_userCharacterClasses.append(adoptPtr(spacesCached = spacesCreate())); executed 307 times by 3 tests: m_userCharacterClasses.append(adoptPtr(spacesCached = spacesCreate()));Executed by:
| 307 | ||||||
| 315 | return executed 1430 times by 3 tests: spacesCached;return spacesCached;Executed by:
executed 1430 times by 3 tests: return spacesCached;Executed by:
| 1430 | ||||||
| 316 | } | - | ||||||
| 317 | CharacterClass* wordcharCharacterClass() | - | ||||||
| 318 | { | - | ||||||
| 319 | if (!wordcharCached
| 588-3138 | ||||||
| 320 | m_userCharacterClasses.append(adoptPtr(wordcharCached = wordcharCreate())); executed 588 times by 1 test: m_userCharacterClasses.append(adoptPtr(wordcharCached = wordcharCreate()));Executed by:
| 588 | ||||||
| 321 | return executed 3726 times by 1 test: wordcharCached;return wordcharCached;Executed by:
executed 3726 times by 1 test: return wordcharCached;Executed by:
| 3726 | ||||||
| 322 | } | - | ||||||
| 323 | CharacterClass* nondigitsCharacterClass() | - | ||||||
| 324 | { | - | ||||||
| 325 | if (!nondigitsCached
| 0-4 | ||||||
| 326 | m_userCharacterClasses.append(adoptPtr(nondigitsCached = nondigitsCreate())); executed 4 times by 1 test: m_userCharacterClasses.append(adoptPtr(nondigitsCached = nondigitsCreate()));Executed by:
| 4 | ||||||
| 327 | return executed 4 times by 1 test: nondigitsCached;return nondigitsCached;Executed by:
executed 4 times by 1 test: return nondigitsCached;Executed by:
| 4 | ||||||
| 328 | } | - | ||||||
| 329 | CharacterClass* nonspacesCharacterClass() | - | ||||||
| 330 | { | - | ||||||
| 331 | if (!nonspacesCached
| 164-1100 | ||||||
| 332 | m_userCharacterClasses.append(adoptPtr(nonspacesCached = nonspacesCreate())); executed 164 times by 1 test: m_userCharacterClasses.append(adoptPtr(nonspacesCached = nonspacesCreate()));Executed by:
| 164 | ||||||
| 333 | return executed 1264 times by 1 test: nonspacesCached;return nonspacesCached;Executed by:
executed 1264 times by 1 test: return nonspacesCached;Executed by:
| 1264 | ||||||
| 334 | } | - | ||||||
| 335 | CharacterClass* nonwordcharCharacterClass() | - | ||||||
| 336 | { | - | ||||||
| 337 | if (!nonwordcharCached
| 0-4 | ||||||
| 338 | m_userCharacterClasses.append(adoptPtr(nonwordcharCached = nonwordcharCreate())); executed 4 times by 1 test: m_userCharacterClasses.append(adoptPtr(nonwordcharCached = nonwordcharCreate()));Executed by:
| 4 | ||||||
| 339 | return executed 4 times by 1 test: nonwordcharCached;return nonwordcharCached;Executed by:
executed 4 times by 1 test: return nonwordcharCached;Executed by:
| 4 | ||||||
| 340 | } | - | ||||||
| 341 | - | |||||||
| 342 | bool m_ignoreCase : 1; | - | ||||||
| 343 | bool m_multiline : 1; | - | ||||||
| 344 | bool m_containsBackreferences : 1; | - | ||||||
| 345 | bool m_containsBOL : 1; | - | ||||||
| 346 | unsigned m_numSubpatterns; | - | ||||||
| 347 | unsigned m_maxBackReference; | - | ||||||
| 348 | PatternDisjunction* m_body; | - | ||||||
| 349 | Vector<OwnPtr<PatternDisjunction>, 4> m_disjunctions; | - | ||||||
| 350 | Vector<OwnPtr<CharacterClass> > m_userCharacterClasses; | - | ||||||
| 351 | - | |||||||
| 352 | private: | - | ||||||
| 353 | const char* compile(const String& patternString); | - | ||||||
| 354 | - | |||||||
| 355 | CharacterClass* newlineCached; | - | ||||||
| 356 | CharacterClass* digitsCached; | - | ||||||
| 357 | CharacterClass* spacesCached; | - | ||||||
| 358 | CharacterClass* wordcharCached; | - | ||||||
| 359 | CharacterClass* nondigitsCached; | - | ||||||
| 360 | CharacterClass* nonspacesCached; | - | ||||||
| 361 | CharacterClass* nonwordcharCached; | - | ||||||
| 362 | }; | - | ||||||
| 363 | - | |||||||
| 364 | } } | - | ||||||
| Switch to Source code | Preprocessed file |