OpenCoverage

qv4globalobject.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4globalobject.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQml module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qv4globalobject_p.h"-
41#include <private/qv4mm_p.h>-
42#include "qv4value_p.h"-
43#include "qv4context_p.h"-
44#include "qv4function_p.h"-
45#include "qv4debugging_p.h"-
46#include "qv4profiling_p.h"-
47#include "qv4script_p.h"-
48#include "qv4scopedvalue_p.h"-
49#include "qv4string_p.h"-
50#include "qv4jscall_p.h"-
51-
52#include <private/qqmljsengine_p.h>-
53#include <private/qqmljslexer_p.h>-
54#include <private/qqmljsparser_p.h>-
55#include <private/qqmljsast_p.h>-
56#include <qv4codegen_p.h>-
57#include "private/qlocale_tools_p.h"-
58#include "private/qtools_p.h"-
59-
60#include <QtCore/QDebug>-
61#include <QtCore/QString>-
62#include <iostream>-
63#include "qv4alloca_p.h"-
64-
65#include <wtf/MathExtras.h>-
66-
67using namespace QV4;-
68using QtMiscUtils::toHexUpper;-
69using QtMiscUtils::fromHex;-
70-
71static QString escape(const QString &input)-
72{-
73 QString output;-
74 output.reserve(input.size() * 3);-
75 const int length = input.length();-
76 for (int i = 0; i < length; ++i) {
i < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
77 ushort uc = input.at(i).unicode();-
78 if (uc < 0x100) {
uc < 0x100Description
TRUEnever evaluated
FALSEnever evaluated
0
79 if ( (uc > 0x60 && uc < 0x7B)
uc > 0x60Description
TRUEnever evaluated
FALSEnever evaluated
uc < 0x7BDescription
TRUEnever evaluated
FALSEnever evaluated
0
80 || (uc > 0x3F && uc < 0x5B)
uc > 0x3FDescription
TRUEnever evaluated
FALSEnever evaluated
uc < 0x5BDescription
TRUEnever evaluated
FALSEnever evaluated
0
81 || (uc > 0x2C && uc < 0x3A)
uc > 0x2CDescription
TRUEnever evaluated
FALSEnever evaluated
uc < 0x3ADescription
TRUEnever evaluated
FALSEnever evaluated
0
82 || (uc == 0x2A)
(uc == 0x2A)Description
TRUEnever evaluated
FALSEnever evaluated
0
83 || (uc == 0x2B)
(uc == 0x2B)Description
TRUEnever evaluated
FALSEnever evaluated
0
84 || (uc == 0x5F)) {
(uc == 0x5F)Description
TRUEnever evaluated
FALSEnever evaluated
0
85 output.append(QChar(uc));-
86 } else {
never executed: end of block
0
87 output.append('%');-
88 output.append(QLatin1Char(toHexUpper(uc >> 4)));-
89 output.append(QLatin1Char(toHexUpper(uc)));-
90 }
never executed: end of block
0
91 } else {-
92 output.append('%');-
93 output.append('u');-
94 output.append(QLatin1Char(toHexUpper(uc >> 12)));-
95 output.append(QLatin1Char(toHexUpper(uc >> 8)));-
96 output.append(QLatin1Char(toHexUpper(uc >> 4)));-
97 output.append(QLatin1Char(toHexUpper(uc)));-
98 }
never executed: end of block
0
99 }-
100 return output;
never executed: return output;
0
101}-
102-
103static QString unescape(const QString &input)-
104{-
105 QString result;-
106 result.reserve(input.length());-
107 int i = 0;-
108 const int length = input.length();-
109 while (i < length) {
i < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
110 QChar c = input.at(i++);-
111 if ((c == '%') && (i + 1 < length)) {
(c == '%')Description
TRUEnever evaluated
FALSEnever evaluated
(i + 1 < length)Description
TRUEnever evaluated
FALSEnever evaluated
0
112 QChar a = input.at(i);-
113 if ((a == 'u') && (i + 4 < length)) {
(a == 'u')Description
TRUEnever evaluated
FALSEnever evaluated
(i + 4 < length)Description
TRUEnever evaluated
FALSEnever evaluated
0
114 int d3 = fromHex(input.at(i+1).unicode());-
115 int d2 = fromHex(input.at(i+2).unicode());-
116 int d1 = fromHex(input.at(i+3).unicode());-
117 int d0 = fromHex(input.at(i+4).unicode());-
118 if ((d3 != -1) && (d2 != -1) && (d1 != -1) && (d0 != -1)) {
(d3 != -1)Description
TRUEnever evaluated
FALSEnever evaluated
(d2 != -1)Description
TRUEnever evaluated
FALSEnever evaluated
(d1 != -1)Description
TRUEnever evaluated
FALSEnever evaluated
(d0 != -1)Description
TRUEnever evaluated
FALSEnever evaluated
0
119 ushort uc = ushort((d3 << 12) | (d2 << 8) | (d1 << 4) | d0);-
120 result.append(QChar(uc));-
121 i += 5;-
122 } else {
never executed: end of block
0
123 result.append(c);-
124 }
never executed: end of block
0
125 } else {-
126 int d1 = fromHex(a.unicode());-
127 int d0 = fromHex(input.at(i+1).unicode());-
128 if ((d1 != -1) && (d0 != -1)) {
(d1 != -1)Description
TRUEnever evaluated
FALSEnever evaluated
(d0 != -1)Description
TRUEnever evaluated
FALSEnever evaluated
0
129 c = (d1 << 4) | d0;-
130 i += 2;-
131 }
never executed: end of block
0
132 result.append(c);-
133 }
never executed: end of block
0
134 } else {-
135 result.append(c);-
136 }
never executed: end of block
0
137 }-
138 return result;
never executed: return result;
0
139}-
140-
141static const char uriReserved[] = ";/?:@&=+$,#";-
142static const char uriUnescaped[] = "-_.!~*'()";-
143static const char uriUnescapedReserved[] = "-_.!~*'();/?:@&=+$,#";-
144-
145static void addEscapeSequence(QString &output, uchar ch)-
146{-
147 output.append(QLatin1Char('%'));-
148 output.append(QLatin1Char(toHexUpper(ch >> 4)));-
149 output.append(QLatin1Char(toHexUpper(ch & 0xf)));-
150}
executed 1697097 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qquickloader
1697097
151-
152static QString encode(const QString &input, const char *unescapedSet, bool *ok)-
153{-
154 *ok = true;-
155 QString output;-
156 const int length = input.length();-
157 int i = 0;-
158 while (i < length) {
i < lengthDescription
TRUEevaluated 658849 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
FALSEevaluated 554790 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
554790-658849
159 const QChar c = input.at(i);-
160 bool escape = true;-
161 if ((c.unicode() >= 'a' && c.unicode() <= 'z') ||
c.unicode() >= 'a'Description
TRUEevaluated 648366 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
FALSEevaluated 10314 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
c.unicode() <= 'z'Description
TRUEevaluated 2808 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
FALSEevaluated 645702 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2808-648366
162 (c.unicode() >= 'A' && c.unicode() <= 'Z') ||
c.unicode() >= 'A'Description
TRUEevaluated 654780 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
FALSEevaluated 1452 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
c.unicode() <= 'Z'Description
TRUEevaluated 8754 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
FALSEevaluated 645675 times by 1 test
Evaluated by:
  • tst_ecmascripttests
1452-654780
163 (c.unicode() >= '0' && c.unicode() <= '9')) {
c.unicode() >= '0'Description
TRUEevaluated 646566 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1032 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
c.unicode() <= '9'Description
TRUEevaluated 192 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 645782 times by 1 test
Evaluated by:
  • tst_ecmascripttests
192-646566
164 escape = false;-
165 } else {
executed 11754 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qquickloader
11754
166 const char *r = unescapedSet;-
167 while (*r) {
*rDescription
TRUEevaluated 9363509 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
FALSEevaluated 644990 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
644990-9363509
168 if (*r == c.unicode()) {
*r == c.unicode()Description
TRUEevaluated 582 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
FALSEevaluated 9361162 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
582-9361162
169 escape = false;-
170 break;
executed 582 times by 2 tests: break;
Executed by:
  • tst_ecmascripttests
  • tst_qquickloader
582
171 }-
172 ++r;-
173 }
executed 9361076 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qquickloader
9361076
174 }
executed 646876 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qquickloader
646876
175 if (escape) {
escapeDescription
TRUEevaluated 646386 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
FALSEevaluated 12336 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
12336-646386
176 uint uc = c.unicode();-
177 if ((uc >= 0xDC00) && (uc <= 0xDFFF)) {
(uc >= 0xDC00)Description
TRUEevaluated 81920 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 564777 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
(uc <= 0xDFFF)Description
TRUEevaluated 16384 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 65536 times by 1 test
Evaluated by:
  • tst_ecmascripttests
16384-564777
178 *ok = false;-
179 break;
executed 16384 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
16384
180 }-
181 if (!((uc < 0xD800) || (uc > 0xDBFF))) {
(uc < 0xD800)Description
TRUEevaluated 442216 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
FALSEevaluated 188412 times by 1 test
Evaluated by:
  • tst_ecmascripttests
(uc > 0xDBFF)Description
TRUEevaluated 65536 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 122877 times by 1 test
Evaluated by:
  • tst_ecmascripttests
65536-442216
182 ++i;-
183 if (i == length) {
i == lengthDescription
TRUEevaluated 16382 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 106496 times by 1 test
Evaluated by:
  • tst_ecmascripttests
16382-106496
184 *ok = false;-
185 break;
executed 16382 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
16382
186 }-
187 const uint uc2 = input.at(i).unicode();-
188 if ((uc2 < 0xDC00) || (uc2 > 0xDFFF)) {
(uc2 < 0xDC00)Description
TRUEevaluated 40960 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 65536 times by 1 test
Evaluated by:
  • tst_ecmascripttests
(uc2 > 0xDFFF)Description
TRUEevaluated 16384 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 49152 times by 1 test
Evaluated by:
  • tst_ecmascripttests
16384-65536
189 *ok = false;-
190 break;
executed 57344 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
57344
191 }-
192 uc = ((uc - 0xD800) * 0x400) + (uc2 - 0xDC00) + 0x10000;-
193 }
executed 49152 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
49152
194 if (uc < 0x80) {
uc < 0x80Description
TRUEevaluated 830 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
FALSEevaluated 555606 times by 1 test
Evaluated by:
  • tst_ecmascripttests
830-555606
195 addEscapeSequence(output, (uchar)uc);-
196 } else {
executed 830 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qquickloader
830
197 if (uc < 0x0800) {
uc < 0x0800Description
TRUEevaluated 15656 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 536410 times by 1 test
Evaluated by:
  • tst_ecmascripttests
15656-536410
198 addEscapeSequence(output, 0xc0 | ((uchar) (uc >> 6)));-
199 } else {
executed 15656 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
15656
200-
201 if (QChar::requiresSurrogates(uc)) {
QChar::requiresSurrogates(uc)Description
TRUEevaluated 49152 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 488625 times by 1 test
Evaluated by:
  • tst_ecmascripttests
49152-488625
202 addEscapeSequence(output, 0xf0 | ((uchar) (uc >> 18)));-
203 addEscapeSequence(output, 0x80 | (((uchar) (uc >> 12)) & 0x3f));-
204 } else {
executed 49152 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
49152
205 addEscapeSequence(output, 0xe0 | (((uchar) (uc >> 12)) & 0x3f));-
206 }
executed 488898 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
488898
207 addEscapeSequence(output, 0x80 | (((uchar) (uc >> 6)) & 0x3f));-
208 }
executed 538546 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
538546
209 addEscapeSequence(output, 0x80 | ((uchar) (uc&0x3f)));-
210 }
executed 554633 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
554633
211 } else {-
212 output.append(c);-
213 }
executed 12336 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qquickloader
12336
214 ++i;-
215 }
executed 567865 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_qquickloader
567865
216 if (i != length)
i != lengthDescription
TRUEevaluated 73728 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 570704 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
73728-570704
217 *ok = false;
executed 73728 times by 1 test: *ok = false;
Executed by:
  • tst_ecmascripttests
73728
218 return output;
executed 641194 times by 2 tests: return output;
Executed by:
  • tst_ecmascripttests
  • tst_qquickloader
641194
219}-
220-
221enum DecodeMode {-
222 DecodeAll,-
223 DecodeNonReserved-
224};-
225-
226static QString decode(const QString &input, DecodeMode decodeMode, bool *ok)-
227{-
228 *ok = true;-
229 QString output;-
230 output.reserve(input.length());-
231 const int length = input.length();-
232 int i = 0;-
233 const QChar percent = QLatin1Char('%');-
234 while (i < length) {
i < lengthDescription
TRUEevaluated 13068743 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 8861992 times by 1 test
Evaluated by:
  • tst_ecmascripttests
8861992-13068743
235 const QChar ch = input.at(i);-
236 if (ch == percent) {
ch == percentDescription
TRUEevaluated 12541623 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 527240 times by 1 test
Evaluated by:
  • tst_ecmascripttests
527240-12541623
237 int start = i;-
238 if (i + 2 >= length)
i + 2 >= lengthDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 12527160 times by 1 test
Evaluated by:
  • tst_ecmascripttests
32-12527160
239 goto error;
executed 32 times by 1 test: goto error;
Executed by:
  • tst_ecmascripttests
32
240-
241 int d1 = fromHex(input.at(i+1).unicode());-
242 int d0 = fromHex(input.at(i+2).unicode());-
243 if ((d1 == -1) || (d0 == -1))
(d1 == -1)Description
TRUEevaluated 524016 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 12037150 times by 1 test
Evaluated by:
  • tst_ecmascripttests
(d0 == -1)Description
TRUEevaluated 524016 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 11582608 times by 1 test
Evaluated by:
  • tst_ecmascripttests
524016-12037150
244 goto error;
executed 1025215 times by 1 test: goto error;
Executed by:
  • tst_ecmascripttests
1025215
245-
246 int b = (d1 << 4) | d0;-
247 i += 2;-
248 if (b & 0x80) {
b & 0x80Description
TRUEevaluated 11596958 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1900 times by 1 test
Evaluated by:
  • tst_ecmascripttests
1900-11596958
249 int uc;-
250 int min_uc;-
251 int need;-
252 if ((b & 0xe0) == 0xc0) {
(b & 0xe0) == 0xc0Description
TRUEevaluated 589845 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 10979896 times by 1 test
Evaluated by:
  • tst_ecmascripttests
589845-10979896
253 uc = b & 0x1f;-
254 need = 1;-
255 min_uc = 0x80;-
256 } else if ((b & 0xf0) == 0xe0) {
executed 589843 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
(b & 0xf0) == 0xe0Description
TRUEevaluated 1577624 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 9457071 times by 1 test
Evaluated by:
  • tst_ecmascripttests
589843-9457071
257 uc = b & 0x0f;-
258 need = 2;-
259 min_uc = 0x800;-
260 } else if ((b & 0xf8) == 0xf0) {
executed 1571449 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
(b & 0xf8) == 0xf0Description
TRUEevaluated 9468236 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 576 times by 1 test
Evaluated by:
  • tst_ecmascripttests
576-9468236
261 uc = b & 0x07;-
262 need = 3;-
263 min_uc = 0x10000;-
264 } else {
executed 9453701 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
9453701
265 goto error;
executed 575 times by 1 test: goto error;
Executed by:
  • tst_ecmascripttests
575
266 }-
267-
268 if (i + (3 * need) >= length)
i + (3 * need) >= lengthDescription
TRUEevaluated 2099 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 11577598 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2099-11577598
269 goto error;
executed 2099 times by 1 test: goto error;
Executed by:
  • tst_ecmascripttests
2099
270-
271 for (int j = 0; j < need; ++j) {
j < needDescription
TRUEevaluated 29854783 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 8357808 times by 1 test
Evaluated by:
  • tst_ecmascripttests
8357808-29854783
272 ++i;-
273 if (input.at(i) != percent)
input.at(i) != percentDescription
TRUEevaluated 702 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 29913525 times by 1 test
Evaluated by:
  • tst_ecmascripttests
702-29913525
274 goto error;
executed 702 times by 1 test: goto error;
Executed by:
  • tst_ecmascripttests
702
275-
276 d1 = fromHex(input.at(i+1).unicode());-
277 d0 = fromHex(input.at(i+2).unicode());-
278 if ((d1 == -1) || (d0 == -1))
(d1 == -1)Description
TRUEevaluated 3135070 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 26776527 times by 1 test
Evaluated by:
  • tst_ecmascripttests
(d0 == -1)Description
TRUEnever evaluated
FALSEevaluated 26804354 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-26804354
279 goto error;
executed 3110132 times by 1 test: goto error;
Executed by:
  • tst_ecmascripttests
3110132
280-
281 b = (d1 << 4) | d0;-
282 if ((b & 0xC0) != 0x80)
(b & 0xC0) != 0x80Description
TRUEevaluated 135157 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 26679004 times by 1 test
Evaluated by:
  • tst_ecmascripttests
135157-26679004
283 goto error;
executed 135150 times by 1 test: goto error;
Executed by:
  • tst_ecmascripttests
135150
284-
285 i += 2;-
286 uc = (uc << 6) + (b & 0x3f);-
287 }
executed 26667996 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
26667996
288 if (uc < min_uc)
uc < min_ucDescription
TRUEnever evaluated
FALSEevaluated 8362624 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-8362624
289 goto error;
never executed: goto error;
0
290-
291 if (uc < 0x10000) {
uc < 0x10000Description
TRUEevaluated 507176 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 7857551 times by 1 test
Evaluated by:
  • tst_ecmascripttests
507176-7857551
292 output.append(QChar(uc));-
293 } else {
executed 507176 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
507176
294 if (uc > 0x10FFFF)
uc > 0x10FFFFDescription
TRUEnever evaluated
FALSEevaluated 7838287 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-7838287
295 goto error;
never executed: goto error;
0
296-
297 ushort l = ushort(((uc - 0x10000) & 0x3FF) + 0xDC00);-
298 ushort h = ushort((((uc - 0x10000) >> 10) & 0x3FF) + 0xD800);-
299 output.append(QChar(h));-
300 output.append(QChar(l));-
301 }
executed 7821960 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
7821960
302 } else {-
303 if (decodeMode == DecodeNonReserved && b <= 0x40) {
decodeMode == ...odeNonReservedDescription
TRUEevaluated 924 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 976 times by 1 test
Evaluated by:
  • tst_ecmascripttests
b <= 0x40Description
TRUEevaluated 444 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 480 times by 1 test
Evaluated by:
  • tst_ecmascripttests
444-976
304 const char *r = uriReserved;-
305 while (*r) {
*rDescription
TRUEevaluated 3848 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 236 times by 1 test
Evaluated by:
  • tst_ecmascripttests
236-3848
306 if (*r == b)
*r == bDescription
TRUEevaluated 208 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 3640 times by 1 test
Evaluated by:
  • tst_ecmascripttests
208-3640
307 break;
executed 208 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
208
308 ++r;-
309 }
executed 3640 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
3640
310 if (*r)
*rDescription
TRUEevaluated 208 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 236 times by 1 test
Evaluated by:
  • tst_ecmascripttests
208-236
311 output.append(input.midRef(start, i - start + 1));
executed 208 times by 1 test: output.append(input.midRef(start, i - start + 1));
Executed by:
  • tst_ecmascripttests
208
312 else-
313 output.append(QChar(b));
executed 236 times by 1 test: output.append(QChar(b));
Executed by:
  • tst_ecmascripttests
236
314 } else {-
315 output.append(QChar(b));-
316 }
executed 1456 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1456
317 }-
318 } else {-
319 output.append(ch);-
320 }
executed 527240 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
527240
321 ++i;-
322 }
executed 8868322 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
8868322
323 if (i != length)
i != lengthDescription
TRUEnever evaluated
FALSEevaluated 8874845 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-8874845
324 *ok = false;
never executed: *ok = false;
0
325 return output;
executed 8829052 times by 1 test: return output;
Executed by:
  • tst_ecmascripttests
8829052
326 error:-
327 *ok = false;-
328 return QString();
executed 4219004 times by 1 test: return QString();
Executed by:
  • tst_ecmascripttests
4219004
329}-
330-
331DEFINE_OBJECT_VTABLE(EvalFunction);-
332-
333void Heap::EvalFunction::init(QV4::ExecutionContext *scope)-
334{-
335 Scope s(scope);-
336 Heap::FunctionObject::init(scope, s.engine->id_eval());-
337 ScopedFunctionObject f(s, this);-
338 f->defineReadonlyConfigurableProperty(s.engine->id_length(), Primitive::fromInt32(1));-
339}
executed 98530 times by 153 tests: end of block
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_parserstress
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlecmascript
  • tst_qqmlenginecleanup
  • ...
