OpenCoverage

YarrInterpreter.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/3rdparty/masm/yarr/YarrInterpreter.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright (C) 2009 Apple Inc. All rights reserved.-
3 * Copyright (C) 2010 Peter Varga (pvarga@inf.u-szeged.hu), University of Szeged-
4 *-
5 * Redistribution and use in source and binary forms, with or without-
6 * modification, are permitted provided that the following conditions-
7 * are met:-
8 * 1. Redistributions of source code must retain the above copyright-
9 * notice, this list of conditions and the following disclaimer.-
10 * 2. Redistributions in binary form must reproduce the above copyright-
11 * notice, this list of conditions and the following disclaimer in the-
12 * documentation and/or other materials provided with the distribution.-
13 *-
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY-
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR-
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR-
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,-
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,-
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR-
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY-
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE-
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.-
25 */-
26-
27#include "config.h"-
28#include "YarrInterpreter.h"-
29-
30#include "Yarr.h"-
31#include "YarrCanonicalizeUCS2.h"-
32#include <wtf/BumpPointerAllocator.h>-
33#include <wtf/DataLog.h>-
34#include <wtf/text/CString.h>-
35#include <wtf/text/WTFString.h>-
36-
37#ifndef NDEBUG-
38#include <stdio.h>-
39#endif-
40-
41using namespace WTF;-
42-
43namespace JSC { namespace Yarr {-
44-
45template<typename CharType>-
46class Interpreter {-
47public:-
48 struct ParenthesesDisjunctionContext;-
49-
50 struct BackTrackInfoPatternCharacter {-
51 uintptr_t matchAmount;-
52 };-
53 struct BackTrackInfoCharacterClass {-
54 uintptr_t matchAmount;-
55 };-
56 struct BackTrackInfoBackReference {-
57 uintptr_t begin; // Not really needed for greedy quantifiers.-
58 uintptr_t matchAmount; // Not really needed for fixed quantifiers.-
59 };-
60 struct BackTrackInfoAlternative {-
61 uintptr_t offset;-
62 };-
63 struct BackTrackInfoParentheticalAssertion {-
64 uintptr_t begin;-
65 };-
66 struct BackTrackInfoParenthesesOnce {-
67 uintptr_t begin;-
68 };-
69 struct BackTrackInfoParenthesesTerminal {-
70 uintptr_t begin;-
71 };-
72 struct BackTrackInfoParentheses {-
73 uintptr_t matchAmount;-
74 ParenthesesDisjunctionContext* lastContext;-
75 };-
76-
77 static inline void appendParenthesesDisjunctionContext(BackTrackInfoParentheses* backTrack, ParenthesesDisjunctionContext* context)-
78 {-
79 context->next = backTrack->lastContext;-
80 backTrack->lastContext = context;-
81 ++backTrack->matchAmount;-
82 }
executed 504 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
504
83-
84 static inline void popParenthesesDisjunctionContext(BackTrackInfoParentheses* backTrack)-
85 {-
86 RELEASE_ASSERT(backTrack->matchAmount);-
87 RELEASE_ASSERT(backTrack->lastContext);-
88 backTrack->lastContext = backTrack->lastContext->next;-
89 --backTrack->matchAmount;-
90 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
24
91-
92 struct DisjunctionContext-
93 {-
94 DisjunctionContext()-
95 : term(0)-
96 {-
97 }
executed 2972 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
2972
98-
99 void* operator new(size_t, void* where)-
100 {-
101 return where;
executed 2972 times by 1 test: return where;
Executed by:
  • tst_ecmascripttests
2972
102 }-
103-
104 int term;-
105 unsigned matchBegin;-
106 unsigned matchEnd;-
107 uintptr_t frame[1];-
108 };-
109-
110 DisjunctionContext* allocDisjunctionContext(ByteDisjunction* disjunction)-
111 {-
112 size_t size = sizeof(DisjunctionContext) - sizeof(uintptr_t) + disjunction->m_frameSize * sizeof(uintptr_t);-
113 allocatorPool = allocatorPool->ensureCapacity(size);-
114 RELEASE_ASSERT(allocatorPool);-
115 return new (allocatorPool->alloc(size)) DisjunctionContext();
executed 216 times by 1 test: return new (allocatorPool->alloc(size)) DisjunctionContext();
Executed by:
  • tst_ecmascripttests
216
116 }-
117-
118 void freeDisjunctionContext(DisjunctionContext* context)-
119 {-
120 allocatorPool = allocatorPool->dealloc(context);-
121 }
executed 216 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
216
122-
123 struct ParenthesesDisjunctionContext-
124 {-
125 ParenthesesDisjunctionContext(unsigned* output, ByteTerm& term)-
126 : next(0)-
127 {-
128 unsigned firstSubpatternId = term.atom.subpatternId;-
129 unsigned numNestedSubpatterns = term.atom.parenthesesDisjunction->m_numSubpatterns;-
130-
131 for (unsigned i = 0; i < (numNestedSubpatterns << 1); ++i) {
i < (numNested...patterns << 1)Description
TRUEevaluated 6350 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2756 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2756-6350
132 subpatternBackup[i] = output[(firstSubpatternId << 1) + i];-
133 output[(firstSubpatternId << 1) + i] = offsetNoMatch;-
134 }
executed 6350 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
6350
135-
136 new (getDisjunctionContext(term)) DisjunctionContext();-
137 }
executed 2756 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
2756
138-
139 void* operator new(size_t, void* where)-
140 {-
141 return where;
executed 2756 times by 1 test: return where;
Executed by:
  • tst_ecmascripttests
2756
142 }-
143-
144 void restoreOutput(unsigned* output, unsigned firstSubpatternId, unsigned numNestedSubpatterns)-
145 {-
146 for (unsigned i = 0; i < (numNestedSubpatterns << 1); ++i)
i < (numNested...patterns << 1)Description
TRUEevaluated 4840 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2276 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2276-4840
147 output[(firstSubpatternId << 1) + i] = subpatternBackup[i];
executed 4840 times by 1 test: output[(firstSubpatternId << 1) + i] = subpatternBackup[i];
Executed by:
  • tst_ecmascripttests
4840
148 }
executed 2276 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
2276
149-
150 DisjunctionContext* getDisjunctionContext(ByteTerm& term)-
151 {-
152 return reinterpret_cast<DisjunctionContext*>(&(subpatternBackup[term.atom.parenthesesDisjunction->m_numSubpatterns << 1]));
executed 5961 times by 1 test: return reinterpret_cast<DisjunctionContext*>(&(subpatternBackup[term.atom.parenthesesDisjunction->m_numSubpatterns << 1]));
Executed by:
  • tst_ecmascripttests
5961
153 }-
154-
155 ParenthesesDisjunctionContext* next;-
156 unsigned subpatternBackup[1];-
157 };-
158-
159 ParenthesesDisjunctionContext* allocParenthesesDisjunctionContext(ByteDisjunction* disjunction, unsigned* output, ByteTerm& term)-
160 {-
161 size_t size = sizeof(ParenthesesDisjunctionContext) - sizeof(unsigned) + (term.atom.parenthesesDisjunction->m_numSubpatterns << 1) * sizeof(unsigned) + sizeof(DisjunctionContext) - sizeof(uintptr_t) + disjunction->m_frameSize * sizeof(uintptr_t);-
162 allocatorPool = allocatorPool->ensureCapacity(size);-
163 RELEASE_ASSERT(allocatorPool);-
164 return new (allocatorPool->alloc(size)) ParenthesesDisjunctionContext(output, term);
executed 2756 times by 1 test: return new (allocatorPool->alloc(size)) ParenthesesDisjunctionContext(output, term);
Executed by:
  • tst_ecmascripttests
2756
165 }-
166-
167 void freeParenthesesDisjunctionContext(ParenthesesDisjunctionContext* context)-
168 {-
169 allocatorPool = allocatorPool->dealloc(context);-
170 }
executed 2276 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
2276
171-
172 class InputStream {-
173 public:-
174 InputStream(const CharType* input, unsigned start, unsigned length)-
175 : input(input)-
176 , pos(start)-
177 , length(length)-
178 {-
179 }
executed 216 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
216
180-
181 void next()-
182 {-
183 ++pos;-
184 }
executed 16236 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
16236
185-
186 void rewind(unsigned amount)-
187 {-
188 ASSERT(pos >= amount);-
189 pos -= amount;-
190 }
never executed: end of block
0
191-
192 int read()-
193 {-
194 ASSERT(pos < length);-
195 if (pos < length)
pos < lengthDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-4
196 return input[pos];
executed 4 times by 1 test: return input[pos];
Executed by:
  • tst_ecmascripttests
4
197 return -1;
never executed: return -1;
0
198 }-
199-
200 int readPair()-
201 {-
202 ASSERT(pos + 1 < length);-
203 return input[pos] | input[pos + 1] << 16;
never executed: return input[pos] | input[pos + 1] << 16;
0
204 }-
205-
206 int readChecked(unsigned negativePositionOffest)-
207 {-
208 RELEASE_ASSERT(pos >= negativePositionOffest);-
209 unsigned p = pos - negativePositionOffest;-
210 ASSERT(p < length);-
211 return input[p];
executed 7386841 times by 1 test: return input[p];
Executed by:
  • tst_ecmascripttests
7386841
212 }-
213-
214 int reread(unsigned from)-
215 {-
216 ASSERT(from < length);-
217 return input[from];
executed 516 times by 1 test: return input[from];
Executed by:
  • tst_ecmascripttests
516
218 }-
219-
220 int prev()-
221 {-
222 ASSERT(!(pos > length));-
223 if (pos && length)
posDescription
TRUEnever evaluated
FALSEnever evaluated
lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
224 return input[pos - 1];
never executed: return input[pos - 1];
0
225 return -1;
never executed: return -1;
0
226 }-
227-
228 unsigned getPos()-
229 {-
230 return pos;
executed 21774 times by 1 test: return pos;
Executed by:
  • tst_ecmascripttests
21774
231 }-
232-
233 void setPos(unsigned p)-
234 {-
235 pos = p;-
236 }
executed 116 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
116
237-
238 bool atStart()-
239 {-
240 return pos == 0;
never executed: return pos == 0;
0
241 }-
242-
243 bool atEnd()-
244 {-
245 return pos == length;
executed 16292 times by 1 test: return pos == length;
Executed by:
  • tst_ecmascripttests
16292
246 }-
247-
248 unsigned end()-
249 {-
250 return length;
never executed: return length;
0
251 }-
252-
253 bool checkInput(unsigned count)-
254 {-
255 if (((pos + count) <= length) && ((pos + count) >= pos)) {
((pos + count) <= length)Description
TRUEevaluated 3706514 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 11504 times by 1 test
Evaluated by:
  • tst_ecmascripttests
((pos + count) >= pos)Description
TRUEevaluated 3706513 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-3706514
256 pos += count;-
257 return true;
executed 3706514 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
3706514
258 }-
259 return false;
executed 11504 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
11504
260 }-
261-
262 void uncheckInput(unsigned count)-
263 {-
264 RELEASE_ASSERT(pos >= count);-
265 pos -= count;-
266 }
executed 3703919 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
3703919
267-
268 bool atStart(unsigned negativePositionOffest)-
269 {-
270 return pos == negativePositionOffest;
executed 88 times by 1 test: return pos == negativePositionOffest;
Executed by:
  • tst_ecmascripttests
88
271 }-
272-
273 bool atEnd(unsigned negativePositionOffest)-
274 {-
275 RELEASE_ASSERT(pos >= negativePositionOffest);-
276 return (pos - negativePositionOffest) == length;
executed 60 times by 1 test: return (pos - negativePositionOffest) == length;
Executed by:
  • tst_ecmascripttests
60
277 }-
278-
279 bool isAvailableInput(unsigned offset)-
280 {-
281 return (((pos + offset) <= length) && ((pos + offset) >= pos));
executed 216 times by 1 test: return (((pos + offset) <= length) && ((pos + offset) >= pos));
Executed by:
  • tst_ecmascripttests
216
282 }-
283-
284 private:-
285 const CharType* input;-
286 unsigned pos;-
287 unsigned length;-
288 };-
289-
290 bool testCharacterClass(CharacterClass* characterClass, int ch)-
291 {-
292 if (ch & 0xFF80) {
ch & 0xFF80Description
TRUEnever evaluated
FALSEevaluated 3684556 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-3684556
293 for (unsigned i = 0; i < characterClass->m_matchesUnicode.size(); ++i)
i < characterC...Unicode.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
294 if (ch == characterClass->m_matchesUnicode[i])
ch == characte...chesUnicode[i]Description
TRUEnever evaluated
FALSEnever evaluated
0
295 return true;
never executed: return true;
0
296 for (unsigned i = 0; i < characterClass->m_rangesUnicode.size(); ++i)
i < characterC...Unicode.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
297 if ((ch >= characterClass->m_rangesUnicode[i].begin) && (ch <= characterClass->m_rangesUnicode[i].end))
(ch >= charact...code[i].begin)Description
TRUEnever evaluated
FALSEnever evaluated
(ch <= charact...nicode[i].end)Description
TRUEnever evaluated
FALSEnever evaluated
0
298 return true;
never executed: return true;
0
299 } else {
never executed: end of block
0
300 for (unsigned i = 0; i < characterClass->m_matches.size(); ++i)
i < characterC...matches.size()Description
TRUEevaluated 3695540 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 3681720 times by 1 test
Evaluated by:
  • tst_ecmascripttests
3681720-3695540
301 if (ch == characterClass->m_matches[i])
ch == characte...->m_matches[i]Description
TRUEevaluated 2836 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 3692704 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2836-3692704
302 return true;
executed 2836 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
2836
303 for (unsigned i = 0; i < characterClass->m_ranges.size(); ++i)
i < characterC..._ranges.size()Description
TRUEevaluated 2412 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 3680832 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2412-3680832
304 if ((ch >= characterClass->m_ranges[i].begin) && (ch <= characterClass->m_ranges[i].end))
(ch >= charact...nges[i].begin)Description
TRUEevaluated 2012 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 400 times by 1 test
Evaluated by:
  • tst_ecmascripttests
(ch <= charact...ranges[i].end)Description
TRUEevaluated 888 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1124 times by 1 test
Evaluated by:
  • tst_ecmascripttests
400-2012
305 return true;
executed 888 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
888
306 }
executed 3680832 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
3680832
307-
308 return false;
executed 3680832 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
3680832
309 }-
310-
311 bool checkCharacter(int testChar, unsigned negativeInputOffset)-
312 {-
313 return testChar == input.readChecked(negativeInputOffset);
executed 3702252 times by 1 test: return testChar == input.readChecked(negativeInputOffset);
Executed by:
  • tst_ecmascripttests
3702252
314 }-
315-
316 bool checkCasedCharacter(int loChar, int hiChar, unsigned negativeInputOffset)-
317 {-
318 int ch = input.readChecked(negativeInputOffset);-
319 return (loChar == ch) || (hiChar == ch);
executed 36 times by 1 test: return (loChar == ch) || (hiChar == ch);
Executed by:
  • tst_ecmascripttests
36
320 }-
321-
322 bool checkCharacterClass(CharacterClass* characterClass, bool invert, unsigned negativeInputOffset)-
323 {-
324 bool match = testCharacterClass(characterClass, input.readChecked(negativeInputOffset));-
325 return invert ? !match : match;
executed 3684432 times by 1 test: return invert ? !match : match;
Executed by:
  • tst_ecmascripttests
3684432
326 }-
327-
328 bool tryConsumeBackReference(int matchBegin, int matchEnd, unsigned negativeInputOffset)-
329 {-
330 unsigned matchSize = (unsigned)(matchEnd - matchBegin);-
331-
332 if (!input.checkInput(matchSize))
!input.checkInput(matchSize)Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 260 times by 1 test
Evaluated by:
  • tst_ecmascripttests
28-260
333 return false;
executed 28 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
28
334-
335 if (pattern->m_ignoreCase) {
pattern->m_ignoreCaseDescription
TRUEnever evaluated
FALSEevaluated 260 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-260
336 for (unsigned i = 0; i < matchSize; ++i) {
i < matchSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
337 int oldCh = input.reread(matchBegin + i);-
338 int ch = input.readChecked(negativeInputOffset + matchSize - i);-
339-
340 if (oldCh == ch)
oldCh == chDescription
TRUEnever evaluated
FALSEnever evaluated
0
341 continue;
never executed: continue;
0
342-
343 // The definition for canonicalize (see ES 5.1, 15.10.2.8) means that-
344 // unicode values are never allowed to match against ascii ones.-
345 if (isASCII(oldCh) || isASCII(ch)) {
isASCII(oldCh)Description
TRUEnever evaluated
FALSEnever evaluated
isASCII(ch)Description
TRUEnever evaluated
FALSEnever evaluated
0
346 if (toASCIIUpper(oldCh) == toASCIIUpper(ch))
toASCIIUpper(o...ASCIIUpper(ch)Description
TRUEnever evaluated
FALSEnever evaluated
0
347 continue;
never executed: continue;
0
348 } else if (areCanonicallyEquivalent(oldCh, ch))
never executed: end of block
areCanonically...ent(oldCh, ch)Description
TRUEnever evaluated
FALSEnever evaluated
0
349 continue;
never executed: continue;
0
350-
351 input.uncheckInput(matchSize);-
352 return false;
never executed: return false;
0
353 }-
354 } else {
never executed: end of block
0
355 for (unsigned i = 0; i < matchSize; ++i) {
i < matchSizeDescription
TRUEevaluated 516 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 172 times by 1 test
Evaluated by:
  • tst_ecmascripttests
172-516
356 if (!checkCharacter(input.reread(matchBegin + i), negativeInputOffset + matchSize - i)) {
!checkCharacte...matchSize - i)Description
TRUEevaluated 88 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 428 times by 1 test
Evaluated by:
  • tst_ecmascripttests
88-428
357 input.uncheckInput(matchSize);-
358 return false;
executed 88 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
88
359 }-
360 }
executed 428 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
428
361 }
executed 172 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
172
362-
363 return true;
executed 172 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
172
364 }-
365-
366 bool matchAssertionBOL(ByteTerm& term)-
367 {-
368 return (input.atStart(term.inputPosition)) || (pattern->m_multiline && testCharacterClass(pattern->newlineCharacterClass, input.readChecked(term.inputPosition + 1)));
executed 24 times by 1 test: return (input.atStart(term.inputPosition)) || (pattern->m_multiline && testCharacterClass(pattern->newlineCharacterClass, input.readChecked(term.inputPosition + 1)));
Executed by:
  • tst_ecmascripttests
24
369 }-
370-
371 bool matchAssertionEOL(ByteTerm& term)-
372 {-
373 if (term.inputPosition)
term.inputPositionDescription
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-28
374 return (input.atEnd(term.inputPosition)) || (pattern->m_multiline && testCharacterClass(pattern->newlineCharacterClass, input.readChecked(term.inputPosition)));
never executed: return (input.atEnd(term.inputPosition)) || (pattern->m_multiline && testCharacterClass(pattern->newlineCharacterClass, input.readChecked(term.inputPosition)));
0
375-
376 return (input.atEnd()) || (pattern->m_multiline && testCharacterClass(pattern->newlineCharacterClass, input.read()));
executed 28 times by 1 test: return (input.atEnd()) || (pattern->m_multiline && testCharacterClass(pattern->newlineCharacterClass, input.read()));
Executed by:
  • tst_ecmascripttests
28
377 }-
378-
379 bool matchAssertionWordBoundary(ByteTerm& term)-
380 {-
381 bool prevIsWordchar = !input.atStart(term.inputPosition) && testCharacterClass(pattern->wordcharCharacterClass, input.readChecked(term.inputPosition + 1));
!input.atStart...inputPosition)Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
testCharacterC...Position + 1))Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-60
382 bool readIsWordchar;-
383 if (term.inputPosition)
term.inputPositionDescription
TRUEevaluated 60 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-60
384 readIsWordchar = !input.atEnd(term.inputPosition) && testCharacterClass(pattern->wordcharCharacterClass, input.readChecked(term.inputPosition));
executed 60 times by 1 test: readIsWordchar = !input.atEnd(term.inputPosition) && testCharacterClass(pattern->wordcharCharacterClass, input.readChecked(term.inputPosition));
Executed by:
  • tst_ecmascripttests
!input.atEnd(t...inputPosition)Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
testCharacterC...nputPosition))Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-60
385 else-
386 readIsWordchar = !input.atEnd() && testCharacterClass(pattern->wordcharCharacterClass, input.read());
executed 4 times by 1 test: readIsWordchar = !input.atEnd() && testCharacterClass(pattern->wordcharCharacterClass, input.read());
Executed by:
  • tst_ecmascripttests
