Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4globalobject.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | - | |||||||||||||||||||||||||
67 | using namespace QV4; | - | ||||||||||||||||||||||||
68 | using QtMiscUtils::toHexUpper; | - | ||||||||||||||||||||||||
69 | using QtMiscUtils::fromHex; | - | ||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||
71 | static 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) {
| 0 | ||||||||||||||||||||||||
77 | ushort uc = input.at(i).unicode(); | - | ||||||||||||||||||||||||
78 | if (uc < 0x100) {
| 0 | ||||||||||||||||||||||||
79 | if ( (uc > 0x60 && uc < 0x7B)
| 0 | ||||||||||||||||||||||||
80 | || (uc > 0x3F && uc < 0x5B)
| 0 | ||||||||||||||||||||||||
81 | || (uc > 0x2C && uc < 0x3A)
| 0 | ||||||||||||||||||||||||
82 | || (uc == 0x2A)
| 0 | ||||||||||||||||||||||||
83 | || (uc == 0x2B)
| 0 | ||||||||||||||||||||||||
84 | || (uc == 0x5F)) {
| 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 | - | |||||||||||||||||||||||||
103 | static 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) {
| 0 | ||||||||||||||||||||||||
110 | QChar c = input.at(i++); | - | ||||||||||||||||||||||||
111 | if ((c == '%') && (i + 1 < length)) {
| 0 | ||||||||||||||||||||||||
112 | QChar a = input.at(i); | - | ||||||||||||||||||||||||
113 | if ((a == 'u') && (i + 4 < length)) {
| 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)) {
| 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)) {
| 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 | - | |||||||||||||||||||||||||
141 | static const char uriReserved[] = ";/?:@&=+$,#"; | - | ||||||||||||||||||||||||
142 | static const char uriUnescaped[] = "-_.!~*'()"; | - | ||||||||||||||||||||||||
143 | static const char uriUnescapedReserved[] = "-_.!~*'();/?:@&=+$,#"; | - | ||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | static 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:
| 1697097 | ||||||||||||||||||||||||
151 | - | |||||||||||||||||||||||||
152 | static 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) {
| 554790-658849 | ||||||||||||||||||||||||
159 | const QChar c = input.at(i); | - | ||||||||||||||||||||||||
160 | bool escape = true; | - | ||||||||||||||||||||||||
161 | if ((c.unicode() >= 'a' && c.unicode() <= 'z') ||
| 2808-648366 | ||||||||||||||||||||||||
162 | (c.unicode() >= 'A' && c.unicode() <= 'Z') ||
| 1452-654780 | ||||||||||||||||||||||||
163 | (c.unicode() >= '0' && c.unicode() <= '9')) {
| 192-646566 | ||||||||||||||||||||||||
164 | escape = false; | - | ||||||||||||||||||||||||
165 | } else { executed 11754 times by 2 tests: end of block Executed by:
| 11754 | ||||||||||||||||||||||||
166 | const char *r = unescapedSet; | - | ||||||||||||||||||||||||
167 | while (*r) {
| 644990-9363509 | ||||||||||||||||||||||||
168 | if (*r == c.unicode()) {
| 582-9361162 | ||||||||||||||||||||||||
169 | escape = false; | - | ||||||||||||||||||||||||
170 | break; executed 582 times by 2 tests: break; Executed by:
| 582 | ||||||||||||||||||||||||
171 | } | - | ||||||||||||||||||||||||
172 | ++r; | - | ||||||||||||||||||||||||
173 | } executed 9361076 times by 2 tests: end of block Executed by:
| 9361076 | ||||||||||||||||||||||||
174 | } executed 646876 times by 2 tests: end of block Executed by:
| 646876 | ||||||||||||||||||||||||
175 | if (escape) {
| 12336-646386 | ||||||||||||||||||||||||
176 | uint uc = c.unicode(); | - | ||||||||||||||||||||||||
177 | if ((uc >= 0xDC00) && (uc <= 0xDFFF)) {
| 16384-564777 | ||||||||||||||||||||||||
178 | *ok = false; | - | ||||||||||||||||||||||||
179 | break; executed 16384 times by 1 test: break; Executed by:
| 16384 | ||||||||||||||||||||||||
180 | } | - | ||||||||||||||||||||||||
181 | if (!((uc < 0xD800) || (uc > 0xDBFF))) {
| 65536-442216 | ||||||||||||||||||||||||
182 | ++i; | - | ||||||||||||||||||||||||
183 | if (i == length) {
| 16382-106496 | ||||||||||||||||||||||||
184 | *ok = false; | - | ||||||||||||||||||||||||
185 | break; executed 16382 times by 1 test: break; Executed by:
| 16382 | ||||||||||||||||||||||||
186 | } | - | ||||||||||||||||||||||||
187 | const uint uc2 = input.at(i).unicode(); | - | ||||||||||||||||||||||||
188 | if ((uc2 < 0xDC00) || (uc2 > 0xDFFF)) {
| 16384-65536 | ||||||||||||||||||||||||
189 | *ok = false; | - | ||||||||||||||||||||||||
190 | break; executed 57344 times by 1 test: break; Executed by:
| 57344 | ||||||||||||||||||||||||
191 | } | - | ||||||||||||||||||||||||
192 | uc = ((uc - 0xD800) * 0x400) + (uc2 - 0xDC00) + 0x10000; | - | ||||||||||||||||||||||||
193 | } executed 49152 times by 1 test: end of block Executed by:
| 49152 | ||||||||||||||||||||||||
194 | if (uc < 0x80) {
| 830-555606 | ||||||||||||||||||||||||
195 | addEscapeSequence(output, (uchar)uc); | - | ||||||||||||||||||||||||
196 | } else { executed 830 times by 2 tests: end of block Executed by:
| 830 | ||||||||||||||||||||||||
197 | if (uc < 0x0800) {
| 15656-536410 | ||||||||||||||||||||||||
198 | addEscapeSequence(output, 0xc0 | ((uchar) (uc >> 6))); | - | ||||||||||||||||||||||||
199 | } else { executed 15656 times by 1 test: end of block Executed by:
| 15656 | ||||||||||||||||||||||||
200 | - | |||||||||||||||||||||||||
201 | if (QChar::requiresSurrogates(uc)) {
| 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:
| 49152 | ||||||||||||||||||||||||
205 | addEscapeSequence(output, 0xe0 | (((uchar) (uc >> 12)) & 0x3f)); | - | ||||||||||||||||||||||||
206 | } executed 488898 times by 1 test: end of block Executed by:
| 488898 | ||||||||||||||||||||||||
207 | addEscapeSequence(output, 0x80 | (((uchar) (uc >> 6)) & 0x3f)); | - | ||||||||||||||||||||||||
208 | } executed 538546 times by 1 test: end of block Executed by:
| 538546 | ||||||||||||||||||||||||
209 | addEscapeSequence(output, 0x80 | ((uchar) (uc&0x3f))); | - | ||||||||||||||||||||||||
210 | } executed 554633 times by 1 test: end of block Executed by:
| 554633 | ||||||||||||||||||||||||
211 | } else { | - | ||||||||||||||||||||||||
212 | output.append(c); | - | ||||||||||||||||||||||||
213 | } executed 12336 times by 2 tests: end of block Executed by:
| 12336 | ||||||||||||||||||||||||
214 | ++i; | - | ||||||||||||||||||||||||
215 | } executed 567865 times by 2 tests: end of block Executed by:
| 567865 | ||||||||||||||||||||||||
216 | if (i != length)
| 73728-570704 | ||||||||||||||||||||||||
217 | *ok = false; executed 73728 times by 1 test: *ok = false; Executed by:
| 73728 | ||||||||||||||||||||||||
218 | return output; executed 641194 times by 2 tests: return output; Executed by:
| 641194 | ||||||||||||||||||||||||
219 | } | - | ||||||||||||||||||||||||
220 | - | |||||||||||||||||||||||||
221 | enum DecodeMode { | - | ||||||||||||||||||||||||
222 | DecodeAll, | - | ||||||||||||||||||||||||
223 | DecodeNonReserved | - | ||||||||||||||||||||||||
224 | }; | - | ||||||||||||||||||||||||
225 | - | |||||||||||||||||||||||||
226 | static 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) {
| 8861992-13068743 | ||||||||||||||||||||||||
235 | const QChar ch = input.at(i); | - | ||||||||||||||||||||||||
236 | if (ch == percent) {
| 527240-12541623 | ||||||||||||||||||||||||
237 | int start = i; | - | ||||||||||||||||||||||||
238 | if (i + 2 >= length)
| 32-12527160 | ||||||||||||||||||||||||
239 | goto error; executed 32 times by 1 test: goto error; Executed by:
| 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))
| 524016-12037150 | ||||||||||||||||||||||||
244 | goto error; executed 1025215 times by 1 test: goto error; Executed by:
| 1025215 | ||||||||||||||||||||||||
245 | - | |||||||||||||||||||||||||
246 | int b = (d1 << 4) | d0; | - | ||||||||||||||||||||||||
247 | i += 2; | - | ||||||||||||||||||||||||
248 | if (b & 0x80) {
| 1900-11596958 | ||||||||||||||||||||||||
249 | int uc; | - | ||||||||||||||||||||||||
250 | int min_uc; | - | ||||||||||||||||||||||||
251 | int need; | - | ||||||||||||||||||||||||
252 | if ((b & 0xe0) == 0xc0) {
| 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:
| 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:
| 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:
| 9453701 | ||||||||||||||||||||||||
265 | goto error; executed 575 times by 1 test: goto error; Executed by:
| 575 | ||||||||||||||||||||||||
266 | } | - | ||||||||||||||||||||||||
267 | - | |||||||||||||||||||||||||
268 | if (i + (3 * need) >= length)
| 2099-11577598 | ||||||||||||||||||||||||
269 | goto error; executed 2099 times by 1 test: goto error; Executed by:
| 2099 | ||||||||||||||||||||||||
270 | - | |||||||||||||||||||||||||
271 | for (int j = 0; j < need; ++j) {
| 8357808-29854783 | ||||||||||||||||||||||||
272 | ++i; | - | ||||||||||||||||||||||||
273 | if (input.at(i) != percent)
| 702-29913525 | ||||||||||||||||||||||||
274 | goto error; executed 702 times by 1 test: goto error; Executed by:
| 702 | ||||||||||||||||||||||||
275 | - | |||||||||||||||||||||||||
276 | d1 = fromHex(input.at(i+1).unicode()); | - | ||||||||||||||||||||||||
277 | d0 = fromHex(input.at(i+2).unicode()); | - | ||||||||||||||||||||||||
278 | if ((d1 == -1) || (d0 == -1))
| 0-26804354 | ||||||||||||||||||||||||
279 | goto error; executed 3110132 times by 1 test: goto error; Executed by:
| 3110132 | ||||||||||||||||||||||||
280 | - | |||||||||||||||||||||||||
281 | b = (d1 << 4) | d0; | - | ||||||||||||||||||||||||
282 | if ((b & 0xC0) != 0x80)
| 135157-26679004 | ||||||||||||||||||||||||
283 | goto error; executed 135150 times by 1 test: goto error; Executed by:
| 135150 | ||||||||||||||||||||||||
284 | - | |||||||||||||||||||||||||
285 | i += 2; | - | ||||||||||||||||||||||||
286 | uc = (uc << 6) + (b & 0x3f); | - | ||||||||||||||||||||||||
287 | } executed 26667996 times by 1 test: end of block Executed by:
| 26667996 | ||||||||||||||||||||||||
288 | if (uc < min_uc)
| 0-8362624 | ||||||||||||||||||||||||
289 | goto error; never executed: goto error; | 0 | ||||||||||||||||||||||||
290 | - | |||||||||||||||||||||||||
291 | if (uc < 0x10000) {
| 507176-7857551 | ||||||||||||||||||||||||
292 | output.append(QChar(uc)); | - | ||||||||||||||||||||||||
293 | } else { executed 507176 times by 1 test: end of block Executed by:
| 507176 | ||||||||||||||||||||||||
294 | if (uc > 0x10FFFF)
| 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:
| 7821960 | ||||||||||||||||||||||||
302 | } else { | - | ||||||||||||||||||||||||
303 | if (decodeMode == DecodeNonReserved && b <= 0x40) {
| 444-976 | ||||||||||||||||||||||||
304 | const char *r = uriReserved; | - | ||||||||||||||||||||||||
305 | while (*r) {
| 236-3848 | ||||||||||||||||||||||||
306 | if (*r == b)
| 208-3640 | ||||||||||||||||||||||||
307 | break; executed 208 times by 1 test: break; Executed by:
| 208 | ||||||||||||||||||||||||
308 | ++r; | - | ||||||||||||||||||||||||
309 | } executed 3640 times by 1 test: end of block Executed by:
| 3640 | ||||||||||||||||||||||||
310 | if (*r)
| 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:
| 208 | ||||||||||||||||||||||||
312 | else | - | ||||||||||||||||||||||||
313 | output.append(QChar(b)); executed 236 times by 1 test: output.append(QChar(b)); Executed by:
| 236 | ||||||||||||||||||||||||
314 | } else { | - | ||||||||||||||||||||||||
315 | output.append(QChar(b)); | - | ||||||||||||||||||||||||
316 | } executed 1456 times by 1 test: end of block Executed by:
| 1456 | ||||||||||||||||||||||||
317 | } | - | ||||||||||||||||||||||||
318 | } else { | - | ||||||||||||||||||||||||
319 | output.append(ch); | - | ||||||||||||||||||||||||
320 | } executed 527240 times by 1 test: end of block Executed by:
| 527240 | ||||||||||||||||||||||||
321 | ++i; | - | ||||||||||||||||||||||||
322 | } executed 8868322 times by 1 test: end of block Executed by:
| 8868322 | ||||||||||||||||||||||||
323 | if (i != length)
| 0-8874845 | ||||||||||||||||||||||||
324 | *ok = false; never executed: *ok = false; | 0 | ||||||||||||||||||||||||
325 | return output; executed 8829052 times by 1 test: return output; Executed by:
| 8829052 | ||||||||||||||||||||||||
326 | error: | - | ||||||||||||||||||||||||
327 | *ok = false; | - | ||||||||||||||||||||||||
328 | return QString(); executed 4219004 times by 1 test: return QString(); Executed by:
| 4219004 | ||||||||||||||||||||||||
329 | } | - | ||||||||||||||||||||||||
330 | - | |||||||||||||||||||||||||
331 | DEFINE_OBJECT_VTABLE(EvalFunction); | - | ||||||||||||||||||||||||
332 | - | |||||||||||||||||||||||||
333 | void 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:
| 98530 | ||||||||||||||||||||||||
340 | - | |||||||||||||||||||||||||
341 | ReturnedValue EvalFunction::evalCall(const Value *, const Value *argv, int argc, bool directCall) const | - | ||||||||||||||||||||||||
342 | { | - | ||||||||||||||||||||||||
343 | if (argc < 1)
| 12-1579011 | ||||||||||||||||||||||||
344 | return Encode::undefined(); executed 12 times by 1 test: return Encode::undefined(); Executed by:
| 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) {
| 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:
| 60 | ||||||||||||||||||||||||
356 | - | |||||||||||||||||||||||||
357 | String *scode = argv[0].stringValue(); | - | ||||||||||||||||||||||||
358 | if (!scode)
| 72-1578956 | ||||||||||||||||||||||||
359 | return argv[0].asReturnedValue(); executed 72 times by 1 test: return argv[0].asReturnedValue(); Executed by:
| 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:
| 1580111 | ||||||||||||||||||||||||
365 | script.strictMode = (directCall && isStrict);
| 60-1579465 | ||||||||||||||||||||||||
366 | script.inheritContext = inheritContext; | - | ||||||||||||||||||||||||
367 | script.parse(); | - | ||||||||||||||||||||||||
368 | if (v4->hasException)
| 569-1578345 | ||||||||||||||||||||||||
369 | return Encode::undefined(); executed 570 times by 1 test: return Encode::undefined(); Executed by:
| 570 | ||||||||||||||||||||||||
370 | - | |||||||||||||||||||||||||
371 | Function *function = script.function(); | - | ||||||||||||||||||||||||
372 | if (!function)
| 521286-1055169 | ||||||||||||||||||||||||
373 | return Encode::undefined(); executed 519155 times by 1 test: return Encode::undefined(); Executed by:
| 519155 | ||||||||||||||||||||||||
374 | - | |||||||||||||||||||||||||
375 | if (function->isStrict() || isStrict) {
| 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:
| 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:
| 528709 | ||||||||||||||||||||||||
384 | } | - | ||||||||||||||||||||||||
385 | - | |||||||||||||||||||||||||
386 | - | |||||||||||||||||||||||||
387 | ReturnedValue 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:
| 64 | ||||||||||||||||||||||||
391 | } | - | ||||||||||||||||||||||||
392 | - | |||||||||||||||||||||||||
393 | - | |||||||||||||||||||||||||
394 | static inline int toInt(const QChar &qc, int R) | - | ||||||||||||||||||||||||
395 | { | - | ||||||||||||||||||||||||
396 | ushort c = qc.unicode(); | - | ||||||||||||||||||||||||
397 | int v = -1; | - | ||||||||||||||||||||||||
398 | if (c >= '0' && c <= '9')
| 744-806000 | ||||||||||||||||||||||||
399 | v = c - '0'; executed 271464 times by 2 tests: v = c - '0'; Executed by:
| 271464 | ||||||||||||||||||||||||
400 | else if (c >= 'A' && c <= 'Z')
| 772-534508 | ||||||||||||||||||||||||
401 | v = c - 'A' + 10; executed 267396 times by 1 test: v = c - 'A' + 10; Executed by:
| 267396 | ||||||||||||||||||||||||
402 | else if (c >= 'a' && c <= 'z')
| 800-267084 | ||||||||||||||||||||||||
403 | v = c - 'a' + 10; executed 5496 times by 1 test: v = c - 'a' + 10; Executed by:
| 5496 | ||||||||||||||||||||||||
404 | if (v >= 0 && v < R)
| 356-544356 | ||||||||||||||||||||||||
405 | return v; executed 544000 times by 2 tests: return v; Executed by:
| 544000 | ||||||||||||||||||||||||
406 | else | - | ||||||||||||||||||||||||
407 | return -1; executed 262744 times by 2 tests: return -1; Executed by:
| 262744 | ||||||||||||||||||||||||
408 | } | - | ||||||||||||||||||||||||
409 | - | |||||||||||||||||||||||||
410 | // parseInt [15.1.2.2] | - | ||||||||||||||||||||||||
411 | ReturnedValue 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();
| 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:
| 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) {
| 108-267352 | ||||||||||||||||||||||||
427 | if (*pos == QLatin1Char('-'))
| 972-266380 | ||||||||||||||||||||||||
428 | sign = -1; // 4 executed 972 times by 1 test: sign = -1; Executed by:
| 972 | ||||||||||||||||||||||||
429 | if (*pos == QLatin1Char('-') || *pos == QLatin1Char('+'))
| 700-266380 | ||||||||||||||||||||||||
430 | ++pos; // 5 executed 1672 times by 1 test: ++pos; Executed by:
| 1672 | ||||||||||||||||||||||||
431 | } executed 267352 times by 2 tests: end of block Executed by:
| 267352 | ||||||||||||||||||||||||
432 | bool stripPrefix = true; // 7 | - | ||||||||||||||||||||||||
433 | if (R) { // 8
| 996-266464 | ||||||||||||||||||||||||
434 | if (R < 2 || R > 36)
| 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:
| 108 | ||||||||||||||||||||||||
436 | if (R != 16)
| 328-266028 | ||||||||||||||||||||||||
437 | stripPrefix = false; // 8b executed 266028 times by 1 test: stripPrefix = false; Executed by:
| 266028 | ||||||||||||||||||||||||
438 | } else { // 9 executed 266356 times by 1 test: end of block Executed by:
| 266356 | ||||||||||||||||||||||||
439 | R = 10; // 9a | - | ||||||||||||||||||||||||
440 | } executed 996 times by 2 tests: end of block Executed by:
| 996 | ||||||||||||||||||||||||
441 | if (stripPrefix) { // 10
| 1324-266028 | ||||||||||||||||||||||||
442 | if ((end - pos >= 2)
| 504-820 | ||||||||||||||||||||||||
443 | && (pos[0] == QLatin1Char('0'))
| 228-276 | ||||||||||||||||||||||||
444 | && (pos[1] == QLatin1Char('x') || pos[1] == QLatin1Char('X'))) { // 10a
| 4-140 | ||||||||||||||||||||||||
445 | pos += 2; | - | ||||||||||||||||||||||||
446 | R = 16; | - | ||||||||||||||||||||||||
447 | } executed 224 times by 1 test: end of block Executed by:
| 224 | ||||||||||||||||||||||||
448 | } executed 1324 times by 2 tests: end of block Executed by:
| 1324 | ||||||||||||||||||||||||
449 | // 11: Z is progressively built below | - | ||||||||||||||||||||||||
450 | // 13: this is handled by the toInt function | - | ||||||||||||||||||||||||
451 | if (pos == end) // 12
| 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:
| 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)
| 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:
| 220 | ||||||||||||||||||||||||
459 | qint64 v = d; | - | ||||||||||||||||||||||||
460 | while (pos != end) {
| 4500-539500 | ||||||||||||||||||||||||
461 | d = toInt(*pos++, R); | - | ||||||||||||||||||||||||
462 | if (d == -1)
| 262524-276976 | ||||||||||||||||||||||||
463 | break; executed 262524 times by 2 tests: break; Executed by:
| 262524 | ||||||||||||||||||||||||
464 | if (overflow) {
| 44-276932 | ||||||||||||||||||||||||
465 | if (overflow_digit_count == 0) {
| 20-24 | ||||||||||||||||||||||||
466 | v_overflow = v; | - | ||||||||||||||||||||||||
467 | v = 0; | - | ||||||||||||||||||||||||
468 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
469 | ++overflow_digit_count; | - | ||||||||||||||||||||||||
470 | v = v * R + d; | - | ||||||||||||||||||||||||
471 | } else { executed 44 times by 1 test: end of block Executed by:
| 44 | ||||||||||||||||||||||||
472 | qint64 vNew = v * R + d; | - | ||||||||||||||||||||||||
473 | if (vNew < v) {
| 20-276912 | ||||||||||||||||||||||||
474 | overflow = true; | - | ||||||||||||||||||||||||
475 | --pos; | - | ||||||||||||||||||||||||
476 | } else { executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
477 | v = vNew; | - | ||||||||||||||||||||||||
478 | } executed 276912 times by 2 tests: end of block Executed by:
| 276912 | ||||||||||||||||||||||||
479 | } | - | ||||||||||||||||||||||||
480 | } | - | ||||||||||||||||||||||||
481 | - | |||||||||||||||||||||||||
482 | if (overflow) {
| 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:
| 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:
| 267004 | ||||||||||||||||||||||||
488 | } | - | ||||||||||||||||||||||||
489 | } | - | ||||||||||||||||||||||||
490 | - | |||||||||||||||||||||||||
491 | // parseFloat [15.1.2.3] | - | ||||||||||||||||||||||||
492 | ReturnedValue 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:
| 8-263152 | ||||||||||||||||||||||||
498 | - | |||||||||||||||||||||||||
499 | QString trimmed = inputString->toQString().trimmed(); // 2 | - | ||||||||||||||||||||||||
500 | - | |||||||||||||||||||||||||
501 | // 4: | - | ||||||||||||||||||||||||
502 | if (trimmed.startsWith(QLatin1String("Infinity"))
| 40-263112 | ||||||||||||||||||||||||
503 | || trimmed.startsWith(QLatin1String("+Infinity")))
| 4-263108 | ||||||||||||||||||||||||
504 | RETURN_RESULT(Encode(Q_INFINITY)); executed 44 times by 1 test: return QV4::Encode(Encode((::qInf()))); Executed by:
| 44 | ||||||||||||||||||||||||
505 | if (trimmed.startsWith(QLatin1String("-Infinity")))
| 4-263104 | ||||||||||||||||||||||||
506 | RETURN_RESULT(Encode(-Q_INFINITY)); executed 4 times by 1 test: return QV4::Encode(Encode(-(::qInf()))); Executed by:
| 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)
| 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:
| 212 | ||||||||||||||||||||||||
514 | else | - | ||||||||||||||||||||||||
515 | RETURN_RESULT(Encode(d)); executed 262892 times by 1 test: return QV4::Encode(Encode(d)); Executed by:
| 262892 | ||||||||||||||||||||||||
516 | } | - | ||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||
518 | /// isNaN [15.1.2.4] | - | ||||||||||||||||||||||||
519 | ReturnedValue GlobalFunctions::method_isNaN(const FunctionObject *, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
520 | { | - | ||||||||||||||||||||||||
521 | if (!argc)
| 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:
| 4 | ||||||||||||||||||||||||
524 | - | |||||||||||||||||||||||||
525 | if (argv[0].integerCompatible())
| 182-1892 | ||||||||||||||||||||||||
526 | RETURN_RESULT(Encode(false)); executed 182 times by 2 tests: return QV4::Encode(Encode(false)); Executed by:
| 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:
| 1892 | ||||||||||||||||||||||||
530 | } | - | ||||||||||||||||||||||||
531 | - | |||||||||||||||||||||||||
532 | /// isFinite [15.1.2.5] | - | ||||||||||||||||||||||||
533 | ReturnedValue GlobalFunctions::method_isFinite(const FunctionObject *, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
534 | { | - | ||||||||||||||||||||||||
535 | if (!argc)
| 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:
| 4 | ||||||||||||||||||||||||
538 | - | |||||||||||||||||||||||||
539 | if (argv[0].integerCompatible())
| 24-150 | ||||||||||||||||||||||||
540 | RETURN_RESULT(Encode(true)); executed 24 times by 1 test: return QV4::Encode(Encode(true)); Executed by:
| 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:
| 150 | ||||||||||||||||||||||||
544 | } | - | ||||||||||||||||||||||||
545 | - | |||||||||||||||||||||||||
546 | /// decodeURI [15.1.3.1] | - | ||||||||||||||||||||||||
547 | ReturnedValue GlobalFunctions::method_decodeURI(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
548 | { | - | ||||||||||||||||||||||||
549 | if (argc == 0)
| 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) {
| 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:
| 2065233 | ||||||||||||||||||||||||
559 | RETURN_RESULT(scope.engine->throwURIError(s)); executed 2065227 times by 1 test: return QV4::Encode(scope.engine->throwURIError(s)); Executed by:
| 2065227 | ||||||||||||||||||||||||
560 | } | - | ||||||||||||||||||||||||
561 | - | |||||||||||||||||||||||||
562 | RETURN_RESULT(v4->newString(out)); executed 4445724 times by 1 test: return QV4::Encode(v4->newString(out)); Executed by:
| 4445724 | ||||||||||||||||||||||||
563 | } | - | ||||||||||||||||||||||||
564 | - | |||||||||||||||||||||||||
565 | /// decodeURIComponent [15.1.3.2] | - | ||||||||||||||||||||||||
566 | ReturnedValue GlobalFunctions::method_decodeURIComponent(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
567 | { | - | ||||||||||||||||||||||||
568 | if (argc == 0)
| 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) {
| 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:
| 2104002 | ||||||||||||||||||||||||
578 | RETURN_RESULT(scope.engine->throwURIError(s)); executed 2110048 times by 1 test: return QV4::Encode(scope.engine->throwURIError(s)); Executed by:
| 2110048 | ||||||||||||||||||||||||
579 | } | - | ||||||||||||||||||||||||
580 | - | |||||||||||||||||||||||||
581 | RETURN_RESULT(v4->newString(out)); executed 4447441 times by 1 test: return QV4::Encode(v4->newString(out)); Executed by:
| 4447441 | ||||||||||||||||||||||||
582 | } | - | ||||||||||||||||||||||||
583 | - | |||||||||||||||||||||||||
584 | /// encodeURI [15.1.3.3] | - | ||||||||||||||||||||||||
585 | ReturnedValue GlobalFunctions::method_encodeURI(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
586 | { | - | ||||||||||||||||||||||||
587 | if (argc == 0)
| 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) {
| 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:
| 45053 | ||||||||||||||||||||||||
597 | RETURN_RESULT(scope.engine->throwURIError(s)); executed 45055 times by 1 test: return QV4::Encode(scope.engine->throwURIError(s)); Executed by:
| 45055 | ||||||||||||||||||||||||
598 | } | - | ||||||||||||||||||||||||
599 | - | |||||||||||||||||||||||||
600 | RETURN_RESULT(v4->newString(out)); executed 278562 times by 1 test: return QV4::Encode(v4->newString(out)); Executed by:
| 278562 | ||||||||||||||||||||||||
601 | } | - | ||||||||||||||||||||||||
602 | - | |||||||||||||||||||||||||
603 | /// encodeURIComponent [15.1.3.4] | - | ||||||||||||||||||||||||
604 | ReturnedValue GlobalFunctions::method_encodeURIComponent(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
605 | { | - | ||||||||||||||||||||||||
606 | if (argc == 0)
| 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) {
| 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:
| 45056 | ||||||||||||||||||||||||
616 | RETURN_RESULT(scope.engine->throwURIError(s)); executed 45056 times by 1 test: return QV4::Encode(scope.engine->throwURIError(s)); Executed by:
| 45056 | ||||||||||||||||||||||||
617 | } | - | ||||||||||||||||||||||||
618 | - | |||||||||||||||||||||||||
619 | RETURN_RESULT(v4->newString(out)); executed 277375 times by 2 tests: return QV4::Encode(v4->newString(out)); Executed by:
| 277375 | ||||||||||||||||||||||||
620 | } | - | ||||||||||||||||||||||||
621 | - | |||||||||||||||||||||||||
622 | ReturnedValue GlobalFunctions::method_escape(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
623 | { | - | ||||||||||||||||||||||||
624 | ExecutionEngine *v4 = b->engine(); | - | ||||||||||||||||||||||||
625 | if (!argc)
| 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 | - | |||||||||||||||||||||||||
632 | ReturnedValue GlobalFunctions::method_unescape(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
633 | { | - | ||||||||||||||||||||||||
634 | ExecutionEngine *v4 = b->engine(); | - | ||||||||||||||||||||||||
635 | if (!argc)
| 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 code | Switch to Preprocessed file |