98530
340-
341ReturnedValue EvalFunction::evalCall(const Value *, const Value *argv, int argc, bool directCall) const-
342{-
343 if (argc < 1)
argc < 1Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1579011 times by 7 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
12-1579011
344 return Encode::undefined();
executed 12 times by 1 test: return Encode::undefined();
Executed by:
  • tst_ecmascripttests
12
345-
346 ExecutionEngine *v4 = engine();-
347 bool isStrict = v4->currentStackFrame->v4Function->isStrict();-
348-
349 Scope scope(v4);-
350 ScopedContext ctx(scope, v4->currentContext());-
351-
352 if (!directCall) {
!directCallDescription
TRUEevaluated 60 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1578622 times by 7 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
60-1578622
353 // the context for eval should be the global scope-
354 ctx = v4->scriptContext();-
355 }
executed 60 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
60
356-
357 String *scode = argv[0].stringValue();-
358 if (!scode)
!scodeDescription
TRUEevaluated 72 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1578956 times by 7 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
72-1578956
359 return argv[0].asReturnedValue();
executed 72 times by 1 test: return argv[0].asReturnedValue();
Executed by:
  • tst_ecmascripttests
72
360-
361 const QString code = scode->toQString();-
362 bool inheritContext = !isStrict;-
363-
364 Script script(ctx, QV4::Compiler::ContextType::Eval, code, QStringLiteral("eval code"));
executed 1580111 times by 7 tests: return qstring_literal_temp;
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
1580111
365 script.strictMode = (directCall && isStrict);
directCallDescription
TRUEevaluated 1579465 times by 7 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
FALSEevaluated 60 times by 1 test
Evaluated by:
  • tst_ecmascripttests
isStrictDescription
TRUEevaluated 788850 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
FALSEevaluated 790836 times by 7 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
60-1579465
366 script.inheritContext = inheritContext;-
367 script.parse();-
368 if (v4->hasException)
v4->hasExceptionDescription
TRUEevaluated 569 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1578345 times by 7 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
569-1578345
369 return Encode::undefined();
executed 570 times by 1 test: return Encode::undefined();
Executed by:
  • tst_ecmascripttests
570
370-
371 Function *function = script.function();-
372 if (!function)
!functionDescription
TRUEevaluated 521286 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1055169 times by 7 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
521286-1055169
373 return Encode::undefined();
executed 519155 times by 1 test: return Encode::undefined();
Executed by:
  • tst_ecmascripttests
519155
374-
375 if (function->isStrict() || isStrict) {
function->isStrict()Description
TRUEevaluated 526402 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
FALSEevaluated 528749 times by 7 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
isStrictDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 528753 times by 7 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
28-528753
376 ScopedFunctionObject e(scope, FunctionObject::createScriptFunction(ctx, function));-
377 ScopedValue thisObject(scope, directCall ? scope.engine->currentStackFrame->thisObject() : scope.engine->globalObject->asReturnedValue());-
378 return e->call(thisObject, nullptr, 0);
executed 526429 times by 2 tests: return e->call(thisObject, nullptr, 0);
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
526429
379 }-
380-
381 ScopedValue thisObject(scope, scope.engine->currentStackFrame->thisObject());-
382-
383 return function->call(thisObject, nullptr, 0, ctx);
executed 528709 times by 7 tests: return function->call(thisObject, nullptr, 0, ctx);
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
528709
384}-
385-
386-
387ReturnedValue EvalFunction::virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)-
388{-
389 // indirect call-
390 return static_cast<const EvalFunction *>(f)->evalCall(thisObject, argv, argc, false);
executed 64 times by 1 test: return static_cast<const EvalFunction *>(f)->evalCall(thisObject, argv, argc, false);
Executed by:
  • tst_ecmascripttests
64
391}-
392-
393-
394static inline int toInt(const QChar &qc, int R)-
395{-
396 ushort c = qc.unicode();-
397 int v = -1;-
398 if (c >= '0' && c <= '9')
c >= '0'Description
TRUEevaluated 806000 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
FALSEevaluated 744 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
c <= '9'Description
TRUEevaluated 271464 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
FALSEevaluated 534536 times by 1 test
Evaluated by:
  • tst_ecmascripttests
744-806000
399 v = c - '0';
executed 271464 times by 2 tests: v = c - '0';
Executed by:
  • tst_ecmascripttests
  • tst_examples
271464
400 else if (c >= 'A' && c <= 'Z')
c >= 'A'Description
TRUEevaluated 534508 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 772 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
c <= 'Z'Description
TRUEevaluated 267396 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 267112 times by 1 test
Evaluated by:
  • tst_ecmascripttests
772-534508
401 v = c - 'A' + 10;
executed 267396 times by 1 test: v = c - 'A' + 10;
Executed by:
  • tst_ecmascripttests
267396
402 else if (c >= 'a' && c <= 'z')
c >= 'a'Description
TRUEevaluated 267084 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 800 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
c <= 'z'Description
TRUEevaluated 5496 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 261588 times by 1 test
Evaluated by:
  • tst_ecmascripttests
800-267084
403 v = c - 'a' + 10;
executed 5496 times by 1 test: v = c - 'a' + 10;
Executed by:
  • tst_ecmascripttests
5496
404 if (v >= 0 && v < R)
v >= 0Description
TRUEevaluated 544356 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
FALSEevaluated 262388 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
v < RDescription
TRUEevaluated 544000 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
FALSEevaluated 356 times by 1 test
Evaluated by:
  • tst_ecmascripttests
356-544356
405 return v;
executed 544000 times by 2 tests: return v;
Executed by:
  • tst_ecmascripttests
  • tst_examples
544000
406 else-
407 return -1;
executed 262744 times by 2 tests: return -1;
Executed by:
  • tst_ecmascripttests
  • tst_examples
262744
408}-
409-
410// parseInt [15.1.2.2]-
411ReturnedValue GlobalFunctions::method_parseInt(const FunctionObject *b, const Value *, const Value *argv, int argc)-
412{-
413 Scope scope(b);-
414 ScopedValue inputString(scope, argc ? argv[0] : Primitive::undefinedValue());-
415 ScopedValue radix(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());-
416 int R = radix->isUndefined() ? 0 : radix->toInt32();
radix->isUndefined()Description
TRUEevaluated 812 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
FALSEevaluated 266664 times by 1 test
Evaluated by:
  • tst_ecmascripttests
812-266664
417-
418 // [15.1.2.2] step by step:-
419 QString trimmed = inputString->toQString().trimmed(); // 1 + 2-
420 CHECK_EXCEPTION();
executed 16 times by 1 test: return QV4::Encode::undefined();
Executed by:
  • tst_ecmascripttests
scope.hasException()Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 267460 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
16-267460
421-
422 const QChar *pos = trimmed.constData();-
423 const QChar *end = pos + trimmed.length();-
424-
425 int sign = 1; // 3-
426 if (pos != end) {
pos != endDescription
TRUEevaluated 267352 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
FALSEevaluated 108 times by 1 test
Evaluated by:
  • tst_ecmascripttests
108-267352
427 if (*pos == QLatin1Char('-'))
*pos == QLatin1Char('-')Description
TRUEevaluated 972 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 266380 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
972-266380
428 sign = -1; // 4
executed 972 times by 1 test: sign = -1;
Executed by:
  • tst_ecmascripttests
972
429 if (*pos == QLatin1Char('-') || *pos == QLatin1Char('+'))
*pos == QLatin1Char('-')Description
TRUEevaluated 972 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 266380 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
*pos == QLatin1Char('+')Description
TRUEevaluated 700 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 265680 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
700-266380
430 ++pos; // 5
executed 1672 times by 1 test: ++pos;
Executed by:
  • tst_ecmascripttests
1672
431 }
executed 267352 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_examples
267352
432 bool stripPrefix = true; // 7-
433 if (R) { // 8
RDescription
TRUEevaluated 266464 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 996 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
996-266464
434 if (R < 2 || R > 36)
R < 2Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 266408 times by 1 test
Evaluated by:
  • tst_ecmascripttests
R > 36Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 266356 times by 1 test
Evaluated by:
  • tst_ecmascripttests
52-266408
435 RETURN_RESULT(Encode(std::numeric_limits<double>::quiet_NaN())); // 8a
executed 108 times by 1 test: return QV4::Encode(Encode(std::numeric_limits<double>::quiet_NaN()));
Executed by:
  • tst_ecmascripttests
108
436 if (R != 16)
R != 16Description
TRUEevaluated 266028 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 328 times by 1 test
Evaluated by:
  • tst_ecmascripttests
328-266028
437 stripPrefix = false; // 8b
executed 266028 times by 1 test: stripPrefix = false;
Executed by:
  • tst_ecmascripttests
266028
438 } else { // 9
executed 266356 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
266356
439 R = 10; // 9a-
440 }
executed 996 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_examples
996
441 if (stripPrefix) { // 10
stripPrefixDescription
TRUEevaluated 1324 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
FALSEevaluated 266028 times by 1 test
Evaluated by:
  • tst_ecmascripttests
1324-266028
442 if ((end - pos >= 2)
(end - pos >= 2)Description
TRUEevaluated 504 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
FALSEevaluated 820 times by 1 test
Evaluated by:
  • tst_ecmascripttests
504-820
443 && (pos[0] == QLatin1Char('0'))
(pos[0] == QLatin1Char('0'))Description
TRUEevaluated 228 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 276 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
228-276
444 && (pos[1] == QLatin1Char('x') || pos[1] == QLatin1Char('X'))) { // 10a
pos[1] == QLatin1Char('x')Description
TRUEevaluated 140 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 88 times by 1 test
Evaluated by:
  • tst_ecmascripttests
pos[1] == QLatin1Char('X')Description
TRUEevaluated 84 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-140
445 pos += 2;-
446 R = 16;-
447 }
executed 224 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
224
448 }
executed 1324 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_examples
1324
449 // 11: Z is progressively built below-
450 // 13: this is handled by the toInt function-
451 if (pos == end) // 12
pos == endDescription
TRUEevaluated 108 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 267244 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
108-267244
452 RETURN_RESULT(Encode(std::numeric_limits<double>::quiet_NaN()));
executed 108 times by 1 test: return QV4::Encode(Encode(std::numeric_limits<double>::quiet_NaN()));
Executed by:
  • tst_ecmascripttests
108
453 bool overflow = false;-
454 qint64 v_overflow = 0;-
455 unsigned overflow_digit_count = 0;-
456 int d = toInt(*pos++, R);-
457 if (d == -1)
d == -1Description
TRUEevaluated 220 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 267024 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
220-267024
458 RETURN_RESULT(Encode(std::numeric_limits<double>::quiet_NaN()));
executed 220 times by 1 test: return QV4::Encode(Encode(std::numeric_limits<double>::quiet_NaN()));
Executed by:
  • tst_ecmascripttests
220
459 qint64 v = d;-
460 while (pos != end) {
pos != endDescription
TRUEevaluated 539500 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
FALSEevaluated 4500 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4500-539500
461 d = toInt(*pos++, R);-
462 if (d == -1)
d == -1Description
TRUEevaluated 262524 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
FALSEevaluated 276976 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
262524-276976
463 break;
executed 262524 times by 2 tests: break;
Executed by:
  • tst_ecmascripttests
  • tst_examples
262524
464 if (overflow) {
overflowDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 276932 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
44-276932
465 if (overflow_digit_count == 0) {
overflow_digit_count == 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
20-24
466 v_overflow = v;-
467 v = 0;-
468 }
executed 20 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
20
469 ++overflow_digit_count;-
470 v = v * R + d;-
471 } else {
executed 44 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
44
472 qint64 vNew = v * R + d;-
473 if (vNew < v) {
vNew < vDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 276912 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
20-276912
474 overflow = true;-
475 --pos;-
476 } else {
executed 20 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
20
477 v = vNew;-
478 }
executed 276912 times by 2 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_examples
276912
479 }-
480 }-
481-
482 if (overflow) {
overflowDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 267004 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
20-267004
483 double result = (double) v_overflow * pow(static_cast<double>(R), static_cast<double>(overflow_digit_count));-
484 result += v;-
485 RETURN_RESULT(Encode(sign * result));
executed 20 times by 1 test: return QV4::Encode(Encode(sign * result));
Executed by:
  • tst_ecmascripttests
20
486 } else {-
487 RETURN_RESULT(Encode(sign * (double) v)); // 15
executed 267004 times by 2 tests: return QV4::Encode(Encode(sign * (double) v));
Executed by:
  • tst_ecmascripttests
  • tst_examples
267004
488 }-
489}-
490-
491// parseFloat [15.1.2.3]-
492ReturnedValue GlobalFunctions::method_parseFloat(const FunctionObject *b, const Value *, const Value *argv, int argc)-
493{-
494 Scope scope(b);-
495 // [15.1.2.3] step by step:-
496 ScopedString inputString(scope, argc ? argv[0] : Primitive::undefinedValue(), ScopedString::Convert);-
497 CHECK_EXCEPTION();
executed 8 times by 1 test: return QV4::Encode::undefined();
Executed by:
  • tst_ecmascripttests
scope.hasException()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 263152 times by 1 test
Evaluated by:
  • tst_ecmascripttests
8-263152
498-
499 QString trimmed = inputString->toQString().trimmed(); // 2-
500-
501 // 4:-
502 if (trimmed.startsWith(QLatin1String("Infinity"))
trimmed.starts...g("Infinity"))Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 263112 times by 1 test
Evaluated by:
  • tst_ecmascripttests
40-263112
503 || trimmed.startsWith(QLatin1String("+Infinity")))
trimmed.starts...("+Infinity"))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 263108 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-263108
504 RETURN_RESULT(Encode(Q_INFINITY));
executed 44 times by 1 test: return QV4::Encode(Encode((::qInf())));
Executed by:
  • tst_ecmascripttests