!input.atEnd()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
testCharacterC... input.read())Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-4
387-
388 bool wordBoundary = prevIsWordchar != readIsWordchar;-
389 return term.invert() ? !wordBoundary : wordBoundary;
executed 64 times by 1 test: return term.invert() ? !wordBoundary : wordBoundary;
Executed by:
  • tst_ecmascripttests
64
390 }-
391-
392 bool backtrackPatternCharacter(ByteTerm& term, DisjunctionContext* context)-
393 {-
394 BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + term.frameLocation);-
395-
396 switch (term.atom.quantityType) {-
397 case QuantifierFixedCount:
executed 2136 times by 1 test: case QuantifierFixedCount:
Executed by:
  • tst_ecmascripttests
2136
398 break;
executed 2136 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
2136
399-
400 case QuantifierGreedy:
executed 52 times by 1 test: case QuantifierGreedy:
Executed by:
  • tst_ecmascripttests
52
401 if (backTrack->matchAmount) {
backTrack->matchAmountDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_ecmascripttests
12-40
402 --backTrack->matchAmount;-
403 input.uncheckInput(1);-
404 return true;
executed 40 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
40
405 }-
406 break;
executed 12 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
12
407-
408 case QuantifierNonGreedy:
never executed: case QuantifierNonGreedy:
0
409 if ((backTrack->matchAmount < term.atom.quantityCount) && input.checkInput(1)) {
(backTrack->ma...quantityCount)Description
TRUEnever evaluated
FALSEnever evaluated
input.checkInput(1)Description
TRUEnever evaluated
FALSEnever evaluated
0
410 ++backTrack->matchAmount;-
411 if (checkCharacter(term.atom.patternCharacter, term.inputPosition + 1))
checkCharacter...tPosition + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
412 return true;
never executed: return true;
0
413 }
never executed: end of block
0
414 input.uncheckInput(backTrack->matchAmount);-
415 break;
never executed: break;
0
416 }-
417-
418 return false;
executed 2148 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
2148
419 }-
420-
421 bool backtrackPatternCasedCharacter(ByteTerm& term, DisjunctionContext* context)-
422 {-
423 BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + term.frameLocation);-
424-
425 switch (term.atom.quantityType) {-
426 case QuantifierFixedCount:
never executed: case QuantifierFixedCount:
0
427 break;
never executed: break;
0
428-
429 case QuantifierGreedy:
never executed: case QuantifierGreedy:
0
430 if (backTrack->matchAmount) {
backTrack->matchAmountDescription
TRUEnever evaluated
FALSEnever evaluated
0
431 --backTrack->matchAmount;-
432 input.uncheckInput(1);-
433 return true;
never executed: return true;
0
434 }-
435 break;
never executed: break;
0
436-
437 case QuantifierNonGreedy:
never executed: case QuantifierNonGreedy:
0
438 if ((backTrack->matchAmount < term.atom.quantityCount) && input.checkInput(1)) {
(backTrack->ma...quantityCount)Description
TRUEnever evaluated
FALSEnever evaluated
input.checkInput(1)Description
TRUEnever evaluated
FALSEnever evaluated
0
439 ++backTrack->matchAmount;-
440 if (checkCasedCharacter(term.atom.casedCharacter.lo, term.atom.casedCharacter.hi, term.inputPosition + 1))
checkCasedChar...tPosition + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
441 return true;
never executed: return true;
0
442 }
never executed: end of block
0
443 input.uncheckInput(backTrack->matchAmount);-
444 break;
never executed: break;
0
445 }-
446-
447 return false;
never executed: return false;
0
448 }-
449-
450 bool matchCharacterClass(ByteTerm& term, DisjunctionContext* context)-
451 {-
452 ASSERT(term.type == ByteTerm::TypeCharacterClass);-
453 BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + term.frameLocation);-
454-
455 switch (term.atom.quantityType) {-
456 case QuantifierFixedCount: {
executed 5776 times by 1 test: case QuantifierFixedCount:
Executed by:
  • tst_ecmascripttests
5776
457 for (unsigned matchAmount = 0; matchAmount < term.atom.quantityCount; ++matchAmount) {
matchAmount < ....quantityCountDescription
TRUEevaluated 5840 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 3200 times by 1 test
Evaluated by:
  • tst_ecmascripttests
3200-5840
458 if (!checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition - matchAmount))
!checkCharacte...- matchAmount)Description
TRUEevaluated 2576 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 3264 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2576-3264
459 return false;
executed 2576 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
2576
460 }
executed 3264 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
3264
461 return true;
executed 3200 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
3200
462 }-
463-
464 case QuantifierGreedy: {
executed 13440 times by 1 test: case QuantifierGreedy:
Executed by:
  • tst_ecmascripttests
13440
465 unsigned matchAmount = 0;-
466 while ((matchAmount < term.atom.quantityCount) && input.checkInput(1)) {
(matchAmount <...quantityCount)Description
TRUEevaluated 3689800 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
input.checkInput(1)Description
TRUEevaluated 3678584 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 11216 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-3689800
467 if (!checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition + 1)) {
!checkCharacte...tPosition + 1)Description
TRUEevaluated 2224 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 3676360 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2224-3676360
468 input.uncheckInput(1);-
469 break;
executed 2224 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
2224
470 }-
471 ++matchAmount;-
472 }
executed 3676360 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
3676360
473 backTrack->matchAmount = matchAmount;-
474-
475 return true;
executed 13440 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
13440
476 }-
477-
478 case QuantifierNonGreedy:
executed 4 times by 1 test: case QuantifierNonGreedy:
Executed by:
  • tst_ecmascripttests
