OpenCoverage

YarrInterpreter.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/3rdparty/masm/yarr/YarrInterpreter.h
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4namespace WTF {-
5class BumpPointerAllocator;-
6}-
7using WTF::BumpPointerAllocator;-
8-
9namespace JSC { namespace Yarr {-
10-
11class ByteDisjunction;-
12-
13struct ByteTerm {-
14 enum Type {-
15 TypeBodyAlternativeBegin,-
16 TypeBodyAlternativeDisjunction,-
17 TypeBodyAlternativeEnd,-
18 TypeAlternativeBegin,-
19 TypeAlternativeDisjunction,-
20 TypeAlternativeEnd,-
21 TypeSubpatternBegin,-
22 TypeSubpatternEnd,-
23 TypeAssertionBOL,-
24 TypeAssertionEOL,-
25 TypeAssertionWordBoundary,-
26 TypePatternCharacterOnce,-
27 TypePatternCharacterFixed,-
28 TypePatternCharacterGreedy,-
29 TypePatternCharacterNonGreedy,-
30 TypePatternCasedCharacterOnce,-
31 TypePatternCasedCharacterFixed,-
32 TypePatternCasedCharacterGreedy,-
33 TypePatternCasedCharacterNonGreedy,-
34 TypeCharacterClass,-
35 TypeBackReference,-
36 TypeParenthesesSubpattern,-
37 TypeParenthesesSubpatternOnceBegin,-
38 TypeParenthesesSubpatternOnceEnd,-
39 TypeParenthesesSubpatternTerminalBegin,-
40 TypeParenthesesSubpatternTerminalEnd,-
41 TypeParentheticalAssertionBegin,-
42 TypeParentheticalAssertionEnd,-
43 TypeCheckInput,-
44 TypeUncheckInput,-
45 TypeDotStarEnclosure,-
46 } type;-
47 union {-
48 struct {-
49 union {-
50 UChar patternCharacter;-
51 struct {-
52 UChar lo;-
53 UChar hi;-
54 } casedCharacter;-
55 CharacterClass* characterClass;-
56 unsigned subpatternId;-
57 };-
58 union {-
59 ByteDisjunction* parenthesesDisjunction;-
60 unsigned parenthesesWidth;-
61 };-
62 QuantifierType quantityType;-
63 unsigned quantityCount;-
64 } atom;-
65 struct {-
66 int next;-
67 int end;-
68 bool onceThrough;-
69 } alternative;-
70 struct {-
71 bool m_bol : 1;-
72 bool m_eol : 1;-
73 } anchors;-
74 unsigned checkInputCount;-
75 };-
76 unsigned frameLocation;-
77 bool m_capture : 1;-
78 bool m_invert : 1;-
79 unsigned inputPosition;-
80-
81 ByteTerm(UChar ch, int inputPos, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)-
82 : frameLocation(frameLocation)-
83 , m_capture(false)-
84 , m_invert(false)-
85 {-
86 switch (quantityType) {-
87 case
executed 1535 times by 1 test: case QuantifierFixedCount:
Executed by:
  • tst_ecmascripttests
QuantifierFixedCount:
executed 1535 times by 1 test: case QuantifierFixedCount:
Executed by:
  • tst_ecmascripttests
1535
88 type = (
(quantityCount == 1)Description
TRUEevaluated 1535 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
quantityCount == 1)
(quantityCount == 1)Description
TRUEevaluated 1535 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
? ByteTerm::TypePatternCharacterOnce : ByteTerm::TypePatternCharacterFixed;
0-1535
89 break;
executed 1535 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
1535
90 case
executed 228 times by 1 test: case QuantifierGreedy:
Executed by:
  • tst_ecmascripttests
QuantifierGreedy:
executed 228 times by 1 test: case QuantifierGreedy:
Executed by:
  • tst_ecmascripttests
228
91 type = ByteTerm::TypePatternCharacterGreedy;-
92 break;
executed 228 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
228
93 case
never executed: case QuantifierNonGreedy:
QuantifierNonGreedy:
never executed: case QuantifierNonGreedy:
0
94 type = ByteTerm::TypePatternCharacterNonGreedy;-
95 break;
never executed: break;
0
96 }-
97-
98 atom.patternCharacter = ch;-
99 atom.quantityType = quantityType;-
100 atom.quantityCount = quantityCount.unsafeGet();-
101 inputPosition = inputPos;-
102 }
executed 1763 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1763
103-
104 ByteTerm(UChar lo, UChar hi, int inputPos, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)-
105 : frameLocation(frameLocation)-
106 , m_capture(false)-
107 , m_invert(false)-
108 {-
109 switch (quantityType) {-
110 case
executed 32 times by 1 test: case QuantifierFixedCount:
Executed by:
  • tst_ecmascripttests
QuantifierFixedCount:
executed 32 times by 1 test: case QuantifierFixedCount:
Executed by:
  • tst_ecmascripttests
32
111 type = (
(quantityCount == 1)Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
quantityCount == 1)
(quantityCount == 1)Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
? ByteTerm::TypePatternCasedCharacterOnce : ByteTerm::TypePatternCasedCharacterFixed;
0-32
112 break;
executed 32 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
32
113 case
never executed: case QuantifierGreedy:
QuantifierGreedy:
never executed: case QuantifierGreedy:
0
114 type = ByteTerm::TypePatternCasedCharacterGreedy;-
115 break;
never executed: break;
0
116 case
never executed: case QuantifierNonGreedy:
QuantifierNonGreedy:
never executed: case QuantifierNonGreedy:
0
117 type = ByteTerm::TypePatternCasedCharacterNonGreedy;-
118 break;
never executed: break;
0
119 }-
120-
121 atom.casedCharacter.lo = lo;-
122 atom.casedCharacter.hi = hi;-
123 atom.quantityType = quantityType;-
124 atom.quantityCount = quantityCount.unsafeGet();-
125 inputPosition = inputPos;-
126 }
executed 32 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
32
127-
128 ByteTerm(CharacterClass* characterClass, bool invert, int inputPos)-
129 : type(ByteTerm::TypeCharacterClass)-
130 , m_capture(false)-
131 , m_invert(invert)-
132 {-
133 atom.characterClass = characterClass;-
134 atom.quantityType = QuantifierFixedCount;-
135 atom.quantityCount = 1;-
136 inputPosition = inputPos;-
137 }
executed 1632 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1632
138-
139 ByteTerm(Type type, unsigned subpatternId, ByteDisjunction* parenthesesInfo, bool capture, int inputPos)-
140 : type(type)-
141 , m_capture(capture)-
142 , m_invert(false)-
143 {-
144 atom.subpatternId = subpatternId;-
145 atom.parenthesesDisjunction = parenthesesInfo;-
146 atom.quantityType = QuantifierFixedCount;-
147 atom.quantityCount = 1;-
148 inputPosition = inputPos;-
149 }
executed 412 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
412
150-
151 ByteTerm(Type type, bool invert = false)-
152 : type(type)-
153 , m_capture(false)-
154 , m_invert(invert)-
155 {-
156 atom.quantityType = QuantifierFixedCount;-
157 atom.quantityCount = 1;-
158 }
executed 4686 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
4686
159-
160 ByteTerm(Type type, unsigned subpatternId, bool capture, bool invert, int inputPos)-
161 : type(type)-
162 , m_capture(capture)-
163 , m_invert(invert)-
164 {-
165 atom.subpatternId = subpatternId;-
166 atom.quantityType = QuantifierFixedCount;-
167 atom.quantityCount = 1;-
168 inputPosition = inputPos;-
169 }
executed 1996 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1996
170-
171 static ByteTerm BOL(int inputPos)-
172 {-
173 ByteTerm term(TypeAssertionBOL);-
174 term.inputPosition = inputPos;-
175 return
executed 24 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
term;
executed 24 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
24
176 }-
177-
178 static ByteTerm CheckInput(Checked<unsigned> count)-
179 {-
180 ByteTerm term(TypeCheckInput);-
181 term.checkInputCount = count.unsafeGet();-
182 return
executed 1255 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
term;
executed 1255 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
1255
183 }-
184-
185 static ByteTerm UncheckInput(Checked<unsigned> count)-
186 {-
187 ByteTerm term(TypeUncheckInput);-
188 term.checkInputCount = count.unsafeGet();-
189 return
never executed: return term;
term;
never executed: return term;
0
190 }-
191-
192 static ByteTerm EOL(int inputPos)-
193 {-
194 ByteTerm term(TypeAssertionEOL);-
195 term.inputPosition = inputPos;-
196 return
executed 24 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
term;
executed 24 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
24
197 }-
198-
199 static ByteTerm WordBoundary(bool invert, int inputPos)-
200 {-
201 ByteTerm term(TypeAssertionWordBoundary, invert);-
202 term.inputPosition = inputPos;-
203 return
executed 8 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
term;
executed 8 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
8
204 }-
205-
206 static ByteTerm BackReference(unsigned subpatternId, int inputPos)-
207 {-
208 return
executed 192 times by 1 test: return ByteTerm(TypeBackReference, subpatternId, false, false, inputPos);
Executed by:
  • tst_ecmascripttests
ByteTerm(TypeBackReference, subpatternId, false, false, inputPos);
executed 192 times by 1 test: return ByteTerm(TypeBackReference, subpatternId, false, false, inputPos);
Executed by:
  • tst_ecmascripttests
192
209 }-
210-
211 static ByteTerm BodyAlternativeBegin(bool onceThrough)-
212 {-
213 ByteTerm term(TypeBodyAlternativeBegin);-
214 term.alternative.next = 0;-
215 term.alternative.end = 0;-
216 term.alternative.onceThrough = onceThrough;-
217 return
executed 208 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
term;
executed 208 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
208
218 }-
219-
220 static ByteTerm BodyAlternativeDisjunction(bool onceThrough)-
221 {-
222 ByteTerm term(TypeBodyAlternativeDisjunction);-
223 term.alternative.next = 0;-
224 term.alternative.end = 0;-
225 term.alternative.onceThrough = onceThrough;-
226 return
executed 24 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
term;
executed 24 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
24
227 }-
228-
229 static ByteTerm BodyAlternativeEnd()-
230 {-
231 ByteTerm term(TypeBodyAlternativeEnd);-
232 term.alternative.next = 0;-
233 term.alternative.end = 0;-
234 term.alternative.onceThrough = false;-
235 return
executed 208 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
term;
executed 208 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
208
236 }-
237-
238 static ByteTerm AlternativeBegin()-
239 {-
240 ByteTerm term(TypeAlternativeBegin);-
241 term.alternative.next = 0;-
242 term.alternative.end = 0;-
243 term.alternative.onceThrough = false;-
244 return
executed 1108 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
term;
executed 1108 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
1108
245 }-
246-
247 static ByteTerm AlternativeDisjunction()-
248 {-
249 ByteTerm term(TypeAlternativeDisjunction);-
250 term.alternative.next = 0;-
251 term.alternative.end = 0;-
252 term.alternative.onceThrough = false;-
253 return
executed 564 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
term;
executed 564 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
564
254 }-
255-
256 static ByteTerm AlternativeEnd()-
257 {-
258 ByteTerm term(TypeAlternativeEnd);-
259 term.alternative.next = 0;-
260 term.alternative.end = 0;-
261 term.alternative.onceThrough = false;-
262 return
executed 440 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
term;
executed 440 times by 1 test: return term;
Executed by:
  • tst_ecmascripttests
440
263 }-
264-
265 static ByteTerm SubpatternBegin()-
266 {-
267 return
executed 412 times by 1 test: return ByteTerm(TypeSubpatternBegin);
Executed by:
  • tst_ecmascripttests
ByteTerm(TypeSubpatternBegin);
executed 412 times by 1 test: return ByteTerm(TypeSubpatternBegin);
Executed by:
  • tst_ecmascripttests
412
268 }-
269-
270 static ByteTerm SubpatternEnd()-
271 {-
272 return
executed 412 times by 1 test: return ByteTerm(TypeSubpatternEnd);
Executed by:
  • tst_ecmascripttests
ByteTerm(TypeSubpatternEnd);
executed 412 times by 1 test: return ByteTerm(TypeSubpatternEnd);
Executed by:
  • tst_ecmascripttests
412
273 }-
274-
275 static ByteTerm DotStarEnclosure(bool bolAnchor, bool eolAnchor)-
276 {-
277 ByteTerm term(TypeDotStarEnclosure);-
278 term.anchors.m_bol = bolAnchor;-
279 term.anchors.m_eol = eolAnchor;-
280 return
never executed: return term;
term;
never executed: return term;
0
281 }-
282-
283 bool invert()-
284 {-
285 return
executed 3684528 times by 1 test: return m_invert;
Executed by:
  • tst_ecmascripttests
m_invert;
executed 3684528 times by 1 test: return m_invert;
Executed by:
  • tst_ecmascripttests
3684528
286 }-
287-
288 bool capture()-
289 {-
290 return
executed 2906 times by 1 test: return m_capture;
Executed by:
  • tst_ecmascripttests
m_capture;
executed 2906 times by 1 test: return m_capture;
Executed by:
  • tst_ecmascripttests
2906
291 }-
292};-
293-
294class ByteDisjunction {-
295 ;-
296public:-
297 ByteDisjunction(unsigned numSubpatterns, unsigned frameSize)-
298 : m_numSubpatterns(numSubpatterns)-
299 , m_frameSize(frameSize)-
300 {-
301 }
executed 620 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
620
302-
303 Vector<ByteTerm> terms;-
304 unsigned m_numSubpatterns;-
305 unsigned m_frameSize;-
306};-
307-
308struct BytecodePattern {-
309 ;-
310public:-
311 BytecodePattern(PassOwnPtr<ByteDisjunction> body, Vector<OwnPtr<ByteDisjunction> >& parenthesesInfoToAdopt, YarrPattern& pattern, BumpPointerAllocator* allocator)-
312 : m_body(body)-
313 , m_ignoreCase(pattern.m_ignoreCase)-
314 , m_multiline(pattern.m_multiline)-
315 , m_allocator(allocator)-
316 {-
317 m_body->terms.shrinkToFit();-
318-
319 newlineCharacterClass = pattern.newlineCharacterClass();-
320 wordcharCharacterClass = pattern.wordcharCharacterClass();-
321-
322 m_allParenthesesInfo.swap(parenthesesInfoToAdopt);-
323 m_allParenthesesInfo.shrinkToFit();-
324-
325 m_userCharacterClasses.swap(pattern.m_userCharacterClasses);-
326 m_userCharacterClasses.shrinkToFit();-
327 }
executed 207 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
207
328-
329 OwnPtr<ByteDisjunction> m_body;-
330 bool m_ignoreCase;-
331 bool m_multiline;-
332-
333-
334 BumpPointerAllocator* m_allocator;-
335-
336 CharacterClass* newlineCharacterClass;-
337 CharacterClass* wordcharCharacterClass;-
338-
339private:-
340 Vector<OwnPtr<ByteDisjunction> > m_allParenthesesInfo;-
341 Vector<OwnPtr<CharacterClass> > m_userCharacterClasses;-
342};-
343-
344 PassOwnPtr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*);-
345 unsigned interpret(BytecodePattern*, const String& input, unsigned start, unsigned* output);-
346unsigned interpret(BytecodePattern*, const LChar* input, unsigned length, unsigned start, unsigned* output);-
347unsigned interpret(BytecodePattern*, const UChar* input, unsigned length, unsigned start, unsigned* output);-
348-
349} }-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0