44
505 if (trimmed.startsWith(QLatin1String("-Infinity")))
trimmed.starts...("-Infinity"))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 263104 times by 1 test
Evaluated by:
  • tst_ecmascripttests
4-263104
506 RETURN_RESULT(Encode(-Q_INFINITY));
executed 4 times by 1 test: return QV4::Encode(Encode(-(::qInf())));
Executed by:
  • tst_ecmascripttests
4
507 QByteArray ba = trimmed.toLatin1();-
508 bool ok;-
509 const char *begin = ba.constData();-
510 const char *end = nullptr;-
511 double d = qstrtod(begin, &end, &ok);-
512 if (end - begin == 0)
end - begin == 0Description
TRUEevaluated 212 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 262891 times by 1 test
Evaluated by:
  • tst_ecmascripttests
212-262891
513 RETURN_RESULT(Encode(std::numeric_limits<double>::quiet_NaN())); // 3
executed 212 times by 1 test: return QV4::Encode(Encode(std::numeric_limits<double>::quiet_NaN()));
Executed by:
  • tst_ecmascripttests
212
514 else-
515 RETURN_RESULT(Encode(d));
executed 262892 times by 1 test: return QV4::Encode(Encode(d));
Executed by:
  • tst_ecmascripttests
262892
516}-
517-
518/// isNaN [15.1.2.4]-
519ReturnedValue GlobalFunctions::method_isNaN(const FunctionObject *, const Value *, const Value *argv, int argc)-
520{-
521 if (!argc)
!argcDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2074 times by 4 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
4-2074
522 // undefined gets converted to NaN-
523 RETURN_RESULT(Encode(true));
executed 4 times by 1 test: return QV4::Encode(Encode(true));
Executed by:
  • tst_ecmascripttests
4
524-
525 if (argv[0].integerCompatible())
argv[0].integerCompatible()Description
TRUEevaluated 182 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquicklayouts
FALSEevaluated 1892 times by 4 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
182-1892
526 RETURN_RESULT(Encode(false));
executed 182 times by 2 tests: return QV4::Encode(Encode(false));
Executed by:
  • tst_ecmascripttests
  • tst_qquicklayouts
182
527-
528 double d = argv[0].toNumber();-
529 RETURN_RESULT(Encode((bool)std::isnan(d)));
executed 1892 times by 4 tests: return QV4::Encode(Encode((bool)std::isnan(d)));
Executed by:
  • tst_ecmascripttests
  • tst_qqmlecmascript
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
1892
530}-
531-
532/// isFinite [15.1.2.5]-
533ReturnedValue GlobalFunctions::method_isFinite(const FunctionObject *, const Value *, const Value *argv, int argc)-
534{-
535 if (!argc)
!argcDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 174 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquicklayouts
4-174
536 // undefined gets converted to NaN-
537 RETURN_RESULT(Encode(false));
executed 4 times by 1 test: return QV4::Encode(Encode(false));
Executed by:
  • tst_ecmascripttests
4
538-
539 if (argv[0].integerCompatible())
argv[0].integerCompatible()Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 150 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquicklayouts
24-150
540 RETURN_RESULT(Encode(true));
executed 24 times by 1 test: return QV4::Encode(Encode(true));
Executed by:
  • tst_ecmascripttests
24
541-
542 double d = argv[0].toNumber();-
543 RETURN_RESULT(Encode((bool)std::isfinite(d)));
executed 150 times by 2 tests: return QV4::Encode(Encode((bool)std::isfinite(d)));
Executed by:
  • tst_ecmascripttests
  • tst_qquicklayouts
150
544}-
545-
546/// decodeURI [15.1.3.1]-
547ReturnedValue GlobalFunctions::method_decodeURI(const FunctionObject *b, const Value *, const Value *argv, int argc)-
548{-
549 if (argc == 0)
argc == 0Description
TRUEnever evaluated
FALSEevaluated 6545862 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-6545862
550 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
551-
552 ExecutionEngine *v4 = b->engine();-
553 QString uriString = argv[0].toQString();-
554 bool ok;-
555 QString out = decode(uriString, DecodeNonReserved, &ok);-
556 if (!ok) {
!okDescription
TRUEevaluated 2129259 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 4445896 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2129259-4445896
557 Scope scope(v4);-
558 ScopedString s(scope, scope.engine->newString(QStringLiteral("malformed URI sequence")));
executed 2065233 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_ecmascripttests
2065233
559 RETURN_RESULT(scope.engine->throwURIError(s));
executed 2065227 times by 1 test: return QV4::Encode(scope.engine->throwURIError(s));
Executed by:
  • tst_ecmascripttests
2065227
560 }-
561-
562 RETURN_RESULT(v4->newString(out));
executed 4445724 times by 1 test: return QV4::Encode(v4->newString(out));
Executed by:
  • tst_ecmascripttests
4445724
563}-
564-
565/// decodeURIComponent [15.1.3.2]-
566ReturnedValue GlobalFunctions::method_decodeURIComponent(const FunctionObject *b, const Value *, const Value *argv, int argc)-
567{-
568 if (argc == 0)
argc == 0Description
TRUEnever evaluated
FALSEevaluated 6589277 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-6589277
569 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
570-
571 ExecutionEngine *v4 = b->engine();-
572 QString uriString = argv[0].toQString();-
573 bool ok;-
574 QString out = decode(uriString, DecodeAll, &ok);-
575 if (!ok) {
!okDescription
TRUEevaluated 2147387 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 4447800 times by 1 test
Evaluated by:
  • tst_ecmascripttests
2147387-4447800
576 Scope scope(v4);-
577 ScopedString s(scope, scope.engine->newString(QStringLiteral("malformed URI sequence")));
executed 2104002 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_ecmascripttests
2104002
578 RETURN_RESULT(scope.engine->throwURIError(s));
executed 2110048 times by 1 test: return QV4::Encode(scope.engine->throwURIError(s));
Executed by:
  • tst_ecmascripttests
2110048
579 }-
580-
581 RETURN_RESULT(v4->newString(out));
executed 4447441 times by 1 test: return QV4::Encode(v4->newString(out));
Executed by:
  • tst_ecmascripttests
4447441
582}-
583-
584/// encodeURI [15.1.3.3]-
585ReturnedValue GlobalFunctions::method_encodeURI(const FunctionObject *b, const Value *, const Value *argv, int argc)-
586{-
587 if (argc == 0)
argc == 0Description
TRUEnever evaluated
FALSEevaluated 323557 times by 1 test
Evaluated by:
  • tst_ecmascripttests
0-323557
588 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
589-
590 ExecutionEngine *v4 = b->engine();-
591 QString uriString = argv[0].toQString();-
592 bool ok;-
593 QString out = encode(uriString, uriUnescapedReserved, &ok);-
594 if (!ok) {
!okDescription
TRUEevaluated 45053 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 278568 times by 1 test
Evaluated by:
  • tst_ecmascripttests
45053-278568
595 Scope scope(v4);-
596 ScopedString s(scope, scope.engine->newString(QStringLiteral("malformed URI sequence")));
executed 45053 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_ecmascripttests
45053
597 RETURN_RESULT(scope.engine->throwURIError(s));
executed 45055 times by 1 test: return QV4::Encode(scope.engine->throwURIError(s));
Executed by:
  • tst_ecmascripttests
45055
598 }-
599-
600 RETURN_RESULT(v4->newString(out));
executed 278562 times by 1 test: return QV4::Encode(v4->newString(out));
Executed by:
  • tst_ecmascripttests
278562
601}-
602-
603/// encodeURIComponent [15.1.3.4]-
604ReturnedValue GlobalFunctions::method_encodeURIComponent(const FunctionObject *b, const Value *, const Value *argv, int argc)-
605{-
606 if (argc == 0)
argc == 0Description
TRUEnever evaluated
FALSEevaluated 323396 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
0-323396
607 RETURN_UNDEFINED();
never executed: return QV4::Encode::undefined();
0
608-
609 ExecutionEngine *v4 = b->engine();-
610 QString uriString = argv[0].toQString();-
611 bool ok;-
612 QString out = encode(uriString, uriUnescaped, &ok);-
613 if (!ok) {
!okDescription
TRUEevaluated 45056 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 277471 times by 2 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qquickloader
45056-277471
614 Scope scope(v4);-
615 ScopedString s(scope, scope.engine->newString(QStringLiteral("malformed URI sequence")));
executed 45056 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_ecmascripttests
45056
616 RETURN_RESULT(scope.engine->throwURIError(s));
executed 45056 times by 1 test: return QV4::Encode(scope.engine->throwURIError(s));
Executed by:
  • tst_ecmascripttests
45056
617 }-
618-
619 RETURN_RESULT(v4->newString(out));
executed 277375 times by 2 tests: return QV4::Encode(v4->newString(out));
Executed by:
  • tst_ecmascripttests
  • tst_qquickloader
277375
620}-
621-
622ReturnedValue GlobalFunctions::method_escape(const FunctionObject *b, const Value *, const Value *argv, int argc)-
623{-
624 ExecutionEngine *v4 = b->engine();-
625 if (!argc)
!argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
626 RETURN_RESULT(v4->newString(QStringLiteral("undefined")));
never executed: return QV4::Encode(v4->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "undefined")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "undefined" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
627-
628 QString str = argv[0].toQString();-
629 RETURN_RESULT(v4->newString(escape(str)));
never executed: return QV4::Encode(v4->newString(escape(str)));
0
630}-
631-
632ReturnedValue GlobalFunctions::method_unescape(const FunctionObject *b, const Value *, const Value *argv, int argc)-
633{-
634 ExecutionEngine *v4 = b->engine();-
635 if (!argc)
!argcDescription
TRUEnever evaluated
FALSEnever evaluated
0
636 RETURN_RESULT(v4->newString(QStringLiteral("undefined")));
never executed: return QV4::Encode(v4->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "undefined")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "undefined" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));
never executed: return qstring_literal_temp;
0
637-
638 QString str = argv[0].toQString();-
639 RETURN_RESULT(v4->newString(unescape(str)));
never executed: return QV4::Encode(v4->newString(unescape(str)));
0
640}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0