4
479 backTrack->matchAmount = 0;-
480 return true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
4
481 }-
482-
483 RELEASE_ASSERT_NOT_REACHED();-
484 return false;
never executed: return false;
0
485 }-
486-
487 bool backtrackCharacterClass(ByteTerm& term, DisjunctionContext* context)-
488 {-
489 ASSERT(term.type == ByteTerm::TypeCharacterClass);-
490 BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + term.frameLocation);-
491-
492 switch (term.atom.quantityType) {-
493 case QuantifierFixedCount:
executed 2676 times by 1 test: case QuantifierFixedCount:
Executed by:
  • tst_ecmascripttests
2676
494 break;
executed 2676 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
2676
495-
496 case QuantifierGreedy:
executed 3688032 times by 1 test: case QuantifierGreedy:
Executed by:
  • tst_ecmascripttests
3688032
497 if (backTrack->matchAmount) {
backTrack->matchAmountDescription
TRUEevaluated 3674756 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 13276 times by 1 test
Evaluated by:
  • tst_ecmascripttests
13276-3674756
498 --backTrack->matchAmount;-
499 input.uncheckInput(1);-
500 return true;
executed 3674756 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
3674756
501 }-
502 break;
executed 13276 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
13276
503-
504 case QuantifierNonGreedy:
executed 8 times by 1 test: case QuantifierNonGreedy:
Executed by:
  • tst_ecmascripttests
8
505 if ((backTrack->matchAmount < term.atom.quantityCount) && input.checkInput(1)) {
(backTrack->ma...quantityCount)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
input.checkInput(1)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-8
506 ++backTrack->matchAmount;-
507 if (checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition + 1))
checkCharacter...tPosition + 1)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-8
508 return true;
executed 8 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
8
509 }
never executed: end of block
0
510 input.uncheckInput(backTrack->matchAmount);-
511 break;
never executed: break;
0
512 }-
513-
514 return false;
executed 15952 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
15952
515 }-
516-
517 bool matchBackReference(ByteTerm& term, DisjunctionContext* context)-
518 {-
519 ASSERT(term.type == ByteTerm::TypeBackReference);-
520 BackTrackInfoBackReference* backTrack = reinterpret_cast<BackTrackInfoBackReference*>(context->frame + term.frameLocation);-
521-
522 unsigned matchBegin = output[(term.atom.subpatternId << 1)];-
523 unsigned matchEnd = output[(term.atom.subpatternId << 1) + 1];-
524-
525 // If the end position of the referenced match hasn't set yet then the backreference in the same parentheses where it references to that.-
526 // In this case the result of match is empty string like when it references to a parentheses with zero-width match.-
527 // Eg.: /(a\1)/-
528 if (matchEnd == offsetNoMatch)
matchEnd == offsetNoMatchDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 304 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-304
529 return true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
4
530-
531 if (matchBegin == offsetNoMatch)
matchBegin == offsetNoMatchDescription
TRUEnever evaluated
FALSEevaluated 304 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-304
532 return true;
never executed: return true;
0
533-
534 ASSERT(matchBegin <= matchEnd);-
535-
536 if (matchBegin == matchEnd)
matchBegin == matchEndDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 276 times by 1 test
Evaluated by:
  • tst_ecmascripttests
28-276
537 return true;
executed 28 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
28
538-
539 switch (term.atom.quantityType) {-
540 case QuantifierFixedCount: {
executed 244 times by 1 test: case QuantifierFixedCount:
Executed by:
  • tst_ecmascripttests
244
541 backTrack->begin = input.getPos();-
542 for (unsigned matchAmount = 0; matchAmount < term.atom.quantityCount; ++matchAmount) {
matchAmount < ....quantityCountDescription
TRUEevaluated 244 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 160 times by 1 test
Evaluated by:
  • tst_ecmascripttests
160-244
543 if (!tryConsumeBackReference(matchBegin, matchEnd, term.inputPosition)) {
!tryConsumeBac...inputPosition)Description
TRUEevaluated 84 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 160 times by 1 test
Evaluated by:
  • tst_ecmascripttests
84-160
544 input.setPos(backTrack->begin);-
545 return false;
executed 84 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
84
546 }-
547 }
executed 160 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
160
548 return true;
executed 160 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
160
549 }-
550-
551 case QuantifierGreedy: {
executed 32 times by 1 test: case QuantifierGreedy:
Executed by:
  • tst_ecmascripttests
32
552 unsigned matchAmount = 0;-
553 while ((matchAmount < term.atom.quantityCount) && tryConsumeBackReference(matchBegin, matchEnd, term.inputPosition))
(matchAmount <...quantityCount)Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
tryConsumeBack...inputPosition)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-44
554 ++matchAmount;
executed 12 times by 1 test: ++matchAmount;
Executed by:
  • tst_ecmascripttests
12
555 backTrack->matchAmount = matchAmount;-
556 return true;
executed 32 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
32
557 }-
558-
559 case QuantifierNonGreedy:
never executed: case QuantifierNonGreedy:
0
560 backTrack->begin = input.getPos();-
561 backTrack->matchAmount = 0;-
562 return true;
never executed: return true;
0
563 }-
564-
565 RELEASE_ASSERT_NOT_REACHED();-
566 return false;
never executed: return false;
0
567 }-
568-
569 bool backtrackBackReference(ByteTerm& term, DisjunctionContext* context)-
570 {-
571 ASSERT(term.type == ByteTerm::TypeBackReference);-
572 BackTrackInfoBackReference* backTrack = reinterpret_cast<BackTrackInfoBackReference*>(context->frame + term.frameLocation);-
573-
574 unsigned matchBegin = output[(term.atom.subpatternId << 1)];-
575 unsigned matchEnd = output[(term.atom.subpatternId << 1) + 1];-
576-
577 if (matchBegin == offsetNoMatch)
matchBegin == offsetNoMatchDescription
TRUEnever evaluated
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-32
578 return false;
never executed: return false;
0
579-
580 ASSERT(matchBegin <= matchEnd);-
581-
582 if (matchBegin == matchEnd)
matchBegin == matchEndDescription
TRUEnever evaluated
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-32
583 return false;
never executed: return false;
0
584-
585 switch (term.atom.quantityType) {-
586 case QuantifierFixedCount:
executed 8 times by 1 test: case QuantifierFixedCount:
Executed by:
  • tst_ecmascripttests
8
587 // for quantityCount == 1, could rewind.-
588 input.setPos(backTrack->begin);-
589 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
8
590-
591 case QuantifierGreedy:
executed 24 times by 1 test: case QuantifierGreedy:
Executed by:
  • tst_ecmascripttests
24
592 if (backTrack->matchAmount) {
backTrack->matchAmountDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-24
593 --backTrack->matchAmount;-
594 input.rewind(matchEnd - matchBegin);-
595 return true;
never executed: return true;
0
596 }-
597 break;
executed 24 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
24
598-
599 case QuantifierNonGreedy:
never executed: case QuantifierNonGreedy:
0
600 if ((backTrack->matchAmount < term.atom.quantityCount) && tryConsumeBackReference(matchBegin, matchEnd, term.inputPosition)) {
(backTrack->ma...quantityCount)Description
TRUEnever evaluated
FALSEnever evaluated
tryConsumeBack...inputPosition)Description
TRUEnever evaluated
FALSEnever evaluated
0
601 ++backTrack->matchAmount;-
602 return true;
never executed: return true;
0
603 }-
604 input.setPos(backTrack->begin);-
605 break;
never executed: break;
0
606 }-
607-
608 return false;
executed 32 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
32
609 }-
610-
611 void recordParenthesesMatch(ByteTerm& term, ParenthesesDisjunctionContext* context)-
612 {-
613 if (term.capture()) {
term.capture()Description
TRUEevaluated 204 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-204
614 unsigned subpatternId = term.atom.subpatternId;-
615 output[(subpatternId << 1)] = context->getDisjunctionContext(term)->matchBegin + term.inputPosition;-
616 output[(subpatternId << 1) + 1] = context->getDisjunctionContext(term)->matchEnd + term.inputPosition;-
617 }
executed 204 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
204
618 }
executed 204 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
204
619 void resetMatches(ByteTerm& term, ParenthesesDisjunctionContext* context)-
620 {-
621 unsigned firstSubpatternId = term.atom.subpatternId;-
622 unsigned count = term.atom.parenthesesDisjunction->m_numSubpatterns;-
623 context->restoreOutput(output, firstSubpatternId, count);-
624 }
executed 2276 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
2276
625 JSRegExpResult parenthesesDoBacktrack(ByteTerm& term, BackTrackInfoParentheses* backTrack)-
626 {-
627 while (backTrack->matchAmount) {
backTrack->matchAmountDescription
TRUEnever evaluated
FALSEnever evaluated
0
628 ParenthesesDisjunctionContext* context = backTrack->lastContext;-
629-
630 JSRegExpResult result = matchDisjunction(term.atom.parenthesesDisjunction, context->getDisjunctionContext(term), true);-
631 if (result == JSRegExpMatch)
result == JSRegExpMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
632 return JSRegExpMatch;
never executed: return JSRegExpMatch;
0
633-
634 resetMatches(term, context);-
635 popParenthesesDisjunctionContext(backTrack);-
636 freeParenthesesDisjunctionContext(context);-
637-
638 if (result != JSRegExpNoMatch)
result != JSRegExpNoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
639 return result;
never executed: return result;
0
640 }
never executed: end of block
0
641-
642 return JSRegExpNoMatch;
never executed: return JSRegExpNoMatch;
0
643 }-
644-
645 bool matchParenthesesOnceBegin(ByteTerm& term, DisjunctionContext* context)-
646 {-
647 ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternOnceBegin);-
648 ASSERT(term.atom.quantityCount == 1);-
649-
650 BackTrackInfoParenthesesOnce* backTrack = reinterpret_cast<BackTrackInfoParenthesesOnce*>(context->frame + term.frameLocation);-
651-
652 switch (term.atom.quantityType) {-
653 case QuantifierGreedy: {
executed 212 times by 1 test: case QuantifierGreedy:
Executed by:
  • tst_ecmascripttests
212
654 // set this speculatively; if we get to the parens end this will be true.-
655 backTrack->begin = input.getPos();-
656 break;
executed 212 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
212
657 }-
658 case QuantifierNonGreedy: {
never executed: case QuantifierNonGreedy:
0
659 backTrack->begin = notFound;-
660 context->term += term.atom.parenthesesWidth;-
661 return true;
never executed: return true;
0
662 }-
663 case QuantifierFixedCount:
executed 527 times by 1 test: case QuantifierFixedCount:
Executed by:
  • tst_ecmascripttests
527
664 break;
executed 527 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
527
665 }-
666-
667 if (term.capture()) {
term.capture()Description
TRUEevaluated 739 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-739
668 unsigned subpatternId = term.atom.subpatternId;-
669 output[(subpatternId << 1)] = input.getPos() - term.inputPosition;-
670 }
executed 739 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
739
671-
672 return true;
executed 739 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
739
673 }-
674-
675 bool matchParenthesesOnceEnd(ByteTerm& term, DisjunctionContext* context)-
676 {-
677 ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternOnceEnd);-
678 ASSERT(term.atom.quantityCount == 1);-
679-
680 if (term.capture()) {
term.capture()Description
TRUEevaluated 572 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-572
681 unsigned subpatternId = term.atom.subpatternId;-
682 output[(subpatternId << 1) + 1] = input.getPos() + term.inputPosition;-
683 }
executed 572 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
572
684-
685 if (term.atom.quantityType == QuantifierFixedCount)
term.atom.quan...fierFixedCountDescription
TRUEevaluated 507 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 64 times by 1 test
Evaluated by:
  • tst_ecmascripttests
64-507
686 return true;
executed 508 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
508
687-
688 BackTrackInfoParenthesesOnce* backTrack = reinterpret_cast<BackTrackInfoParenthesesOnce*>(context->frame + term.frameLocation);-
689 return backTrack->begin != input.getPos();
executed 64 times by 1 test: return backTrack->begin != input.getPos();
Executed by:
  • tst_ecmascripttests
64
690 }-
691-
692 bool backtrackParenthesesOnceBegin(ByteTerm& term, DisjunctionContext* context)-
693 {-
694 ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternOnceBegin);-
695 ASSERT(term.atom.quantityCount == 1);-
696-
697 BackTrackInfoParenthesesOnce* backTrack = reinterpret_cast<BackTrackInfoParenthesesOnce*>(context->frame + term.frameLocation);-
698-
699 if (term.capture()) {
term.capture()Description
TRUEevaluated 292 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-292
700 unsigned subpatternId = term.atom.subpatternId;-
701 output[(subpatternId << 1)] = offsetNoMatch;-
702 output[(subpatternId << 1) + 1] = offsetNoMatch;-
703 }
executed 292 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
292
704-
705 switch (term.atom.quantityType) {-
706 case QuantifierGreedy:
executed 148 times by 1 test: case QuantifierGreedy:
Executed by:
  • tst_ecmascripttests
148
707 // if we backtrack to this point, there is another chance - try matching nothing.-
708 ASSERT(backTrack->begin != notFound);-
709 backTrack->begin = notFound;-
710 context->term += term.atom.parenthesesWidth;-
711 return true;
executed 148 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
148
712 case QuantifierNonGreedy:
never executed: case QuantifierNonGreedy:
0
713 ASSERT(backTrack->begin != notFound);-
714 case QuantifierFixedCount:
code before this statement never executed: case QuantifierFixedCount:
executed 144 times by 1 test: case QuantifierFixedCount:
Executed by:
  • tst_ecmascripttests
0-144
715 break;
executed 144 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
144
716 }-
717-
718 return false;
executed 144 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
144
719 }-
720-
721 bool backtrackParenthesesOnceEnd(ByteTerm& term, DisjunctionContext* context)-
722 {-
723 ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternOnceEnd);-
724 ASSERT(term.atom.quantityCount == 1);-
725-
726 BackTrackInfoParenthesesOnce* backTrack = reinterpret_cast<BackTrackInfoParenthesesOnce*>(context->frame + term.frameLocation);-
727-
728 switch (term.atom.quantityType) {-
729 case QuantifierGreedy:
executed 24 times by 1 test: case QuantifierGreedy:
Executed by:
  • tst_ecmascripttests
24
730 if (backTrack->begin == notFound) {
backTrack->begin == notFoundDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-24
731 context->term -= term.atom.parenthesesWidth;-
732 return false;
executed 24 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
24
733 }-
734 Q_FALLTHROUGH();-
735 case QuantifierNonGreedy:
code before this statement never executed: case QuantifierNonGreedy:
never executed: case QuantifierNonGreedy:
0
736 if (backTrack->begin == notFound) {
backTrack->begin == notFoundDescription
TRUEnever evaluated
FALSEnever evaluated
0
737 backTrack->begin = input.getPos();-
738 if (term.capture()) {
term.capture()Description
TRUEnever evaluated
FALSEnever evaluated
0
739 // Technically this access to inputPosition should be accessing the begin term's-
740 // inputPosition, but for repeats other than fixed these values should be-
741 // the same anyway! (We don't pre-check for greedy or non-greedy matches.)-
742 ASSERT((&term - term.atom.parenthesesWidth)->type == ByteTerm::TypeParenthesesSubpatternOnceBegin);-
743 ASSERT((&term - term.atom.parenthesesWidth)->inputPosition == term.inputPosition);-
744 unsigned subpatternId = term.atom.subpatternId;-
745 output[subpatternId << 1] = input.getPos() + term.inputPosition;-
746 }
never executed: end of block
0
747 context->term -= term.atom.parenthesesWidth;-
748 return true;
never executed: return true;
0
749 }-
750 case QuantifierFixedCount:
code before this statement never executed: case QuantifierFixedCount:
executed 124 times by 1 test: case QuantifierFixedCount:
Executed by:
  • tst_ecmascripttests
0-124
751 break;
executed 124 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
124
752 }-
753-
754 return false;
executed 124 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
124
755 }-
756-
757 bool matchParenthesesTerminalBegin(ByteTerm& term, DisjunctionContext* context)-
758 {-
759 ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternTerminalBegin);-
760 ASSERT(term.atom.quantityType == QuantifierGreedy);-
761 ASSERT(term.atom.quantityCount == quantifyInfinite);-
762 ASSERT(!term.capture());-
763-
764 BackTrackInfoParenthesesTerminal* backTrack = reinterpret_cast<BackTrackInfoParenthesesTerminal*>(context->frame + term.frameLocation);-
765 backTrack->begin = input.getPos();-
766 return true;
never executed: return true;
0
767 }-
768-
769 bool matchParenthesesTerminalEnd(ByteTerm& term, DisjunctionContext* context)-
770 {-
771 ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternTerminalEnd);-
772-
773 BackTrackInfoParenthesesTerminal* backTrack = reinterpret_cast<BackTrackInfoParenthesesTerminal*>(context->frame + term.frameLocation);-
774 // Empty match is a failed match.-
775 if (backTrack->begin == input.getPos())
backTrack->beg...input.getPos()Description
TRUEnever evaluated
FALSEnever evaluated
0
776 return false;
never executed: return false;
0
777-
778 // Successful match! Okay, what's next? - loop around and try to match moar!-
779 context->term -= (term.atom.parenthesesWidth + 1);-
780 return true;
never executed: return true;
0
781 }-
782-
783 bool backtrackParenthesesTerminalBegin(ByteTerm& term, DisjunctionContext* context)-
784 {-
785 ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternTerminalBegin);-
786 ASSERT(term.atom.quantityType == QuantifierGreedy);-
787 ASSERT(term.atom.quantityCount == quantifyInfinite);-
788 ASSERT(!term.capture());-
789-
790 // If we backtrack to this point, we have failed to match this iteration of the parens.-
791 // Since this is greedy / zero minimum a failed is also accepted as a match!-
792 context->term += term.atom.parenthesesWidth;-
793 return true;
never executed: return true;
0
794 }-
795-
796 bool backtrackParenthesesTerminalEnd(ByteTerm&, DisjunctionContext*)-
797 {-
798 // 'Terminal' parentheses are at the end of the regex, and as such a match past end-
799 // should always be returned as a successful match - we should never backtrack to here.-
800 RELEASE_ASSERT_NOT_REACHED();-
801 return false;
never executed: return false;
0
802 }-
803-
804 bool matchParentheticalAssertionBegin(ByteTerm& term, DisjunctionContext* context)-
805 {-
806 ASSERT(term.type == ByteTerm::TypeParentheticalAssertionBegin);-
807 ASSERT(term.atom.quantityCount == 1);-
808-
809 BackTrackInfoParentheticalAssertion* backTrack = reinterpret_cast<BackTrackInfoParentheticalAssertion*>(context->frame + term.frameLocation);-
810-
811 backTrack->begin = input.getPos();-
812 return true;
executed 24 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
24
813 }-
814-
815 bool matchParentheticalAssertionEnd(ByteTerm& term, DisjunctionContext* context)-
816 {-
817 ASSERT(term.type == ByteTerm::TypeParentheticalAssertionEnd);-
818 ASSERT(term.atom.quantityCount == 1);-
819-
820 BackTrackInfoParentheticalAssertion* backTrack = reinterpret_cast<BackTrackInfoParentheticalAssertion*>(context->frame + term.frameLocation);-
821-
822 input.setPos(backTrack->begin);-
823-
824 // We've reached the end of the parens; if they are inverted, this is failure.-
825 if (term.invert()) {
term.invert()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-12
826 context->term -= term.atom.parenthesesWidth;-
827 return false;
executed 4 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
4
828 }-
829-
830 return true;
executed 12 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
12
831 }-
832-
833 bool backtrackParentheticalAssertionBegin(ByteTerm& term, DisjunctionContext* context)-
834 {-
835 ASSERT(term.type == ByteTerm::TypeParentheticalAssertionBegin);-
836 ASSERT(term.atom.quantityCount == 1);-
837-
838 // We've failed to match parens; if they are inverted, this is win!-
839 if (term.invert()) {
term.invert()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4
840 context->term += term.atom.parenthesesWidth;-
841 return true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
4
842 }-
843-
844 return false;
executed 4 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
4
845 }-
846-
847 bool backtrackParentheticalAssertionEnd(ByteTerm& term, DisjunctionContext* context)-
848 {-
849 ASSERT(term.type == ByteTerm::TypeParentheticalAssertionEnd);-
850 ASSERT(term.atom.quantityCount == 1);-
851-
852 BackTrackInfoParentheticalAssertion* backTrack = reinterpret_cast<BackTrackInfoParentheticalAssertion*>(context->frame + term.frameLocation);-
853-
854 input.setPos(backTrack->begin);-
855-
856 context->term -= term.atom.parenthesesWidth;-
857 return false;
executed 8 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
8
858 }-
859-
860 JSRegExpResult matchParentheses(ByteTerm& term, DisjunctionContext* context)-
861 {-
862 ASSERT(term.type == ByteTerm::TypeParenthesesSubpattern);-
863-
864 BackTrackInfoParentheses* backTrack = reinterpret_cast<BackTrackInfoParentheses*>(context->frame + term.frameLocation);-
865 ByteDisjunction* disjunctionBody = term.atom.parenthesesDisjunction;-
866-
867 backTrack->matchAmount = 0;-
868 backTrack->lastContext = 0;-
869-
870 switch (term.atom.quantityType) {-
871 case QuantifierFixedCount: {
never executed: case QuantifierFixedCount:
0
872 // While we haven't yet reached our fixed limit,-
873 while (backTrack->matchAmount < term.atom.quantityCount) {
backTrack->mat....quantityCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
874 // Try to do a match, and it it succeeds, add it to the list.-
875 ParenthesesDisjunctionContext* context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);-
876 JSRegExpResult result = matchDisjunction(disjunctionBody, context->getDisjunctionContext(term));-
877 if (result == JSRegExpMatch)
result == JSRegExpMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
878 appendParenthesesDisjunctionContext(backTrack, context);
never executed: appendParenthesesDisjunctionContext(backTrack, context);
0
879 else {-
880 // The match failed; try to find an alternate point to carry on from.-
881 resetMatches(term, context);-
882 freeParenthesesDisjunctionContext(context);-
883-
884 if (result != JSRegExpNoMatch)
result != JSRegExpNoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
885 return result;
never executed: return result;
0
886 JSRegExpResult backtrackResult = parenthesesDoBacktrack(term, backTrack);-
887 if (backtrackResult != JSRegExpMatch)
backtrackResul... JSRegExpMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
888 return backtrackResult;
never executed: return backtrackResult;
0
889 }
never executed: end of block
0
890 }-
891-
892 ASSERT(backTrack->matchAmount == term.atom.quantityCount);-
893 ParenthesesDisjunctionContext* context = backTrack->lastContext;-
894 recordParenthesesMatch(term, context);-
895 return JSRegExpMatch;
never executed: return JSRegExpMatch;
0
896 }-
897-
898 case QuantifierGreedy: {
executed 2232 times by 1 test: case QuantifierGreedy:
Executed by:
  • tst_ecmascripttests
2232
899 while (backTrack->matchAmount < term.atom.quantityCount) {
backTrack->mat....quantityCountDescription
TRUEevaluated 2708 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-2708
900 ParenthesesDisjunctionContext* context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);-
901 JSRegExpResult result = matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term));-
902 if (result == JSRegExpMatch)
result == JSRegExpMatchDescription
TRUEevaluated 476 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2232 times by 1 test
Evaluated by:
  • tst_ecmascripttests
476-2232
903 appendParenthesesDisjunctionContext(backTrack, context);
executed 476 times by 1 test: appendParenthesesDisjunctionContext(backTrack, context);
Executed by:
  • tst_ecmascripttests
476
904 else {-
905 resetMatches(term, context);-
906 freeParenthesesDisjunctionContext(context);-
907-
908 if (result != JSRegExpNoMatch)
result != JSRegExpNoMatchDescription
TRUEnever evaluated
FALSEevaluated 2232 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-2232
909 return result;
never executed: return result;
0
910-
911 break;
executed 2232 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
2232
912 }-
913 }-
914-
915 if (backTrack->matchAmount) {
backTrack->matchAmountDescription
TRUEevaluated 152 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2080 times by 1 test
Evaluated by:
  • tst_ecmascripttests
152-2080
916 ParenthesesDisjunctionContext* context = backTrack->lastContext;-
917 recordParenthesesMatch(term, context);-
918 }
executed 152 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
152
919 return JSRegExpMatch;
executed 2232 times by 1 test: return JSRegExpMatch;
Executed by:
  • tst_ecmascripttests
2232
920 }-
921-
922 case QuantifierNonGreedy:
executed 4 times by 1 test: case QuantifierNonGreedy:
Executed by:
  • tst_ecmascripttests
4
923 return JSRegExpMatch;
executed 4 times by 1 test: return JSRegExpMatch;
Executed by:
  • tst_ecmascripttests
4
924 }-
925-
926 RELEASE_ASSERT_NOT_REACHED();-
927 return JSRegExpErrorNoMatch;
never executed: return JSRegExpErrorNoMatch;
0
928 }-
929-
930 // Rules for backtracking differ depending on whether this is greedy or non-greedy.-
931 //-
932 // Greedy matches never should try just adding more - you should already have done-
933 // the 'more' cases. Always backtrack, at least a leetle bit. However cases where-
934 // you backtrack an item off the list needs checking, since we'll never have matched-
935 // the one less case. Tracking forwards, still add as much as possible.-
936 //-
937 // Non-greedy, we've already done the one less case, so don't match on popping.-
938 // We haven't done the one more case, so always try to add that.-
939 //-
940 JSRegExpResult backtrackParentheses(ByteTerm& term, DisjunctionContext* context)-
941 {-
942 ASSERT(term.type == ByteTerm::TypeParenthesesSubpattern);-
943-
944 BackTrackInfoParentheses* backTrack = reinterpret_cast<BackTrackInfoParentheses*>(context->frame + term.frameLocation);-
945 ByteDisjunction* disjunctionBody = term.atom.parenthesesDisjunction;-
946-
947 switch (term.atom.quantityType) {-
948 case QuantifierFixedCount: {
never executed: case QuantifierFixedCount:
0
949 ASSERT(backTrack->matchAmount == term.atom.quantityCount);-
950-
951 ParenthesesDisjunctionContext* context = 0;-
952 JSRegExpResult result = parenthesesDoBacktrack(term, backTrack);-
953-
954 if (result != JSRegExpMatch)
result != JSRegExpMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
955 return result;
never executed: return result;
0
956-
957 // While we haven't yet reached our fixed limit,-
958 while (backTrack->matchAmount < term.atom.quantityCount) {
backTrack->mat....quantityCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
959 // Try to do a match, and it it succeeds, add it to the list.-
960 context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);-
961 result = matchDisjunction(disjunctionBody, context->getDisjunctionContext(term));-
962-
963 if (result == JSRegExpMatch)
result == JSRegExpMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
964 appendParenthesesDisjunctionContext(backTrack, context);
never executed: appendParenthesesDisjunctionContext(backTrack, context);
0
965 else {-
966 // The match failed; try to find an alternate point to carry on from.-
967 resetMatches(term, context);-
968 freeParenthesesDisjunctionContext(context);-
969-
970 if (result != JSRegExpNoMatch)
result != JSRegExpNoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
971 return result;
never executed: return result;
0
972 JSRegExpResult backtrackResult = parenthesesDoBacktrack(term, backTrack);-
973 if (backtrackResult != JSRegExpMatch)
backtrackResul... JSRegExpMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
974 return backtrackResult;
never executed: return backtrackResult;
0
975 }
never executed: end of block
0
976 }-
977-
978 ASSERT(backTrack->matchAmount == term.atom.quantityCount);-
979 context = backTrack->lastContext;-
980 recordParenthesesMatch(term, context);-
981 return JSRegExpMatch;
never executed: return JSRegExpMatch;
0
982 }-
983-
984 case QuantifierGreedy: {
executed 2112 times by 1 test: case QuantifierGreedy:
Executed by:
  • tst_ecmascripttests
2112
985 if (!backTrack->matchAmount)
!backTrack->matchAmountDescription
TRUEevaluated 2068 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 44 times by 1 test
Evaluated by:
  • tst_ecmascripttests
44-2068
986 return JSRegExpNoMatch;
executed 2068 times by 1 test: return JSRegExpNoMatch;
Executed by:
  • tst_ecmascripttests
2068
987-
988 ParenthesesDisjunctionContext* context = backTrack->lastContext;-
989 JSRegExpResult result = matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term), true);-
990 if (result == JSRegExpMatch) {
result == JSRegExpMatchDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
20-24
991 while (backTrack->matchAmount < term.atom.quantityCount) {
backTrack->mat....quantityCountDescription
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-36
992 ParenthesesDisjunctionContext* context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);-
993 JSRegExpResult parenthesesResult = matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term));-
994 if (parenthesesResult == JSRegExpMatch)
parenthesesRes... JSRegExpMatchDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_ecmascripttests
16-20
995 appendParenthesesDisjunctionContext(backTrack, context);
executed 16 times by 1 test: appendParenthesesDisjunctionContext(backTrack, context);
Executed by:
  • tst_ecmascripttests
16
996 else {-
997 resetMatches(term, context);-
998 freeParenthesesDisjunctionContext(context);-
999-
1000 if (parenthesesResult != JSRegExpNoMatch)
parenthesesRes...SRegExpNoMatchDescription
TRUEnever evaluated
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-20
1001 return parenthesesResult;
never executed: return parenthesesResult;
0
1002-
1003 break;
executed 20 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
20
1004 }-
1005 }-
1006 } else {
executed 20 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
20
1007 resetMatches(term, context);-
1008 popParenthesesDisjunctionContext(backTrack);-
1009 freeParenthesesDisjunctionContext(context);-
1010-
1011 if (result != JSRegExpNoMatch)
result != JSRegExpNoMatchDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-24
1012 return result;
never executed: return result;
0
1013 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
24
1014-
1015 if (backTrack->matchAmount) {
backTrack->matchAmountDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-40
1016 ParenthesesDisjunctionContext* context = backTrack->lastContext;-
1017 recordParenthesesMatch(term, context);-
1018 }
executed 40 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
40
1019 return JSRegExpMatch;
executed 44 times by 1 test: return JSRegExpMatch;
Executed by:
  • tst_ecmascripttests
44
1020 }-
1021-
1022 case QuantifierNonGreedy: {
executed 12 times by 1 test: case QuantifierNonGreedy:
Executed by:
  • tst_ecmascripttests
12
1023 // If we've not reached the limit, try to add one more match.-
1024 if (backTrack->matchAmount < term.atom.quantityCount) {
backTrack->mat....quantityCountDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-12
1025 ParenthesesDisjunctionContext* context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);-
1026 JSRegExpResult result = matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term));-
1027 if (result == JSRegExpMatch) {
result == JSRegExpMatchDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-12
1028 appendParenthesesDisjunctionContext(backTrack, context);-
1029 recordParenthesesMatch(term, context);-
1030 return JSRegExpMatch;
executed 12 times by 1 test: return JSRegExpMatch;
Executed by:
  • tst_ecmascripttests
12
1031 }-
1032-
1033 resetMatches(term, context);-
1034 freeParenthesesDisjunctionContext(context);-
1035-
1036 if (result != JSRegExpNoMatch)
result != JSRegExpNoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
1037 return result;
never executed: return result;
0
1038 }
never executed: end of block
0
1039-
1040 // Nope - okay backtrack looking for an alternative.-
1041 while (backTrack->matchAmount) {
backTrack->matchAmountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1042 ParenthesesDisjunctionContext* context = backTrack->lastContext;-
1043 JSRegExpResult result = matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term), true);-
1044 if (result == JSRegExpMatch) {
result == JSRegExpMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
1045 // successful backtrack! we're back in the game!-
1046 if (backTrack->matchAmount) {
backTrack->matchAmountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1047 context = backTrack->lastContext;-
1048 recordParenthesesMatch(term, context);-
1049 }
never executed: end of block
0
1050 return JSRegExpMatch;
never executed: return JSRegExpMatch;
0
1051 }-
1052-
1053 // pop a match off the stack-
1054 resetMatches(term, context);-
1055 popParenthesesDisjunctionContext(backTrack);-
1056 freeParenthesesDisjunctionContext(context);-
1057-
1058 if (result != JSRegExpNoMatch)
result != JSRegExpNoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
1059 return result;
never executed: return result;
0
1060 }
never executed: end of block
0
1061-
1062 return JSRegExpNoMatch;
never executed: return JSRegExpNoMatch;
0
1063 }-
1064 }-
1065-
1066 RELEASE_ASSERT_NOT_REACHED();-
1067 return JSRegExpErrorNoMatch;
never executed: return JSRegExpErrorNoMatch;
0
1068 }-
1069-
1070 bool matchDotStarEnclosure(ByteTerm& term, DisjunctionContext* context)-
1071 {-
1072 UNUSED_PARAM(term);-
1073 unsigned matchBegin = context->matchBegin;-
1074-
1075 if (matchBegin) {
matchBeginDescription
TRUEnever evaluated
FALSEnever evaluated
0
1076 for (matchBegin--; true; matchBegin--) {
trueDescription
TRUEnever evaluated
FALSEnever evaluated
0
1077 if (testCharacterClass(pattern->newlineCharacterClass, input.reread(matchBegin))) {
testCharacterC...d(matchBegin))Description
TRUEnever evaluated
FALSEnever evaluated
0
1078 ++matchBegin;-
1079 break;
never executed: break;
0
1080 }-
1081-
1082 if (!matchBegin)
!matchBeginDescription
TRUEnever evaluated
FALSEnever evaluated
0
1083 break;
never executed: break;
0
1084 }
never executed: end of block
0
1085 }
never executed: end of block
0
1086-
1087 unsigned matchEnd = input.getPos();-
1088-
1089 for (; (matchEnd != input.end())
(matchEnd != input.end())Description
TRUEnever evaluated
FALSEnever evaluated
0
1090 && (!testCharacterClass(pattern->newlineCharacterClass, input.reread(matchEnd))); matchEnd++) { }
never executed: end of block
(!testCharacte...ad(matchEnd)))Description
TRUEnever evaluated
FALSEnever evaluated
0
1091-
1092 if (((matchBegin && term.anchors.m_bol)
matchBeginDescription
TRUEnever evaluated
FALSEnever evaluated
term.anchors.m_bolDescription
TRUEnever evaluated
FALSEnever evaluated
0
1093 || ((matchEnd != input.end()) && term.anchors.m_eol))
(matchEnd != input.end())Description
TRUEnever evaluated
FALSEnever evaluated
term.anchors.m_eolDescription
TRUEnever evaluated
FALSEnever evaluated
0
1094 && !pattern->m_multiline)
!pattern->m_multilineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1095 return false;
never executed: return false;
0
1096-
1097 context->matchBegin = matchBegin;-
1098 context->matchEnd = matchEnd;-
1099 return true;
never executed: return true;
0
1100 }-
1101-
1102#define MATCH_NEXT() { ++context->term; goto matchAgain; }-
1103#define BACKTRACK() { --context->term; goto backtrack; }-
1104#define currentTerm() (disjunction->terms[context->term])-
1105 JSRegExpResult matchDisjunction(ByteDisjunction* disjunction, DisjunctionContext* context, bool btrack = false)-
1106 {-
1107 if (!--remainingMatchCount)
!--remainingMatchCountDescription
TRUEnever evaluated
FALSEevaluated 3016 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-3016
1108 return JSRegExpErrorHitLimit;
never executed: return JSRegExpErrorHitLimit;
0
1109-
1110 if (btrack)
btrackDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2972 times by 1 test
Evaluated by:
  • tst_ecmascripttests
44-2972
1111 BACKTRACK();
executed 44 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
44
1112-
1113 context->matchBegin = input.getPos();-
1114 context->term = 0;-
1115-
1116 matchAgain:
code before this statement executed 2972 times by 1 test: matchAgain:
Executed by:
  • tst_ecmascripttests
2972
1117 ASSERT(context->term < static_cast<int>(disjunction->terms.size()));-
1118-
1119 switch (currentTerm().type) {-
1120 case ByteTerm::TypeSubpatternBegin:
executed 2756 times by 1 test: case ByteTerm::TypeSubpatternBegin:
Executed by:
  • tst_ecmascripttests
2756
1121 MATCH_NEXT();
executed 2756 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
2756
1122 case ByteTerm::TypeSubpatternEnd:
executed 524 times by 1 test: case ByteTerm::TypeSubpatternEnd:
Executed by:
  • tst_ecmascripttests
524
1123 context->matchEnd = input.getPos();-
1124 return JSRegExpMatch;
executed 524 times by 1 test: return JSRegExpMatch;
Executed by:
  • tst_ecmascripttests
524
1125-
1126 case ByteTerm::TypeBodyAlternativeBegin:
executed 215 times by 1 test: case ByteTerm::TypeBodyAlternativeBegin:
Executed by:
  • tst_ecmascripttests
215
1127 MATCH_NEXT();
executed 215 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
215
1128 case ByteTerm::TypeBodyAlternativeDisjunction:
never executed: case ByteTerm::TypeBodyAlternativeDisjunction:
0
1129 case ByteTerm::TypeBodyAlternativeEnd:
executed 192 times by 1 test: case ByteTerm::TypeBodyAlternativeEnd:
Executed by:
  • tst_ecmascripttests
192
1130 context->matchEnd = input.getPos();-
1131 return JSRegExpMatch;
executed 192 times by 1 test: return JSRegExpMatch;
Executed by:
  • tst_ecmascripttests
192
1132-
1133 case ByteTerm::TypeAlternativeBegin:
executed 552 times by 1 test: case ByteTerm::TypeAlternativeBegin:
Executed by:
  • tst_ecmascripttests
552
1134 MATCH_NEXT();
executed 552 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
552
1135 case ByteTerm::TypeAlternativeDisjunction:
executed 436 times by 1 test: case ByteTerm::TypeAlternativeDisjunction:
Executed by:
  • tst_ecmascripttests
436
1136 case ByteTerm::TypeAlternativeEnd: {
executed 8 times by 1 test: case ByteTerm::TypeAlternativeEnd:
Executed by:
  • tst_ecmascripttests
8
1137 int offset = currentTerm().alternative.end;-
1138 BackTrackInfoAlternative* backTrack = reinterpret_cast<BackTrackInfoAlternative*>(context->frame + currentTerm().frameLocation);-
1139 backTrack->offset = offset;-
1140 context->term += offset;-
1141 MATCH_NEXT();
executed 444 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
444
1142 }-
1143-
1144 case ByteTerm::TypeAssertionBOL:
executed 24 times by 1 test: case ByteTerm::TypeAssertionBOL:
Executed by:
  • tst_ecmascripttests
24
1145 if (matchAssertionBOL(currentTerm()))
matchAssertion...ntext->term]))Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-24
1146 MATCH_NEXT();
executed 24 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
24
1147 BACKTRACK();
never executed: goto backtrack;
0
1148 case ByteTerm::TypeAssertionEOL:
executed 28 times by 1 test: case ByteTerm::TypeAssertionEOL:
Executed by:
  • tst_ecmascripttests
28
1149 if (matchAssertionEOL(currentTerm()))
matchAssertion...ntext->term]))Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-24
1150 MATCH_NEXT();
executed 24 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
24
1151 BACKTRACK();
executed 4 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
4
1152 case ByteTerm::TypeAssertionWordBoundary:
executed 64 times by 1 test: case ByteTerm::TypeAssertionWordBoundary:
Executed by:
  • tst_ecmascripttests
64
1153 if (matchAssertionWordBoundary(currentTerm()))
matchAssertion...ntext->term]))Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
32
1154 MATCH_NEXT();
executed 32 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
32
1155 BACKTRACK();
executed 32 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
32
1156-
1157 case ByteTerm::TypePatternCharacterOnce:
executed 3701495 times by 1 test: case ByteTerm::TypePatternCharacterOnce:
Executed by:
  • tst_ecmascripttests
3701495
1158 case ByteTerm::TypePatternCharacterFixed: {
never executed: case ByteTerm::TypePatternCharacterFixed:
0
1159 for (unsigned matchAmount = 0; matchAmount < currentTerm().atom.quantityCount; ++matchAmount) {
matchAmount < ....quantityCountDescription
TRUEevaluated 3701495 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2654 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2654-3701495
1160 if (!checkCharacter(currentTerm().atom.patternCharacter, currentTerm().inputPosition - matchAmount))
!checkCharacte...- matchAmount)Description
TRUEevaluated 3698843 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2654 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2654-3698843
1161 BACKTRACK();
executed 3698843 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
3698843
1162 }
executed 2654 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
2654
1163 MATCH_NEXT();
executed 2653 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
2653
1164 }-
1165 case ByteTerm::TypePatternCharacterGreedy: {
executed 136 times by 1 test: case ByteTerm::TypePatternCharacterGreedy:
Executed by:
  • tst_ecmascripttests
136
1166 BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + currentTerm().frameLocation);-
1167 unsigned matchAmount = 0;-
1168 while ((matchAmount < currentTerm().atom.quantityCount) && input.checkInput(1)) {
(matchAmount <...quantityCount)Description
TRUEevaluated 260 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
input.checkInput(1)Description
TRUEevaluated 244 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_ecmascripttests
16-260
1169 if (!checkCharacter(currentTerm().atom.patternCharacter, currentTerm().inputPosition + 1)) {
!checkCharacte...tPosition + 1)Description
TRUEevaluated 96 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 148 times by 1 test
Evaluated by:
  • tst_ecmascripttests
96-148
1170 input.uncheckInput(1);-
1171 break;
executed 96 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
96
1172 }-
1173 ++matchAmount;-
1174 }
executed 148 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
148
1175 backTrack->matchAmount = matchAmount;-
1176-
1177 MATCH_NEXT();
executed 136 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
136
1178 }-
1179 case ByteTerm::TypePatternCharacterNonGreedy: {
never executed: case ByteTerm::TypePatternCharacterNonGreedy:
0
1180 BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + currentTerm().frameLocation);-
1181 backTrack->matchAmount = 0;-
1182 MATCH_NEXT();
never executed: goto matchAgain;
0
1183 }-
1184-
1185 case ByteTerm::TypePatternCasedCharacterOnce:
executed 36 times by 1 test: case ByteTerm::TypePatternCasedCharacterOnce:
Executed by:
  • tst_ecmascripttests
36
1186 case ByteTerm::TypePatternCasedCharacterFixed: {
never executed: case ByteTerm::TypePatternCasedCharacterFixed:
0
1187 for (unsigned matchAmount = 0; matchAmount < currentTerm().atom.quantityCount; ++matchAmount) {
matchAmount < ....quantityCountDescription
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
32-36
1188 if (!checkCasedCharacter(currentTerm().atom.casedCharacter.lo, currentTerm().atom.casedCharacter.hi, currentTerm().inputPosition - matchAmount))
!checkCasedCha...- matchAmount)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-32
1189 BACKTRACK();
executed 4 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
4
1190 }
executed 32 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
32
1191 MATCH_NEXT();
executed 32 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
32
1192 }-
1193 case ByteTerm::TypePatternCasedCharacterGreedy: {
never executed: case ByteTerm::TypePatternCasedCharacterGreedy:
0
1194 BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + currentTerm().frameLocation);-
1195 unsigned matchAmount = 0;-
1196 while ((matchAmount < currentTerm().atom.quantityCount) && input.checkInput(1)) {
(matchAmount <...quantityCount)Description
TRUEnever evaluated
FALSEnever evaluated
input.checkInput(1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1197 if (!checkCasedCharacter(currentTerm().atom.casedCharacter.lo, currentTerm().atom.casedCharacter.hi, currentTerm().inputPosition + 1)) {
!checkCasedCha...tPosition + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1198 input.uncheckInput(1);-
1199 break;
never executed: break;
0
1200 }-
1201 ++matchAmount;-
1202 }
never executed: end of block
0
1203 backTrack->matchAmount = matchAmount;-
1204-
1205 MATCH_NEXT();
never executed: goto matchAgain;
0
1206 }-
1207 case ByteTerm::TypePatternCasedCharacterNonGreedy: {
never executed: case ByteTerm::TypePatternCasedCharacterNonGreedy:
0
1208 BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + currentTerm().frameLocation);-
1209 backTrack->matchAmount = 0;-
1210 MATCH_NEXT();
never executed: goto matchAgain;
0
1211 }-
1212-
1213 case ByteTerm::TypeCharacterClass:
executed 19220 times by 1 test: case ByteTerm::TypeCharacterClass:
Executed by:
  • tst_ecmascripttests
19220
1214 if (matchCharacterClass(currentTerm(), context))
matchCharacter...rm]), context)Description
TRUEevaluated 16644 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2576 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2576-16644
1215 MATCH_NEXT();
executed 16644 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
16644
1216 BACKTRACK();
executed 2576 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
2576
1217 case ByteTerm::TypeBackReference:
executed 308 times by 1 test: case ByteTerm::TypeBackReference:
Executed by:
  • tst_ecmascripttests
308
1218 if (matchBackReference(currentTerm(), context))
matchBackRefer...rm]), context)Description
TRUEevaluated 224 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 84 times by 1 test
Evaluated by:
  • tst_ecmascripttests
84-224
1219 MATCH_NEXT();
executed 224 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
224
1220 BACKTRACK();
executed 84 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
84
1221 case ByteTerm::TypeParenthesesSubpattern: {
executed 2236 times by 1 test: case ByteTerm::TypeParenthesesSubpattern:
Executed by:
  • tst_ecmascripttests
2236
1222 JSRegExpResult result = matchParentheses(currentTerm(), context);-
1223-
1224 if (result == JSRegExpMatch) {
result == JSRegExpMatchDescription
TRUEevaluated 2236 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-2236
1225 MATCH_NEXT();
executed 2236 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
2236
1226 } else if (result != JSRegExpNoMatch)
result != JSRegExpNoMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
1227 return result;
never executed: return result;
0
1228-
1229 BACKTRACK();
never executed: goto backtrack;
0
1230 }-
1231 case ByteTerm::TypeParenthesesSubpatternOnceBegin:
executed 739 times by 1 test: case ByteTerm::TypeParenthesesSubpatternOnceBegin:
Executed by:
  • tst_ecmascripttests
739
1232 if (matchParenthesesOnceBegin(currentTerm(), context))
matchParenthes...rm]), context)Description
TRUEevaluated 739 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-739
1233 MATCH_NEXT();
executed 739 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
739
1234 BACKTRACK();
never executed: goto backtrack;
0
1235 case ByteTerm::TypeParenthesesSubpatternOnceEnd:
executed 572 times by 1 test: case ByteTerm::TypeParenthesesSubpatternOnceEnd:
Executed by:
  • tst_ecmascripttests
572
1236 if (matchParenthesesOnceEnd(currentTerm(), context))
matchParenthes...rm]), context)Description
TRUEevaluated 572 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-572
1237 MATCH_NEXT();
executed 572 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
572
1238 BACKTRACK();
never executed: goto backtrack;
0
1239 case ByteTerm::TypeParenthesesSubpatternTerminalBegin:
never executed: case ByteTerm::TypeParenthesesSubpatternTerminalBegin:
0
1240 if (matchParenthesesTerminalBegin(currentTerm(), context))
matchParenthes...rm]), context)Description
TRUEnever evaluated
FALSEnever evaluated
0
1241 MATCH_NEXT();
never executed: goto matchAgain;
0
1242 BACKTRACK();
never executed: goto backtrack;
0
1243 case ByteTerm::TypeParenthesesSubpatternTerminalEnd:
never executed: case ByteTerm::TypeParenthesesSubpatternTerminalEnd:
0
1244 if (matchParenthesesTerminalEnd(currentTerm(), context))
matchParenthes...rm]), context)Description
TRUEnever evaluated
FALSEnever evaluated
0
1245 MATCH_NEXT();
never executed: goto matchAgain;
0
1246 BACKTRACK();
never executed: goto backtrack;
0
1247 case ByteTerm::TypeParentheticalAssertionBegin:
executed 24 times by 1 test: case ByteTerm::TypeParentheticalAssertionBegin:
Executed by:
  • tst_ecmascripttests
24
1248 if (matchParentheticalAssertionBegin(currentTerm(), context))
matchParenthet...rm]), context)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-24
1249 MATCH_NEXT();
executed 24 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
24
1250 BACKTRACK();
never executed: goto backtrack;
0
1251 case ByteTerm::TypeParentheticalAssertionEnd:
executed 16 times by 1 test: case ByteTerm::TypeParentheticalAssertionEnd:
Executed by:
  • tst_ecmascripttests
16
1252 if (matchParentheticalAssertionEnd(currentTerm(), context))
matchParenthet...rm]), context)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-12
1253 MATCH_NEXT();
executed 12 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
12
1254 BACKTRACK();
executed 4 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
4
1255-
1256 case ByteTerm::TypeCheckInput:
executed 27664 times by 1 test: case ByteTerm::TypeCheckInput:
Executed by:
  • tst_ecmascripttests
27664
1257 if (input.checkInput(currentTerm().checkInputCount))
input.checkInp...eckInputCount)Description
TRUEevaluated 27422 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 244 times by 1 test
Evaluated by:
  • tst_ecmascripttests
244-27422
1258 MATCH_NEXT();
executed 27422 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
27422
1259 BACKTRACK();
executed 244 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
244
1260-
1261 case ByteTerm::TypeUncheckInput:
never executed: case ByteTerm::TypeUncheckInput:
0
1262 input.uncheckInput(currentTerm().checkInputCount);-
1263 MATCH_NEXT();
never executed: goto matchAgain;
0
1264 -
1265 case ByteTerm::TypeDotStarEnclosure:
never executed: case ByteTerm::TypeDotStarEnclosure:
0
1266 if (matchDotStarEnclosure(currentTerm(), context))
matchDotStarEn...rm]), context)Description
TRUEnever evaluated
FALSEnever evaluated
0
1267 return JSRegExpMatch;
never executed: return JSRegExpMatch;
0
1268 BACKTRACK();
never executed: goto backtrack;
0
1269 }-
1270-
1271 // We should never fall-through to here.-
1272 RELEASE_ASSERT_NOT_REACHED();-
1273-
1274 backtrack:
code before this statement never executed: backtrack:
0
1275 ASSERT(context->term < static_cast<int>(disjunction->terms.size()));-
1276-
1277 switch (currentTerm().type) {-
1278 case ByteTerm::TypeSubpatternBegin:
executed 2276 times by 1 test: case ByteTerm::TypeSubpatternBegin:
Executed by:
  • tst_ecmascripttests
2276
1279 return JSRegExpNoMatch;
executed 2276 times by 1 test: return JSRegExpNoMatch;
Executed by:
  • tst_ecmascripttests
2276
1280 case ByteTerm::TypeSubpatternEnd:
never executed: case ByteTerm::TypeSubpatternEnd:
0
1281 RELEASE_ASSERT_NOT_REACHED();-
1282-
1283 case ByteTerm::TypeBodyAlternativeBegin:
code before this statement never executed: case ByteTerm::TypeBodyAlternativeBegin:
executed 16268 times by 1 test: case ByteTerm::TypeBodyAlternativeBegin:
Executed by:
  • tst_ecmascripttests
0-16268
1284 case ByteTerm::TypeBodyAlternativeDisjunction: {
executed 8048 times by 1 test: case ByteTerm::TypeBodyAlternativeDisjunction:
Executed by:
  • tst_ecmascripttests
8048
1285 int offset = currentTerm().alternative.next;-
1286 context->term += offset;-
1287 if (offset > 0)
offset > 0Description
TRUEevaluated 8056 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 16260 times by 1 test
Evaluated by:
  • tst_ecmascripttests
8056-16260
1288 MATCH_NEXT();
executed 8056 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
8056
1289-
1290 if (input.atEnd())
input.atEnd()Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 16236 times by 1 test
Evaluated by:
  • tst_ecmascripttests
24-16236
1291 return JSRegExpNoMatch;
executed 24 times by 1 test: return JSRegExpNoMatch;
Executed by:
  • tst_ecmascripttests
24
1292-
1293 input.next();-
1294-
1295 context->matchBegin = input.getPos();-
1296-
1297 if (currentTerm().alternative.onceThrough)
(disjunction->...ve.onceThroughDescription
TRUEnever evaluated
FALSEevaluated 16236 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-16236
1298 context->term += currentTerm().alternative.next;
never executed: context->term += (disjunction->terms[context->term]).alternative.next;
0
1299-
1300 MATCH_NEXT();
executed 16236 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
16236
1301 }-
1302 case ByteTerm::TypeBodyAlternativeEnd:
never executed: case ByteTerm::TypeBodyAlternativeEnd:
0
1303 RELEASE_ASSERT_NOT_REACHED();-
1304-
1305 case ByteTerm::TypeAlternativeBegin:
code before this statement never executed: case ByteTerm::TypeAlternativeBegin:
executed 140 times by 1 test: case ByteTerm::TypeAlternativeBegin:
Executed by:
  • tst_ecmascripttests
0-140
1306 case ByteTerm::TypeAlternativeDisjunction: {
executed 200 times by 1 test: case ByteTerm::TypeAlternativeDisjunction:
Executed by:
  • tst_ecmascripttests
200
1307 int offset = currentTerm().alternative.next;-
1308 context->term += offset;-
1309 if (offset > 0)
offset > 0Description
TRUEevaluated 232 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 108 times by 1 test
Evaluated by:
  • tst_ecmascripttests
108-232
1310 MATCH_NEXT();
executed 232 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
232
1311 BACKTRACK();
executed 108 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
108
1312 }-
1313 case ByteTerm::TypeAlternativeEnd: {
never executed: case ByteTerm::TypeAlternativeEnd:
0
1314 // We should never backtrack back into an alternative of the main body of the regex.-
1315 BackTrackInfoAlternative* backTrack = reinterpret_cast<BackTrackInfoAlternative*>(context->frame + currentTerm().frameLocation);-
1316 unsigned offset = backTrack->offset;-
1317 context->term -= offset;-
1318 BACKTRACK();
never executed: goto backtrack;
0
1319 }-
1320-
1321 case ByteTerm::TypeAssertionBOL:
never executed: case ByteTerm::TypeAssertionBOL:
0
1322 case ByteTerm::TypeAssertionEOL:
never executed: case ByteTerm::TypeAssertionEOL:
0
1323 case ByteTerm::TypeAssertionWordBoundary:
executed 24 times by 1 test: case ByteTerm::TypeAssertionWordBoundary:
Executed by:
  • tst_ecmascripttests
24
1324 BACKTRACK();
executed 24 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
24
1325-
1326 case ByteTerm::TypePatternCharacterOnce:
executed 2136 times by 1 test: case ByteTerm::TypePatternCharacterOnce:
Executed by:
  • tst_ecmascripttests
2136
1327 case ByteTerm::TypePatternCharacterFixed:
never executed: case ByteTerm::TypePatternCharacterFixed:
0
1328 case ByteTerm::TypePatternCharacterGreedy:
executed 52 times by 1 test: case ByteTerm::TypePatternCharacterGreedy:
Executed by:
  • tst_ecmascripttests
52
1329 case ByteTerm::TypePatternCharacterNonGreedy:
never executed: case ByteTerm::TypePatternCharacterNonGreedy:
0
1330 if (backtrackPatternCharacter(currentTerm(), context))
backtrackPatte...rm]), context)Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2148 times by 1 test
Evaluated by:
  • tst_ecmascripttests
40-2148
1331 MATCH_NEXT();
executed 40 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
40
1332 BACKTRACK();
executed 2148 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
2148
1333 case ByteTerm::TypePatternCasedCharacterOnce:
never executed: case ByteTerm::TypePatternCasedCharacterOnce:
0
1334 case ByteTerm::TypePatternCasedCharacterFixed:
never executed: case ByteTerm::TypePatternCasedCharacterFixed:
0
1335 case ByteTerm::TypePatternCasedCharacterGreedy:
never executed: case ByteTerm::TypePatternCasedCharacterGreedy:
0
1336 case ByteTerm::TypePatternCasedCharacterNonGreedy:
never executed: case ByteTerm::TypePatternCasedCharacterNonGreedy:
0
1337 if (backtrackPatternCasedCharacter(currentTerm(), context))
backtrackPatte...rm]), context)Description
TRUEnever evaluated
FALSEnever evaluated
0
1338 MATCH_NEXT();
never executed: goto matchAgain;
0
1339 BACKTRACK();
never executed: goto backtrack;
0
1340 case ByteTerm::TypeCharacterClass:
executed 3690716 times by 1 test: case ByteTerm::TypeCharacterClass:
Executed by:
  • tst_ecmascripttests
3690716
1341 if (backtrackCharacterClass(currentTerm(), context))
backtrackChara...rm]), context)Description
TRUEevaluated 3674764 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 15952 times by 1 test
Evaluated by:
  • tst_ecmascripttests
15952-3674764
1342 MATCH_NEXT();
executed 3674764 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
3674764
1343 BACKTRACK();
executed 15952 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
15952
1344 case ByteTerm::TypeBackReference:
executed 32 times by 1 test: case ByteTerm::TypeBackReference:
Executed by:
  • tst_ecmascripttests
32
1345 if (backtrackBackReference(currentTerm(), context))
backtrackBackR...rm]), context)Description
TRUEnever evaluated
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-32
1346 MATCH_NEXT();
never executed: goto matchAgain;
0
1347 BACKTRACK();
executed 32 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
32
1348 case ByteTerm::TypeParenthesesSubpattern: {
executed 2124 times by 1 test: case ByteTerm::TypeParenthesesSubpattern:
Executed by:
  • tst_ecmascripttests
2124
1349 JSRegExpResult result = backtrackParentheses(currentTerm(), context);-
1350-
1351 if (result == JSRegExpMatch) {
result == JSRegExpMatchDescription
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2068 times by 1 test
Evaluated by:
  • tst_ecmascripttests
56-2068
1352 MATCH_NEXT();
executed 56 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
56
1353 } else if (result != JSRegExpNoMatch)
result != JSRegExpNoMatchDescription
TRUEnever evaluated
FALSEevaluated 2068 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-2068
1354 return result;
never executed: return result;
0
1355-
1356 BACKTRACK();
executed 2068 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
2068
1357 }-
1358 case ByteTerm::TypeParenthesesSubpatternOnceBegin:
executed 292 times by 1 test: case ByteTerm::TypeParenthesesSubpatternOnceBegin:
Executed by:
  • tst_ecmascripttests
292
1359 if (backtrackParenthesesOnceBegin(currentTerm(), context))
backtrackParen...rm]), context)Description
TRUEevaluated 148 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 144 times by 1 test
Evaluated by:
  • tst_ecmascripttests
144-148
1360 MATCH_NEXT();
executed 148 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
148
1361 BACKTRACK();
executed 144 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
144
1362 case ByteTerm::TypeParenthesesSubpatternOnceEnd:
executed 148 times by 1 test: case ByteTerm::TypeParenthesesSubpatternOnceEnd:
Executed by:
  • tst_ecmascripttests
148
1363 if (backtrackParenthesesOnceEnd(currentTerm(), context))
backtrackParen...rm]), context)Description
TRUEnever evaluated
FALSEevaluated 148 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-148
1364 MATCH_NEXT();
never executed: goto matchAgain;
0
1365 BACKTRACK();
executed 148 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
148
1366 case ByteTerm::TypeParenthesesSubpatternTerminalBegin:
never executed: case ByteTerm::TypeParenthesesSubpatternTerminalBegin:
0
1367 if (backtrackParenthesesTerminalBegin(currentTerm(), context))
backtrackParen...rm]), context)Description
TRUEnever evaluated
FALSEnever evaluated
0
1368 MATCH_NEXT();
never executed: goto matchAgain;
0
1369 BACKTRACK();
never executed: goto backtrack;
0
1370 case ByteTerm::TypeParenthesesSubpatternTerminalEnd:
never executed: case ByteTerm::TypeParenthesesSubpatternTerminalEnd:
0
1371 if (backtrackParenthesesTerminalEnd(currentTerm(), context))
backtrackParen...rm]), context)Description
TRUEnever evaluated
FALSEnever evaluated
0
1372 MATCH_NEXT();
never executed: goto matchAgain;
0
1373 BACKTRACK();
never executed: goto backtrack;
0
1374 case ByteTerm::TypeParentheticalAssertionBegin:
executed 8 times by 1 test: case ByteTerm::TypeParentheticalAssertionBegin:
Executed by:
  • tst_ecmascripttests
8
1375 if (backtrackParentheticalAssertionBegin(currentTerm(), context))
backtrackParen...rm]), context)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4
1376 MATCH_NEXT();
executed 4 times by 1 test: goto matchAgain;
Executed by:
  • tst_ecmascripttests
4
1377 BACKTRACK();
executed 4 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
4
1378 case ByteTerm::TypeParentheticalAssertionEnd:
executed 8 times by 1 test: case ByteTerm::TypeParentheticalAssertionEnd:
Executed by:
  • tst_ecmascripttests
8
1379 if (backtrackParentheticalAssertionEnd(currentTerm(), context))
backtrackParen...rm]), context)Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-8
1380 MATCH_NEXT();
never executed: goto matchAgain;
0
1381 BACKTRACK();
executed 8 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
8
1382-
1383 case ByteTerm::TypeCheckInput:
executed 26715 times by 1 test: case ByteTerm::TypeCheckInput:
Executed by:
  • tst_ecmascripttests
26715
1384 input.uncheckInput(currentTerm().checkInputCount);-
1385 BACKTRACK();
executed 26715 times by 1 test: goto backtrack;
Executed by:
  • tst_ecmascripttests
26715
1386-
1387 case ByteTerm::TypeUncheckInput:
never executed: case ByteTerm::TypeUncheckInput:
0
1388 input.checkInput(currentTerm().checkInputCount);-
1389 BACKTRACK();
never executed: goto backtrack;
0
1390-
1391 case ByteTerm::TypeDotStarEnclosure:
never executed: case ByteTerm::TypeDotStarEnclosure:
0
1392 RELEASE_ASSERT_NOT_REACHED();-
1393 }
never executed: end of block
0
1394-
1395 RELEASE_ASSERT_NOT_REACHED();-
1396 return JSRegExpErrorNoMatch;
never executed: return JSRegExpErrorNoMatch;
0
1397 }-
1398-
1399 JSRegExpResult matchNonZeroDisjunction(ByteDisjunction* disjunction, DisjunctionContext* context, bool btrack = false)-
1400 {-
1401 JSRegExpResult result = matchDisjunction(disjunction, context, btrack);-
1402-
1403 if (result == JSRegExpMatch) {
result == JSRegExpMatchDescription
TRUEevaluated 524 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2276 times by 1 test
Evaluated by:
  • tst_ecmascripttests
524-2276
1404 while (context->matchBegin == context->matchEnd) {
context->match...text->matchEndDescription
TRUEnever evaluated
FALSEevaluated 524 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-524
1405 result = matchDisjunction(disjunction, context, true);-
1406 if (result != JSRegExpMatch)
result != JSRegExpMatchDescription
TRUEnever evaluated
FALSEnever evaluated
0
1407 return result;
never executed: return result;
0
1408 }
never executed: end of block
0
1409 return JSRegExpMatch;
executed 524 times by 1 test: return JSRegExpMatch;
Executed by:
  • tst_ecmascripttests
524
1410 }-
1411-
1412 return result;
executed 2276 times by 1 test: return result;
Executed by:
  • tst_ecmascripttests
2276
1413 }-
1414-
1415 unsigned interpret()-
1416 {-
1417 if (!input.isAvailableInput(0))
!input.isAvailableInput(0)Description
TRUEnever evaluated
FALSEevaluated 215 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-215
1418 return offsetNoMatch;
never executed: return offsetNoMatch;
0
1419-
1420 for (unsigned i = 0; i < pattern->m_body->m_numSubpatterns + 1; ++i)
i < pattern->m...ubpatterns + 1Description
TRUEevaluated 1310 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 216 times by 1 test
Evaluated by:
  • tst_ecmascripttests
216-1310
1421 output[i << 1] = offsetNoMatch;
executed 1311 times by 1 test: output[i << 1] = offsetNoMatch;
Executed by:
  • tst_ecmascripttests
1311
1422-
1423 allocatorPool = pattern->m_allocator->startAllocator();-
1424 RELEASE_ASSERT(allocatorPool);-
1425-
1426 DisjunctionContext* context = allocDisjunctionContext(pattern->m_body.get());-
1427-
1428 JSRegExpResult result = matchDisjunction(pattern->m_body.get(), context, false);-
1429 if (result == JSRegExpMatch) {
result == JSRegExpMatchDescription
TRUEevaluated 192 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
24-192
1430 output[0] = context->matchBegin;-
1431 output[1] = context->matchEnd;-
1432 }
executed 192 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
192
1433-
1434 freeDisjunctionContext(context);-
1435-
1436 pattern->m_allocator->stopAllocator();-
1437-
1438 ASSERT((result == JSRegExpMatch) == (output[0] != offsetNoMatch));-
1439 return output[0];
executed 216 times by 1 test: return output[0];
Executed by:
  • tst_ecmascripttests
216
1440 }-
1441-
1442 Interpreter(BytecodePattern* pattern, unsigned* output, const CharType* input, unsigned length, unsigned start)-
1443 : pattern(pattern)-
1444 , output(output)-
1445 , input(input, start, length)-
1446 , allocatorPool(0)-
1447 , remainingMatchCount(matchLimit)-
1448 {-
1449 }
executed 216 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
216
1450-
1451private:-
1452 BytecodePattern* pattern;-
1453 unsigned* output;-
1454 InputStream input;-
1455 BumpPointerPool* allocatorPool;-
1456 unsigned remainingMatchCount;-
1457};-
1458-
1459class ByteCompiler {-
1460 struct ParenthesesStackEntry {-
1461 unsigned beginTerm;-
1462 unsigned savedAlternativeIndex;-
1463 ParenthesesStackEntry(unsigned beginTerm, unsigned savedAlternativeIndex/*, unsigned subpatternId, bool capture = false*/)-
1464 : beginTerm(beginTerm)-
1465 , savedAlternativeIndex(savedAlternativeIndex)-
1466 {-
1467 }
executed 1108 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1108
1468 };-
1469-
1470public:-
1471 ByteCompiler(YarrPattern& pattern)-
1472 : m_pattern(pattern)-
1473 {-
1474 m_currentAlternativeIndex = 0;-
1475 }
executed 208 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
208
1476-
1477 PassOwnPtr<BytecodePattern> compile(BumpPointerAllocator* allocator)-
1478 {-
1479 regexBegin(m_pattern.m_numSubpatterns, m_pattern.m_body->m_callFrameSize, m_pattern.m_body->m_alternatives[0]->onceThrough());-
1480 emitDisjunction(m_pattern.m_body);-
1481 regexEnd();-
1482-
1483 return adoptPtr(new BytecodePattern(m_bodyDisjunction.release(), m_allParenthesesInfo, m_pattern, allocator));
executed 208 times by 1 test: return adoptPtr(new BytecodePattern(m_bodyDisjunction.release(), m_allParenthesesInfo, m_pattern, allocator));
Executed by:
  • tst_ecmascripttests
208
1484 }-
1485-
1486 void checkInput(unsigned count)-
1487 {-
1488 m_bodyDisjunction->terms.append(ByteTerm::CheckInput(count));-
1489 }
executed 1255 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1255
1490-
1491 void uncheckInput(unsigned count)-
1492 {-
1493 m_bodyDisjunction->terms.append(ByteTerm::UncheckInput(count));-
1494 }
never executed: end of block
0
1495 -
1496 void assertionBOL(unsigned inputPosition)-
1497 {-
1498 m_bodyDisjunction->terms.append(ByteTerm::BOL(inputPosition));-
1499 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
24
1500-
1501 void assertionEOL(unsigned inputPosition)-
1502 {-
1503 m_bodyDisjunction->terms.append(ByteTerm::EOL(inputPosition));-
1504 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
24
1505-
1506 void assertionWordBoundary(bool invert, unsigned inputPosition)-
1507 {-
1508 m_bodyDisjunction->terms.append(ByteTerm::WordBoundary(invert, inputPosition));-
1509 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
8
1510-
1511 void atomPatternCharacter(UChar ch, unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)-
1512 {-
1513 if (m_pattern.m_ignoreCase) {
m_pattern.m_ignoreCaseDescription
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1738 times by 1 test
Evaluated by:
  • tst_ecmascripttests
56-1738
1514 UChar lo = Unicode::toLower(ch);-
1515 UChar hi = Unicode::toUpper(ch);-
1516-
1517 if (lo != hi) {
lo != hiDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
24-32
1518 m_bodyDisjunction->terms.append(ByteTerm(lo, hi, inputPosition, frameLocation, quantityCount, quantityType));-
1519 return;
executed 32 times by 1 test: return;
Executed by:
  • tst_ecmascripttests
32
1520 }-
1521 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
24
1522-
1523 m_bodyDisjunction->terms.append(ByteTerm(ch, inputPosition, frameLocation, quantityCount, quantityType));-
1524 }
executed 1764 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1764
1525-
1526 void atomCharacterClass(CharacterClass* characterClass, bool invert, unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)-
1527 {-
1528 m_bodyDisjunction->terms.append(ByteTerm(characterClass, invert, inputPosition));-
1529-
1530 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].atom.quantityCount = quantityCount.unsafeGet();-
1531 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].atom.quantityType = quantityType;-
1532 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;-
1533 }
executed 1632 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1632
1534-
1535 void atomBackReference(unsigned subpatternId, unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)-
1536 {-
1537 ASSERT(subpatternId);-
1538-
1539 m_bodyDisjunction->terms.append(ByteTerm::BackReference(subpatternId, inputPosition));-
1540-
1541 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].atom.quantityCount = quantityCount.unsafeGet();-
1542 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].atom.quantityType = quantityType;-
1543 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;-
1544 }
executed 192 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
192
1545-
1546 void atomParenthesesOnceBegin(unsigned subpatternId, bool capture, unsigned inputPosition, unsigned frameLocation, unsigned alternativeFrameLocation)-
1547 {-
1548 ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);-
1549 int beginTerm = static_cast<int>(m_bodyDisjunction->terms.size());-
1550-
1551 m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpatternOnceBegin, subpatternId, capture, false, inputPosition));-
1552 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;-
1553 m_bodyDisjunction->terms.append(ByteTerm::AlternativeBegin());-
1554 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = alternativeFrameLocation;-
1555-
1556 m_parenthesesStack.append(ParenthesesStackEntry(beginTerm, m_currentAlternativeIndex));-
1557 m_currentAlternativeIndex = beginTerm + 1;-
1558 }
executed 688 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
688
1559-
1560 void atomParenthesesTerminalBegin(unsigned subpatternId, bool capture, unsigned inputPosition, unsigned frameLocation, unsigned alternativeFrameLocation)-
1561 {-
1562 ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);-
1563 int beginTerm = static_cast<int>(m_bodyDisjunction->terms.size());-
1564-
1565 m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpatternTerminalBegin, subpatternId, capture, false, inputPosition));-
1566 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;-
1567 m_bodyDisjunction->terms.append(ByteTerm::AlternativeBegin());-
1568 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = alternativeFrameLocation;-
1569-
1570 m_parenthesesStack.append(ParenthesesStackEntry(beginTerm, m_currentAlternativeIndex));-
1571 m_currentAlternativeIndex = beginTerm + 1;-
1572 }
never executed: end of block
0
1573-
1574 void atomParenthesesSubpatternBegin(unsigned subpatternId, bool capture, unsigned inputPosition, unsigned frameLocation, unsigned alternativeFrameLocation)-
1575 {-
1576 // Errrk! - this is a little crazy, we initially generate as a TypeParenthesesSubpatternOnceBegin,-
1577 // then fix this up at the end! - simplifying this should make it much clearer.-
1578 // https://bugs.webkit.org/show_bug.cgi?id=50136-
1579-
1580 ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);-
1581 int beginTerm = static_cast<int>(m_bodyDisjunction->terms.size());-
1582-
1583 m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpatternOnceBegin, subpatternId, capture, false, inputPosition));-
1584 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;-
1585 m_bodyDisjunction->terms.append(ByteTerm::AlternativeBegin());-
1586 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = alternativeFrameLocation;-
1587-
1588 m_parenthesesStack.append(ParenthesesStackEntry(beginTerm, m_currentAlternativeIndex));-
1589 m_currentAlternativeIndex = beginTerm + 1;-
1590 }
executed 412 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
412
1591-
1592 void atomParentheticalAssertionBegin(unsigned subpatternId, bool invert, unsigned frameLocation, unsigned alternativeFrameLocation)-
1593 {-
1594 ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);-
1595 int beginTerm = static_cast<int>(m_bodyDisjunction->terms.size());-
1596-
1597 m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParentheticalAssertionBegin, subpatternId, false, invert, 0));-
1598 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;-
1599 m_bodyDisjunction->terms.append(ByteTerm::AlternativeBegin());-
1600 m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = alternativeFrameLocation;-
1601-
1602 m_parenthesesStack.append(ParenthesesStackEntry(beginTerm, m_currentAlternativeIndex));-
1603 m_currentAlternativeIndex = beginTerm + 1;-
1604 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
8
1605-
1606 void atomParentheticalAssertionEnd(unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)-
1607 {-
1608 unsigned beginTerm = popParenthesesStack();-
1609 closeAlternative(beginTerm + 1);-
1610 ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);-
1611 unsigned endTerm = static_cast<int>(m_bodyDisjunction->terms.size());-
1612-
1613 ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeParentheticalAssertionBegin);-
1614-
1615 bool invert = m_bodyDisjunction->terms[beginTerm].invert();-
1616 unsigned subpatternId = m_bodyDisjunction->terms[beginTerm].atom.subpatternId;-
1617-
1618 m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParentheticalAssertionEnd, subpatternId, false, invert, inputPosition));-
1619 m_bodyDisjunction->terms[beginTerm].atom.parenthesesWidth = endTerm - beginTerm;-
1620 m_bodyDisjunction->terms[endTerm].atom.parenthesesWidth = endTerm - beginTerm;-
1621 m_bodyDisjunction->terms[endTerm].frameLocation = frameLocation;-
1622-
1623 m_bodyDisjunction->terms[beginTerm].atom.quantityCount = quantityCount.unsafeGet();-
1624 m_bodyDisjunction->terms[beginTerm].atom.quantityType = quantityType;-
1625 m_bodyDisjunction->terms[endTerm].atom.quantityCount = quantityCount.unsafeGet();-
1626 m_bodyDisjunction->terms[endTerm].atom.quantityType = quantityType;-
1627 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
8
1628-
1629 void assertionDotStarEnclosure(bool bolAnchored, bool eolAnchored)-
1630 {-
1631 m_bodyDisjunction->terms.append(ByteTerm::DotStarEnclosure(bolAnchored, eolAnchored));-
1632 }
never executed: end of block
0
1633-
1634 unsigned popParenthesesStack()-
1635 {-
1636 ASSERT(m_parenthesesStack.size());-
1637 ASSERT(m_parenthesesStack.size() <= INT_MAX);-
1638 int stackEnd = static_cast<int>(m_parenthesesStack.size()) - 1;-
1639 unsigned beginTerm = m_parenthesesStack[stackEnd].beginTerm;-
1640 m_currentAlternativeIndex = m_parenthesesStack[stackEnd].savedAlternativeIndex;-
1641 m_parenthesesStack.shrink(stackEnd);-
1642-
1643 ASSERT(beginTerm < m_bodyDisjunction->terms.size());-
1644 ASSERT(m_currentAlternativeIndex < m_bodyDisjunction->terms.size());-
1645-
1646 return beginTerm;
executed 1108 times by 1 test: return beginTerm;
Executed by:
  • tst_ecmascripttests
1108
1647 }-
1648-
1649#ifndef NDEBUG-
1650 void dumpDisjunction(ByteDisjunction* disjunction)-
1651 {-
1652 dataLogF("ByteDisjunction(%p):\n\t", disjunction);-
1653 for (unsigned i = 0; i < disjunction->terms.size(); ++i)
i < disjunction->terms.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1654 dataLogF("{ %d } ", disjunction->terms[i].type);
never executed: dataLogF("{ %d } ", disjunction->terms[i].type);
0
1655 dataLogF("\n");-
1656 }
never executed: end of block
0
1657#endif-
1658-
1659 void closeAlternative(int beginTerm)-
1660 {-
1661 int origBeginTerm = beginTerm;-
1662 ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeAlternativeBegin);-
1663 ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);-
1664 int endIndex = static_cast<int>(m_bodyDisjunction->terms.size());-
1665-
1666 unsigned frameLocation = m_bodyDisjunction->terms[beginTerm].frameLocation;-
1667-
1668 if (!m_bodyDisjunction->terms[beginTerm].alternative.next)
!m_bodyDisjunc...ternative.nextDescription
TRUEevaluated 668 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 440 times by 1 test
Evaluated by:
  • tst_ecmascripttests
440-668
1669 m_bodyDisjunction->terms.remove(beginTerm);
executed 668 times by 1 test: m_bodyDisjunction->terms.remove(beginTerm);
Executed by:
  • tst_ecmascripttests
668
1670 else {-
1671 while (m_bodyDisjunction->terms[beginTerm].alternative.next) {
m_bodyDisjunct...ternative.nextDescription
TRUEevaluated 564 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 440 times by 1 test
Evaluated by:
  • tst_ecmascripttests
440-564
1672 beginTerm += m_bodyDisjunction->terms[beginTerm].alternative.next;-
1673 ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeAlternativeDisjunction);-
1674 m_bodyDisjunction->terms[beginTerm].alternative.end = endIndex - beginTerm;-
1675 m_bodyDisjunction->terms[beginTerm].frameLocation = frameLocation;-
1676 }
executed 564 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
564
1677-
1678 m_bodyDisjunction->terms[beginTerm].alternative.next = origBeginTerm - beginTerm;-
1679-
1680 m_bodyDisjunction->terms.append(ByteTerm::AlternativeEnd());-
1681 m_bodyDisjunction->terms[endIndex].frameLocation = frameLocation;-
1682 }
executed 440 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
440
1683 }-
1684-
1685 void closeBodyAlternative()-
1686 {-
1687 int beginTerm = 0;-
1688 int origBeginTerm = 0;-
1689 ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeBodyAlternativeBegin);-
1690 ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);-
1691 int endIndex = static_cast<int>(m_bodyDisjunction->terms.size());-
1692-
1693 unsigned frameLocation = m_bodyDisjunction->terms[beginTerm].frameLocation;-
1694-
1695 while (m_bodyDisjunction->terms[beginTerm].alternative.next) {
m_bodyDisjunct...ternative.nextDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 208 times by 1 test
Evaluated by:
  • tst_ecmascripttests
24-208
1696 beginTerm += m_bodyDisjunction->terms[beginTerm].alternative.next;-
1697 ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeBodyAlternativeDisjunction);-
1698 m_bodyDisjunction->terms[beginTerm].alternative.end = endIndex - beginTerm;-
1699 m_bodyDisjunction->terms[beginTerm].frameLocation = frameLocation;-
1700 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
24
1701-
1702 m_bodyDisjunction->terms[beginTerm].alternative.next = origBeginTerm - beginTerm;-
1703-
1704 m_bodyDisjunction->terms.append(ByteTerm::BodyAlternativeEnd());-
1705 m_bodyDisjunction->terms[endIndex].frameLocation = frameLocation;-
1706 }
executed 208 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
208
1707-
1708 void atomParenthesesSubpatternEnd(unsigned lastSubpatternId, int inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType, unsigned callFrameSize = 0)-
1709 {-
1710 unsigned beginTerm = popParenthesesStack();-
1711 closeAlternative(beginTerm + 1);-
1712 ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);-
1713 unsigned endTerm = static_cast<int>(m_bodyDisjunction->terms.size());-
1714-
1715 ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeParenthesesSubpatternOnceBegin);-
1716-
1717 ByteTerm& parenthesesBegin = m_bodyDisjunction->terms[beginTerm];-
1718-
1719 bool capture = parenthesesBegin.capture();-
1720 unsigned subpatternId = parenthesesBegin.atom.subpatternId;-
1721-
1722 unsigned numSubpatterns = lastSubpatternId - subpatternId + 1;-
1723 OwnPtr<ByteDisjunction> parenthesesDisjunction = adoptPtr(new ByteDisjunction(numSubpatterns, callFrameSize));-
1724-
1725 unsigned firstTermInParentheses = beginTerm + 1;-
1726 parenthesesDisjunction->terms.reserveInitialCapacity(endTerm - firstTermInParentheses + 2);-
1727-
1728 parenthesesDisjunction->terms.append(ByteTerm::SubpatternBegin());-
1729 for (unsigned termInParentheses = firstTermInParentheses; termInParentheses < endTerm; ++termInParentheses)
termInParentheses < endTermDescription
TRUEevaluated 4500 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 412 times by 1 test
Evaluated by:
  • tst_ecmascripttests
412-4500
1730 parenthesesDisjunction->terms.append(m_bodyDisjunction->terms[termInParentheses]);
executed 4500 times by 1 test: parenthesesDisjunction->terms.append(m_bodyDisjunction->terms[termInParentheses]);
Executed by:
  • tst_ecmascripttests
4500
1731 parenthesesDisjunction->terms.append(ByteTerm::SubpatternEnd());-
1732-
1733 m_bodyDisjunction->terms.shrink(beginTerm);-
1734-
1735 m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpattern, subpatternId, parenthesesDisjunction.get(), capture, inputPosition));-
1736 m_allParenthesesInfo.append(parenthesesDisjunction.release());-
1737-
1738 m_bodyDisjunction->terms[beginTerm].atom.quantityCount = quantityCount.unsafeGet();-
1739 m_bodyDisjunction->terms[beginTerm].atom.quantityType = quantityType;-
1740 m_bodyDisjunction->terms[beginTerm].frameLocation = frameLocation;-
1741 }
executed 412 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
412
1742-
1743 void atomParenthesesOnceEnd(int inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)-
1744 {-
1745 unsigned beginTerm = popParenthesesStack();-
1746 closeAlternative(beginTerm + 1);-
1747 ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);-
1748 unsigned endTerm = static_cast<int>(m_bodyDisjunction->terms.size());-
1749-
1750 ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeParenthesesSubpatternOnceBegin);-
1751-
1752 bool capture = m_bodyDisjunction->terms[beginTerm].capture();-
1753 unsigned subpatternId = m_bodyDisjunction->terms[beginTerm].atom.subpatternId;-
1754-
1755 m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpatternOnceEnd, subpatternId, capture, false, inputPosition));-
1756 m_bodyDisjunction->terms[beginTerm].atom.parenthesesWidth = endTerm - beginTerm;-
1757 m_bodyDisjunction->terms[endTerm].atom.parenthesesWidth = endTerm - beginTerm;-
1758 m_bodyDisjunction->terms[endTerm].frameLocation = frameLocation;-
1759-
1760 m_bodyDisjunction->terms[beginTerm].atom.quantityCount = quantityCount.unsafeGet();-
1761 m_bodyDisjunction->terms[beginTerm].atom.quantityType = quantityType;-
1762 m_bodyDisjunction->terms[endTerm].atom.quantityCount = quantityCount.unsafeGet();-
1763 m_bodyDisjunction->terms[endTerm].atom.quantityType = quantityType;-
1764 }
executed 688 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
688
1765-
1766 void atomParenthesesTerminalEnd(int inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)-
1767 {-
1768 unsigned beginTerm = popParenthesesStack();-
1769 closeAlternative(beginTerm + 1);-
1770 ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);-
1771 unsigned endTerm = static_cast<int>(m_bodyDisjunction->terms.size());-
1772-
1773 ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeParenthesesSubpatternTerminalBegin);-
1774-
1775 bool capture = m_bodyDisjunction->terms[beginTerm].capture();-
1776 unsigned subpatternId = m_bodyDisjunction->terms[beginTerm].atom.subpatternId;-
1777-
1778 m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpatternTerminalEnd, subpatternId, capture, false, inputPosition));-
1779 m_bodyDisjunction->terms[beginTerm].atom.parenthesesWidth = endTerm - beginTerm;-
1780 m_bodyDisjunction->terms[endTerm].atom.parenthesesWidth = endTerm - beginTerm;-
1781 m_bodyDisjunction->terms[endTerm].frameLocation = frameLocation;-
1782-
1783 m_bodyDisjunction->terms[beginTerm].atom.quantityCount = quantityCount.unsafeGet();-
1784 m_bodyDisjunction->terms[beginTerm].atom.quantityType = quantityType;-
1785 m_bodyDisjunction->terms[endTerm].atom.quantityCount = quantityCount.unsafeGet();-
1786 m_bodyDisjunction->terms[endTerm].atom.quantityType = quantityType;-
1787 }
never executed: end of block
0
1788-
1789 void regexBegin(unsigned numSubpatterns, unsigned callFrameSize, bool onceThrough)-
1790 {-
1791 m_bodyDisjunction = adoptPtr(new ByteDisjunction(numSubpatterns, callFrameSize));-
1792 m_bodyDisjunction->terms.append(ByteTerm::BodyAlternativeBegin(onceThrough));-
1793 m_bodyDisjunction->terms[0].frameLocation = 0;-
1794 m_currentAlternativeIndex = 0;-
1795 }
executed 208 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
208
1796-
1797 void regexEnd()-
1798 {-
1799 closeBodyAlternative();-
1800 }
executed 208 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
208
1801-
1802 void alternativeBodyDisjunction(bool onceThrough)-
1803 {-
1804 ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);-
1805 int newAlternativeIndex = static_cast<int>(m_bodyDisjunction->terms.size());-
1806 m_bodyDisjunction->terms[m_currentAlternativeIndex].alternative.next = newAlternativeIndex - m_currentAlternativeIndex;-
1807 m_bodyDisjunction->terms.append(ByteTerm::BodyAlternativeDisjunction(onceThrough));-
1808-
1809 m_currentAlternativeIndex = newAlternativeIndex;-
1810 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
24
1811-
1812 void alternativeDisjunction()-
1813 {-
1814 ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);-
1815 int newAlternativeIndex = static_cast<int>(m_bodyDisjunction->terms.size());-
1816 m_bodyDisjunction->terms[m_currentAlternativeIndex].alternative.next = newAlternativeIndex - m_currentAlternativeIndex;-
1817 m_bodyDisjunction->terms.append(ByteTerm::AlternativeDisjunction());-
1818-
1819 m_currentAlternativeIndex = newAlternativeIndex;-
1820 }
executed 564 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
564
1821-
1822 void emitDisjunction(PatternDisjunction* disjunction, unsigned inputCountAlreadyChecked = 0, unsigned parenthesesInputCountAlreadyChecked = 0)-
1823 {-
1824 for (unsigned alt = 0; alt < disjunction->m_alternatives.size(); ++alt) {
alt < disjunct...natives.size()Description
TRUEevaluated 1903 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1316 times by 1 test
Evaluated by:
  • tst_ecmascripttests
1316-1903
1825 unsigned currentCountAlreadyChecked = inputCountAlreadyChecked;-
1826-
1827 PatternAlternative* alternative = disjunction->m_alternatives[alt].get();-
1828-
1829 if (alt) {
altDescription
TRUEevaluated 588 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1315 times by 1 test
Evaluated by:
  • tst_ecmascripttests
588-1315
1830 if (disjunction == m_pattern.m_body)
disjunction ==...pattern.m_bodyDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 564 times by 1 test
Evaluated by:
  • tst_ecmascripttests
24-564
1831 alternativeBodyDisjunction(alternative->onceThrough());
executed 24 times by 1 test: alternativeBodyDisjunction(alternative->onceThrough());
Executed by:
  • tst_ecmascripttests
24
1832 else-
1833 alternativeDisjunction();
executed 564 times by 1 test: alternativeDisjunction();
Executed by:
  • tst_ecmascripttests
564
1834 }-
1835-
1836 unsigned minimumSize = alternative->m_minimumSize;-
1837 ASSERT(minimumSize >= parenthesesInputCountAlreadyChecked);-
1838 unsigned countToCheck = minimumSize - parenthesesInputCountAlreadyChecked;-
1839-
1840 if (countToCheck) {
countToCheckDescription
TRUEevaluated 1255 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 647 times by 1 test
Evaluated by:
  • tst_ecmascripttests
647-1255
1841 checkInput(countToCheck);-
1842 currentCountAlreadyChecked += countToCheck;-
1843 }
executed 1255 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1255
1844-
1845 for (unsigned i = 0; i < alternative->m_terms.size(); ++i) {
i < alternativ...m_terms.size()Description
TRUEevaluated 4790 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1904 times by 1 test
Evaluated by:
  • tst_ecmascripttests
1904-4790
1846 PatternTerm& term = alternative->m_terms[i];-
1847-
1848 switch (term.type) {-
1849 case PatternTerm::TypeAssertionBOL:
executed 24 times by 1 test: case PatternTerm::TypeAssertionBOL:
Executed by:
  • tst_ecmascripttests
24
1850 assertionBOL(currentCountAlreadyChecked - term.inputPosition);-
1851 break;
executed 24 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
24
1852-
1853 case PatternTerm::TypeAssertionEOL:
executed 24 times by 1 test: case PatternTerm::TypeAssertionEOL:
Executed by:
  • tst_ecmascripttests
24
1854 assertionEOL(currentCountAlreadyChecked - term.inputPosition);-
1855 break;
executed 24 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
24
1856-
1857 case PatternTerm::TypeAssertionWordBoundary:
executed 8 times by 1 test: case PatternTerm::TypeAssertionWordBoundary:
Executed by:
  • tst_ecmascripttests
8
1858 assertionWordBoundary(term.invert(), currentCountAlreadyChecked - term.inputPosition);-
1859 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
8
1860-
1861 case PatternTerm::TypePatternCharacter:
executed 1795 times by 1 test: case PatternTerm::TypePatternCharacter:
Executed by:
  • tst_ecmascripttests
1795
1862 atomPatternCharacter(term.patternCharacter, currentCountAlreadyChecked - term.inputPosition, term.frameLocation, term.quantityCount, term.quantityType);-
1863 break;
executed 1796 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
1796
1864-
1865 case PatternTerm::TypeCharacterClass:
executed 1632 times by 1 test: case PatternTerm::TypeCharacterClass:
Executed by:
  • tst_ecmascripttests
1632
1866 atomCharacterClass(term.characterClass, term.invert(), currentCountAlreadyChecked- term.inputPosition, term.frameLocation, term.quantityCount, term.quantityType);-
1867 break;
executed 1632 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
1632
1868-
1869 case PatternTerm::TypeBackReference:
executed 192 times by 1 test: case PatternTerm::TypeBackReference:
Executed by:
  • tst_ecmascripttests
192
1870 atomBackReference(term.backReferenceSubpatternId, currentCountAlreadyChecked - term.inputPosition, term.frameLocation, term.quantityCount, term.quantityType);-
1871 break;
executed 192 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
192
1872-
1873 case PatternTerm::TypeForwardReference:
executed 8 times by 1 test: case PatternTerm::TypeForwardReference:
Executed by:
  • tst_ecmascripttests
8
1874 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
8
1875-
1876 case PatternTerm::TypeParenthesesSubpattern: {
executed 1100 times by 1 test: case PatternTerm::TypeParenthesesSubpattern:
Executed by:
  • tst_ecmascripttests
1100
1877 unsigned disjunctionAlreadyCheckedCount = 0;-
1878 if (term.quantityCount == 1 && !term.parentheses.isCopy) {
term.quantityCount == 1Description
TRUEevaluated 688 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 412 times by 1 test
Evaluated by:
  • tst_ecmascripttests
!term.parentheses.isCopyDescription
TRUEevaluated 688 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
0-688
1879 unsigned alternativeFrameLocation = term.frameLocation;-
1880 // For QuantifierFixedCount we pre-check the minimum size; for greedy/non-greedy we reserve a slot in the frame.-
1881 if (term.quantityType == QuantifierFixedCount)
term.quantityT...fierFixedCountDescription
TRUEevaluated 480 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 208 times by 1 test
Evaluated by:
  • tst_ecmascripttests
208-480
1882 disjunctionAlreadyCheckedCount = term.parentheses.disjunction->m_minimumSize;
executed 480 times by 1 test: disjunctionAlreadyCheckedCount = term.parentheses.disjunction->m_minimumSize;
Executed by:
  • tst_ecmascripttests
480
1883 else-
1884 alternativeFrameLocation += YarrStackSpaceForBackTrackInfoParenthesesOnce;
executed 208 times by 1 test: alternativeFrameLocation += 1;
Executed by:
  • tst_ecmascripttests
208
1885 unsigned delegateEndInputOffset = term.inputPosition - currentCountAlreadyChecked;-
1886 atomParenthesesOnceBegin(term.parentheses.subpatternId, term.capture(), disjunctionAlreadyCheckedCount - delegateEndInputOffset, term.frameLocation, alternativeFrameLocation);-
1887 emitDisjunction(term.parentheses.disjunction, currentCountAlreadyChecked, disjunctionAlreadyCheckedCount);-
1888 atomParenthesesOnceEnd(delegateEndInputOffset, term.frameLocation, term.quantityCount, term.quantityType);-
1889 } else if (term.parentheses.isTerminal) {
executed 688 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
term.parentheses.isTerminalDescription
TRUEnever evaluated
FALSEevaluated 412 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-688
1890 unsigned delegateEndInputOffset = term.inputPosition - currentCountAlreadyChecked;-
1891 atomParenthesesTerminalBegin(term.parentheses.subpatternId, term.capture(), disjunctionAlreadyCheckedCount - delegateEndInputOffset, term.frameLocation, term.frameLocation + YarrStackSpaceForBackTrackInfoParenthesesOnce);-
1892 emitDisjunction(term.parentheses.disjunction, currentCountAlreadyChecked, disjunctionAlreadyCheckedCount);-
1893 atomParenthesesTerminalEnd(delegateEndInputOffset, term.frameLocation, term.quantityCount, term.quantityType);-
1894 } else {
never executed: end of block
0
1895 unsigned delegateEndInputOffset = term.inputPosition - currentCountAlreadyChecked;-
1896 atomParenthesesSubpatternBegin(term.parentheses.subpatternId, term.capture(), disjunctionAlreadyCheckedCount - delegateEndInputOffset, term.frameLocation, 0);-
1897 emitDisjunction(term.parentheses.disjunction, currentCountAlreadyChecked, 0);-
1898 atomParenthesesSubpatternEnd(term.parentheses.lastSubpatternId, delegateEndInputOffset, term.frameLocation, term.quantityCount, term.quantityType, term.parentheses.disjunction->m_callFrameSize);-
1899 }
executed 412 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
412
1900 break;
executed 1100 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
1100
1901 }-
1902-
1903 case PatternTerm::TypeParentheticalAssertion: {
executed 8 times by 1 test: case PatternTerm::TypeParentheticalAssertion:
Executed by:
  • tst_ecmascripttests
8
1904 unsigned alternativeFrameLocation = term.frameLocation + YarrStackSpaceForBackTrackInfoParentheticalAssertion;-
1905-
1906 ASSERT(currentCountAlreadyChecked >= static_cast<unsigned>(term.inputPosition));-
1907 unsigned positiveInputOffset = currentCountAlreadyChecked - static_cast<unsigned>(term.inputPosition);-
1908 unsigned uncheckAmount = 0;-
1909 if (positiveInputOffset > term.parentheses.disjunction->m_minimumSize) {
positiveInputO...>m_minimumSizeDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-8
1910 uncheckAmount = positiveInputOffset - term.parentheses.disjunction->m_minimumSize;-
1911 uncheckInput(uncheckAmount);-
1912 currentCountAlreadyChecked -= uncheckAmount;-
1913 }
never executed: end of block
0
1914-
1915 atomParentheticalAssertionBegin(term.parentheses.subpatternId, term.invert(), term.frameLocation, alternativeFrameLocation);-
1916 emitDisjunction(term.parentheses.disjunction, currentCountAlreadyChecked, positiveInputOffset - uncheckAmount);-
1917 atomParentheticalAssertionEnd(0, term.frameLocation, term.quantityCount, term.quantityType);-
1918 if (uncheckAmount) {
uncheckAmountDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-8
1919 checkInput(uncheckAmount);-
1920 currentCountAlreadyChecked += uncheckAmount;-
1921 }
never executed: end of block
0
1922 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
8
1923 }-
1924-
1925 case PatternTerm::TypeDotStarEnclosure:
never executed: case PatternTerm::TypeDotStarEnclosure:
0
1926 assertionDotStarEnclosure(term.anchors.bolAnchor, term.anchors.eolAnchor);-
1927 break;
never executed: break;
0
1928 }-
1929 }
executed 4791 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
4791
1930 }
executed 1904 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1904
1931 }
executed 1316 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1316
1932-
1933private:-
1934 YarrPattern& m_pattern;-
1935 OwnPtr<ByteDisjunction> m_bodyDisjunction;-
1936 unsigned m_currentAlternativeIndex;-
1937 Vector<ParenthesesStackEntry> m_parenthesesStack;-
1938 Vector<OwnPtr<ByteDisjunction> > m_allParenthesesInfo;-
1939};-
1940-
1941PassOwnPtr<BytecodePattern> byteCompile(YarrPattern& pattern, BumpPointerAllocator* allocator)-
1942{-
1943 return ByteCompiler(pattern).compile(allocator);
executed 208 times by 1 test: return ByteCompiler(pattern).compile(allocator);
Executed by:
  • tst_ecmascripttests
208
1944}-
1945-
1946unsigned interpret(BytecodePattern* bytecode, const String& input, unsigned start, unsigned* output)-
1947{-
1948 if (input.is8Bit())
input.is8Bit()Description
TRUEnever evaluated
FALSEnever evaluated
0
1949 return Interpreter<LChar>(bytecode, output, input.characters8(), input.length(), start).interpret();
never executed: return Interpreter<LChar>(bytecode, output, input.characters8(), input.length(), start).interpret();
0
1950 return Interpreter<UChar>(bytecode, output, input.characters16(), input.length(), start).interpret();
never executed: return Interpreter<UChar>(bytecode, output, input.characters16(), input.length(), start).interpret();
0
1951}-
1952-
1953unsigned interpret(BytecodePattern* bytecode, const LChar* input, unsigned length, unsigned start, unsigned* output)-
1954{-
1955 return Interpreter<LChar>(bytecode, output, input, length, start).interpret();
never executed: return Interpreter<LChar>(bytecode, output, input, length, start).interpret();
0
1956}-
1957-
1958unsigned interpret(BytecodePattern* bytecode, const UChar* input, unsigned length, unsigned start, unsigned* output)-
1959{-
1960 return Interpreter<UChar>(bytecode, output, input, length, start).interpret();
executed 216 times by 1 test: return Interpreter<UChar>(bytecode, output, input, length, start).interpret();
Executed by:
  • tst_ecmascripttests
216
1961}-
1962-
1963// These should be the same for both UChar & LChar.-
1964COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoPatternCharacter) == (YarrStackSpaceForBackTrackInfoPatternCharacter * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoPatternCharacter);-
1965COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoCharacterClass) == (YarrStackSpaceForBackTrackInfoCharacterClass * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoCharacterClass);-
1966COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoBackReference) == (YarrStackSpaceForBackTrackInfoBackReference * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoBackReference);-
1967COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoAlternative) == (YarrStackSpaceForBackTrackInfoAlternative * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoAlternative);-
1968COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoParentheticalAssertion) == (YarrStackSpaceForBackTrackInfoParentheticalAssertion * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParentheticalAssertion);-
1969COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoParenthesesOnce) == (YarrStackSpaceForBackTrackInfoParenthesesOnce * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParenthesesOnce);-
1970COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoParentheses) == (YarrStackSpaceForBackTrackInfoParentheses * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParentheses);-
1971-
1972-
1973} }-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0