Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4runtime.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 "qv4global_p.h" | - | ||||||||||||||||||
41 | #include "qv4engine_p.h" | - | ||||||||||||||||||
42 | #include "qv4runtime_p.h" | - | ||||||||||||||||||
43 | #ifndef V4_BOOTSTRAP | - | ||||||||||||||||||
44 | #include "qv4object_p.h" | - | ||||||||||||||||||
45 | #include "qv4objectproto_p.h" | - | ||||||||||||||||||
46 | #include "qv4globalobject_p.h" | - | ||||||||||||||||||
47 | #include "qv4stringobject_p.h" | - | ||||||||||||||||||
48 | #include "qv4argumentsobject_p.h" | - | ||||||||||||||||||
49 | #include "qv4objectiterator_p.h" | - | ||||||||||||||||||
50 | #include "qv4dateobject_p.h" | - | ||||||||||||||||||
51 | #include "qv4lookup_p.h" | - | ||||||||||||||||||
52 | #include "qv4function_p.h" | - | ||||||||||||||||||
53 | #include "qv4numberobject_p.h" | - | ||||||||||||||||||
54 | #include "qv4regexp_p.h" | - | ||||||||||||||||||
55 | #include "qv4regexpobject_p.h" | - | ||||||||||||||||||
56 | #include "private/qlocale_tools_p.h" | - | ||||||||||||||||||
57 | #include "qv4scopedvalue_p.h" | - | ||||||||||||||||||
58 | #include "qv4jscall_p.h" | - | ||||||||||||||||||
59 | #include <private/qv4qmlcontext_p.h> | - | ||||||||||||||||||
60 | #include <private/qqmltypewrapper_p.h> | - | ||||||||||||||||||
61 | #include <private/qqmlengine_p.h> | - | ||||||||||||||||||
62 | #include <private/qqmljavascriptexpression_p.h> | - | ||||||||||||||||||
63 | #include "qv4qobjectwrapper_p.h" | - | ||||||||||||||||||
64 | #include "qv4symbol_p.h" | - | ||||||||||||||||||
65 | #include "qv4generatorobject_p.h" | - | ||||||||||||||||||
66 | #include <private/qv8engine_p.h> | - | ||||||||||||||||||
67 | #endif | - | ||||||||||||||||||
68 | - | |||||||||||||||||||
69 | #include <QtCore/QDebug> | - | ||||||||||||||||||
70 | #include <cassert> | - | ||||||||||||||||||
71 | #include <cstdio> | - | ||||||||||||||||||
72 | #include <stdlib.h> | - | ||||||||||||||||||
73 | - | |||||||||||||||||||
74 | #include <wtf/MathExtras.h> | - | ||||||||||||||||||
75 | - | |||||||||||||||||||
76 | #ifdef QV4_COUNT_RUNTIME_FUNCTIONS | - | ||||||||||||||||||
77 | # include <QtCore/QBuffer> | - | ||||||||||||||||||
78 | # include <QtCore/QDebug> | - | ||||||||||||||||||
79 | #endif // QV4_COUNT_RUNTIME_FUNCTIONS | - | ||||||||||||||||||
80 | - | |||||||||||||||||||
81 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
82 | - | |||||||||||||||||||
83 | namespace QV4 { | - | ||||||||||||||||||
84 | - | |||||||||||||||||||
85 | #ifdef QV4_COUNT_RUNTIME_FUNCTIONS | - | ||||||||||||||||||
86 | struct RuntimeCounters::Data { | - | ||||||||||||||||||
87 | enum Type { | - | ||||||||||||||||||
88 | None = 0, | - | ||||||||||||||||||
89 | Undefined = 1, | - | ||||||||||||||||||
90 | Null = 2, | - | ||||||||||||||||||
91 | Boolean = 3, | - | ||||||||||||||||||
92 | Integer = 4, | - | ||||||||||||||||||
93 | Managed = 5, | - | ||||||||||||||||||
94 | Double = 7 | - | ||||||||||||||||||
95 | }; | - | ||||||||||||||||||
96 | - | |||||||||||||||||||
97 | static const char *pretty(Type t) { | - | ||||||||||||||||||
98 | switch (t) { | - | ||||||||||||||||||
99 | case None: return ""; | - | ||||||||||||||||||
100 | case Undefined: return "Undefined"; | - | ||||||||||||||||||
101 | case Null: return "Null"; | - | ||||||||||||||||||
102 | case Boolean: return "Boolean"; | - | ||||||||||||||||||
103 | case Integer: return "Integer"; | - | ||||||||||||||||||
104 | case Managed: return "Managed"; | - | ||||||||||||||||||
105 | case Double: return "Double"; | - | ||||||||||||||||||
106 | default: return "Unknown"; | - | ||||||||||||||||||
107 | } | - | ||||||||||||||||||
108 | } | - | ||||||||||||||||||
109 | - | |||||||||||||||||||
110 | static unsigned mangle(unsigned tag) { | - | ||||||||||||||||||
111 | switch (tag) { | - | ||||||||||||||||||
112 | case Value::Undefined_Type: return Undefined; | - | ||||||||||||||||||
113 | case Value::Null_Type: return Null; | - | ||||||||||||||||||
114 | case Value::Boolean_Type: return Boolean; | - | ||||||||||||||||||
115 | case Value::Integer_Type: return Integer; | - | ||||||||||||||||||
116 | case Value::Managed_Type: return Managed; | - | ||||||||||||||||||
117 | default: return Double; | - | ||||||||||||||||||
118 | } | - | ||||||||||||||||||
119 | } | - | ||||||||||||||||||
120 | - | |||||||||||||||||||
121 | static unsigned mangle(unsigned tag1, unsigned tag2) { | - | ||||||||||||||||||
122 | return (mangle(tag1) << 3) | mangle(tag2); | - | ||||||||||||||||||
123 | } | - | ||||||||||||||||||
124 | - | |||||||||||||||||||
125 | static void unmangle(unsigned signature, Type &tag1, Type &tag2) { | - | ||||||||||||||||||
126 | tag1 = Type((signature >> 3) & 7); | - | ||||||||||||||||||
127 | tag2 = Type(signature & 7); | - | ||||||||||||||||||
128 | } | - | ||||||||||||||||||
129 | - | |||||||||||||||||||
130 | typedef QVector<quint64> Counters; | - | ||||||||||||||||||
131 | QHash<const char *, Counters> counters; | - | ||||||||||||||||||
132 | - | |||||||||||||||||||
133 | inline void count(const char *func) { | - | ||||||||||||||||||
134 | QVector<quint64> &cnt = counters[func]; | - | ||||||||||||||||||
135 | if (cnt.isEmpty()) | - | ||||||||||||||||||
136 | cnt.resize(64); | - | ||||||||||||||||||
137 | cnt[0] += 1; | - | ||||||||||||||||||
138 | } | - | ||||||||||||||||||
139 | - | |||||||||||||||||||
140 | inline void count(const char *func, unsigned tag) { | - | ||||||||||||||||||
141 | QVector<quint64> &cnt = counters[func]; | - | ||||||||||||||||||
142 | if (cnt.isEmpty()) | - | ||||||||||||||||||
143 | cnt.resize(64); | - | ||||||||||||||||||
144 | cnt[mangle(tag)] += 1; | - | ||||||||||||||||||
145 | } | - | ||||||||||||||||||
146 | - | |||||||||||||||||||
147 | inline void count(const char *func, unsigned tag1, unsigned tag2) { | - | ||||||||||||||||||
148 | QVector<quint64> &cnt = counters[func]; | - | ||||||||||||||||||
149 | if (cnt.isEmpty()) | - | ||||||||||||||||||
150 | cnt.resize(64); | - | ||||||||||||||||||
151 | cnt[mangle(tag1, tag2)] += 1; | - | ||||||||||||||||||
152 | } | - | ||||||||||||||||||
153 | - | |||||||||||||||||||
154 | struct Line { | - | ||||||||||||||||||
155 | const char *func; | - | ||||||||||||||||||
156 | Type tag1, tag2; | - | ||||||||||||||||||
157 | quint64 count; | - | ||||||||||||||||||
158 | - | |||||||||||||||||||
159 | static bool less(const Line &line1, const Line &line2) { | - | ||||||||||||||||||
160 | return line1.count > line2.count; | - | ||||||||||||||||||
161 | } | - | ||||||||||||||||||
162 | }; | - | ||||||||||||||||||
163 | - | |||||||||||||||||||
164 | void dump() const { | - | ||||||||||||||||||
165 | QBuffer buf; | - | ||||||||||||||||||
166 | buf.open(QIODevice::WriteOnly); | - | ||||||||||||||||||
167 | QTextStream outs(&buf); | - | ||||||||||||||||||
168 | QList<Line> lines; | - | ||||||||||||||||||
169 | for (auto it = counters.cbegin(), end = counters.cend(); it != end; ++it) { | - | ||||||||||||||||||
170 | const Counters &fCount = it.value(); | - | ||||||||||||||||||
171 | for (int i = 0, ei = fCount.size(); i != ei; ++i) { | - | ||||||||||||||||||
172 | quint64 count = fCount[i]; | - | ||||||||||||||||||
173 | if (!count) | - | ||||||||||||||||||
174 | continue; | - | ||||||||||||||||||
175 | Line line; | - | ||||||||||||||||||
176 | line.func = it.key(); | - | ||||||||||||||||||
177 | unmangle(i, line.tag1, line.tag2); | - | ||||||||||||||||||
178 | line.count = count; | - | ||||||||||||||||||
179 | lines.append(line); | - | ||||||||||||||||||
180 | } | - | ||||||||||||||||||
181 | } | - | ||||||||||||||||||
182 | std::sort(lines.begin(), lines.end(), Line::less); | - | ||||||||||||||||||
183 | outs << lines.size() << " counters:" << endl; | - | ||||||||||||||||||
184 | for (const Line &line : qAsConst(lines)) | - | ||||||||||||||||||
185 | outs << qSetFieldWidth(10) << line.count << qSetFieldWidth(0) | - | ||||||||||||||||||
186 | << " | " << line.func | - | ||||||||||||||||||
187 | << " | " << pretty(line.tag1) | - | ||||||||||||||||||
188 | << " | " << pretty(line.tag2) | - | ||||||||||||||||||
189 | << endl; | - | ||||||||||||||||||
190 | qDebug("%s", buf.data().constData()); | - | ||||||||||||||||||
191 | } | - | ||||||||||||||||||
192 | }; | - | ||||||||||||||||||
193 | - | |||||||||||||||||||
194 | RuntimeCounters *RuntimeCounters::instance = 0; | - | ||||||||||||||||||
195 | static RuntimeCounters runtimeCountersInstance; | - | ||||||||||||||||||
196 | RuntimeCounters::RuntimeCounters() | - | ||||||||||||||||||
197 | : d(new Data) | - | ||||||||||||||||||
198 | { | - | ||||||||||||||||||
199 | if (!instance) | - | ||||||||||||||||||
200 | instance = this; | - | ||||||||||||||||||
201 | } | - | ||||||||||||||||||
202 | - | |||||||||||||||||||
203 | RuntimeCounters::~RuntimeCounters() | - | ||||||||||||||||||
204 | { | - | ||||||||||||||||||
205 | d->dump(); | - | ||||||||||||||||||
206 | delete d; | - | ||||||||||||||||||
207 | } | - | ||||||||||||||||||
208 | - | |||||||||||||||||||
209 | void RuntimeCounters::count(const char *func) | - | ||||||||||||||||||
210 | { | - | ||||||||||||||||||
211 | d->count(func); | - | ||||||||||||||||||
212 | } | - | ||||||||||||||||||
213 | - | |||||||||||||||||||
214 | void RuntimeCounters::count(const char *func, uint tag) | - | ||||||||||||||||||
215 | { | - | ||||||||||||||||||
216 | d->count(func, tag); | - | ||||||||||||||||||
217 | } | - | ||||||||||||||||||
218 | - | |||||||||||||||||||
219 | void RuntimeCounters::count(const char *func, uint tag1, uint tag2) | - | ||||||||||||||||||
220 | { | - | ||||||||||||||||||
221 | d->count(func, tag1, tag2); | - | ||||||||||||||||||
222 | } | - | ||||||||||||||||||
223 | - | |||||||||||||||||||
224 | #endif // QV4_COUNT_RUNTIME_FUNCTIONS | - | ||||||||||||||||||
225 | - | |||||||||||||||||||
226 | #ifndef V4_BOOTSTRAP | - | ||||||||||||||||||
227 | - | |||||||||||||||||||
228 | Runtime::Runtime() | - | ||||||||||||||||||
229 | { | - | ||||||||||||||||||
230 | #define INIT_METHOD(returnvalue, name, args) runtimeMethods[name] = reinterpret_cast<void*>(&method_##name); | - | ||||||||||||||||||
231 | FOR_EACH_RUNTIME_METHOD(INIT_METHOD) | - | ||||||||||||||||||
232 | #undef INIT_METHOD | - | ||||||||||||||||||
233 | } executed 99151 times by 153 tests: end of block Executed by:
| 99151 | ||||||||||||||||||
234 | - | |||||||||||||||||||
235 | void RuntimeHelpers::numberToString(QString *result, double num, int radix) | - | ||||||||||||||||||
236 | { | - | ||||||||||||||||||
237 | Q_ASSERT(result); | - | ||||||||||||||||||
238 | - | |||||||||||||||||||
239 | if (std::isnan(num)) {
| 2404-3021936 | ||||||||||||||||||
240 | *result = QStringLiteral("NaN"); | - | ||||||||||||||||||
241 | return; executed 2404 times by 1 test: return; Executed by:
| 2404 | ||||||||||||||||||
242 | } else if (qt_is_inf(num)) {
| 1655-3020283 | ||||||||||||||||||
243 | *result = num < 0 ? QStringLiteral("-Infinity") : QStringLiteral("Infinity"); executed 976 times by 2 tests: return qstring_literal_temp; Executed by:
| 976 | ||||||||||||||||||
244 | return; executed 1655 times by 2 tests: return; Executed by:
| 1655 | ||||||||||||||||||
245 | } | - | ||||||||||||||||||
246 | - | |||||||||||||||||||
247 | if (radix == 10) {
| 0-3020296 | ||||||||||||||||||
248 | // We cannot use our usual locale->toString(...) here, because EcmaScript has special rules | - | ||||||||||||||||||
249 | // about the longest permissible number, depending on if it's <0 or >0. | - | ||||||||||||||||||
250 | const int ecma_shortest_low = -6; | - | ||||||||||||||||||
251 | const int ecma_shortest_high = 21; | - | ||||||||||||||||||
252 | - | |||||||||||||||||||
253 | const QLatin1Char zero('0'); | - | ||||||||||||||||||
254 | const QLatin1Char dot('.'); | - | ||||||||||||||||||
255 | - | |||||||||||||||||||
256 | int decpt = 0; | - | ||||||||||||||||||
257 | int sign = 0; | - | ||||||||||||||||||
258 | *result = qdtoa(num, &decpt, &sign); | - | ||||||||||||||||||
259 | - | |||||||||||||||||||
260 | if (decpt <= ecma_shortest_low || decpt > ecma_shortest_high) {
| 324-3019284 | ||||||||||||||||||
261 | if (result->length() > 1)
| 124-1203 | ||||||||||||||||||
262 | result->insert(1, dot); executed 124 times by 3 tests: result->insert(1, dot); Executed by:
| 124 | ||||||||||||||||||
263 | result->append(QLatin1Char('e')); | - | ||||||||||||||||||
264 | if (decpt > 0)
| 323-1004 | ||||||||||||||||||
265 | result->append(QLatin1Char('+')); executed 323 times by 2 tests: result->append(QLatin1Char('+')); Executed by:
| 323 | ||||||||||||||||||
266 | result->append(QString::number(decpt - 1)); | - | ||||||||||||||||||
267 | } else if (decpt <= 0) { executed 1328 times by 3 tests: end of block Executed by:
| 1328-3016568 | ||||||||||||||||||
268 | result->prepend(QLatin1String("0.") + QString(-decpt, zero)); | - | ||||||||||||||||||
269 | } else if (decpt < result->length()) { executed 2398 times by 8 tests: end of block Executed by:
| 2398-2989112 | ||||||||||||||||||
270 | result->insert(decpt, dot); | - | ||||||||||||||||||
271 | } else { executed 27459 times by 12 tests: end of block Executed by:
| 27459 | ||||||||||||||||||
272 | result->append(QString(decpt - result->length(), zero)); | - | ||||||||||||||||||
273 | } executed 2989103 times by 27 tests: end of block Executed by:
| 2989103 | ||||||||||||||||||
274 | - | |||||||||||||||||||
275 | if (sign && num)
| 88077-2932220 | ||||||||||||||||||
276 | result->prepend(QLatin1Char('-')); executed 81118 times by 8 tests: result->prepend(QLatin1Char('-')); Executed by:
| 81118 | ||||||||||||||||||
277 | - | |||||||||||||||||||
278 | return; executed 3020290 times by 27 tests: return; Executed by:
| 3020290 | ||||||||||||||||||
279 | } | - | ||||||||||||||||||
280 | - | |||||||||||||||||||
281 | result->clear(); | - | ||||||||||||||||||
282 | bool negative = false; | - | ||||||||||||||||||
283 | - | |||||||||||||||||||
284 | if (num < 0) {
| 0 | ||||||||||||||||||
285 | negative = true; | - | ||||||||||||||||||
286 | num = -num; | - | ||||||||||||||||||
287 | } never executed: end of block | 0 | ||||||||||||||||||
288 | - | |||||||||||||||||||
289 | double frac = num - ::floor(num); | - | ||||||||||||||||||
290 | num = Primitive::toInteger(num); | - | ||||||||||||||||||
291 | - | |||||||||||||||||||
292 | do { | - | ||||||||||||||||||
293 | char c = (char)::fmod(num, radix); | - | ||||||||||||||||||
294 | c = (c < 10) ? (c + '0') : (c - 10 + 'a');
| 0 | ||||||||||||||||||
295 | result->prepend(QLatin1Char(c)); | - | ||||||||||||||||||
296 | num = ::floor(num / radix); | - | ||||||||||||||||||
297 | } while (num != 0); never executed: end of block
| 0 | ||||||||||||||||||
298 | - | |||||||||||||||||||
299 | if (frac != 0) {
| 0 | ||||||||||||||||||
300 | result->append(QLatin1Char('.')); | - | ||||||||||||||||||
301 | do { | - | ||||||||||||||||||
302 | frac = frac * radix; | - | ||||||||||||||||||
303 | char c = (char)::floor(frac); | - | ||||||||||||||||||
304 | c = (c < 10) ? (c + '0') : (c - 10 + 'a');
| 0 | ||||||||||||||||||
305 | result->append(QLatin1Char(c)); | - | ||||||||||||||||||
306 | frac = frac - ::floor(frac); | - | ||||||||||||||||||
307 | } while (frac != 0); never executed: end of block
| 0 | ||||||||||||||||||
308 | } never executed: end of block | 0 | ||||||||||||||||||
309 | - | |||||||||||||||||||
310 | if (negative)
| 0 | ||||||||||||||||||
311 | result->prepend(QLatin1Char('-')); never executed: result->prepend(QLatin1Char('-')); | 0 | ||||||||||||||||||
312 | } never executed: end of block | 0 | ||||||||||||||||||
313 | - | |||||||||||||||||||
314 | ReturnedValue Runtime::method_closure(ExecutionEngine *engine, int functionId) | - | ||||||||||||||||||
315 | { | - | ||||||||||||||||||
316 | QV4::Function *clos = static_cast<CompiledData::CompilationUnit*>(engine->currentStackFrame->v4Function->compilationUnit)->runtimeFunctions[functionId]; | - | ||||||||||||||||||
317 | Q_ASSERT(clos); | - | ||||||||||||||||||
318 | ExecutionContext *current = static_cast<ExecutionContext *>(&engine->currentStackFrame->jsFrame->context); | - | ||||||||||||||||||
319 | if (clos->isGenerator())
| 6116-948890 | ||||||||||||||||||
320 | return GeneratorFunction::create(current, clos)->asReturnedValue(); executed 6111 times by 1 test: return GeneratorFunction::create(current, clos)->asReturnedValue(); Executed by:
| 6111 | ||||||||||||||||||
321 | return FunctionObject::createScriptFunction(current, clos)->asReturnedValue(); executed 949040 times by 31 tests: return FunctionObject::createScriptFunction(current, clos)->asReturnedValue(); Executed by:
| 949040 | ||||||||||||||||||
322 | } | - | ||||||||||||||||||
323 | - | |||||||||||||||||||
324 | bool Runtime::method_deleteProperty(ExecutionEngine *engine, const Value &base, const Value &index) | - | ||||||||||||||||||
325 | { | - | ||||||||||||||||||
326 | Scope scope(engine); | - | ||||||||||||||||||
327 | ScopedObject o(scope, base.toObject(engine)); | - | ||||||||||||||||||
328 | if (scope.engine->hasException)
| 0-10266 | ||||||||||||||||||
329 | return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||
330 | Q_ASSERT(o); | - | ||||||||||||||||||
331 | - | |||||||||||||||||||
332 | ScopedPropertyKey key(scope, index.toPropertyKey(engine)); | - | ||||||||||||||||||
333 | if (engine->hasException)
| 4-10289 | ||||||||||||||||||
334 | return false; executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||||||||
335 | return o->deleteProperty(key); executed 10279 times by 5 tests: return o->deleteProperty(key); Executed by:
| 10279 | ||||||||||||||||||
336 | } | - | ||||||||||||||||||
337 | - | |||||||||||||||||||
338 | bool Runtime::method_deleteName(ExecutionEngine *engine, int nameIndex) | - | ||||||||||||||||||
339 | { | - | ||||||||||||||||||
340 | Scope scope(engine); | - | ||||||||||||||||||
341 | ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
342 | return static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context).deleteProperty(name); executed 142 times by 2 tests: return static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context).deleteProperty(name); Executed by:
| 142 | ||||||||||||||||||
343 | } | - | ||||||||||||||||||
344 | - | |||||||||||||||||||
345 | QV4::ReturnedValue Runtime::method_instanceof(ExecutionEngine *engine, const Value &lval, const Value &rval) | - | ||||||||||||||||||
346 | { | - | ||||||||||||||||||
347 | // 11.8.6, 5: rval must be an Object | - | ||||||||||||||||||
348 | const Object *rhs = rval.as<Object>(); | - | ||||||||||||||||||
349 | if (!rhs)
| 22-4252218 | ||||||||||||||||||
350 | return engine->throwTypeError(); executed 22 times by 2 tests: return engine->throwTypeError(); Executed by:
| 22 | ||||||||||||||||||
351 | - | |||||||||||||||||||
352 | Scope scope(engine); | - | ||||||||||||||||||
353 | ScopedValue hasInstance(scope, rhs->get(engine->symbol_hasInstance())); | - | ||||||||||||||||||
354 | if (hasInstance->isUndefined())
| 74-4262635 | ||||||||||||||||||
355 | return rhs->instanceOf(lval); executed 74 times by 3 tests: return rhs->instanceOf(lval); Executed by:
| 74 | ||||||||||||||||||
356 | FunctionObject *f = hasInstance->as<FunctionObject>(); | - | ||||||||||||||||||
357 | if (!f)
| 4-4299623 | ||||||||||||||||||
358 | return engine->throwTypeError(); executed 4 times by 1 test: return engine->throwTypeError(); Executed by:
| 4 | ||||||||||||||||||
359 | - | |||||||||||||||||||
360 | ScopedValue result(scope, f->call(&rval, &lval, 1)); | - | ||||||||||||||||||
361 | return Encode(result->toBoolean()); executed 4301818 times by 11 tests: return Encode(result->toBoolean()); Executed by:
| 4301818 | ||||||||||||||||||
362 | } | - | ||||||||||||||||||
363 | - | |||||||||||||||||||
364 | QV4::ReturnedValue Runtime::method_in(ExecutionEngine *engine, const Value &left, const Value &right) | - | ||||||||||||||||||
365 | { | - | ||||||||||||||||||
366 | Object *ro = right.objectValue(); | - | ||||||||||||||||||
367 | if (!ro)
| 20-672 | ||||||||||||||||||
368 | return engine->throwTypeError(); executed 20 times by 1 test: return engine->throwTypeError(); Executed by:
| 20 | ||||||||||||||||||
369 | Scope scope(engine); | - | ||||||||||||||||||
370 | ScopedPropertyKey s(scope, left.toPropertyKey(engine)); | - | ||||||||||||||||||
371 | if (scope.hasException())
| 0-672 | ||||||||||||||||||
372 | return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||
373 | bool r = ro->hasProperty(s); | - | ||||||||||||||||||
374 | return Encode(r); executed 672 times by 6 tests: return Encode(r); Executed by:
| 672 | ||||||||||||||||||
375 | } | - | ||||||||||||||||||
376 | - | |||||||||||||||||||
377 | double RuntimeHelpers::stringToNumber(const QString &string) | - | ||||||||||||||||||
378 | { | - | ||||||||||||||||||
379 | const QStringRef s = QStringRef(&string).trimmed(); | - | ||||||||||||||||||
380 | if (s.startsWith(QLatin1String("0x")) || s.startsWith(QLatin1String("0X")))
| 88-262320 | ||||||||||||||||||
381 | return s.toLong(nullptr, 16); executed 262408 times by 1 test: return s.toLong(nullptr, 16); Executed by:
| 262408 | ||||||||||||||||||
382 | bool ok; | - | ||||||||||||||||||
383 | QByteArray ba = s.toLatin1(); | - | ||||||||||||||||||
384 | const char *begin = ba.constData(); | - | ||||||||||||||||||
385 | const char *end = nullptr; | - | ||||||||||||||||||
386 | double d = qstrtod(begin, &end, &ok); | - | ||||||||||||||||||
387 | if (end - begin != ba.size()) {
| 1851-7212 | ||||||||||||||||||
388 | if (ba == "Infinity" || ba == "+Infinity")
| 28-1720 | ||||||||||||||||||
389 | d = Q_INFINITY; executed 160 times by 2 tests: d = (::qInf()); Executed by:
| 160 | ||||||||||||||||||
390 | else if (ba == "-Infinity")
| 88-1604 | ||||||||||||||||||
391 | d = -Q_INFINITY; executed 88 times by 2 tests: d = -(::qInf()); Executed by:
| 88 | ||||||||||||||||||
392 | else | - | ||||||||||||||||||
393 | d = std::numeric_limits<double>::quiet_NaN(); executed 1604 times by 4 tests: d = std::numeric_limits<double>::quiet_NaN(); Executed by:
| 1604 | ||||||||||||||||||
394 | } | - | ||||||||||||||||||
395 | return d; executed 9067 times by 7 tests: return d; Executed by:
| 9067 | ||||||||||||||||||
396 | } | - | ||||||||||||||||||
397 | - | |||||||||||||||||||
398 | Heap::String *RuntimeHelpers::stringFromNumber(ExecutionEngine *engine, double number) | - | ||||||||||||||||||
399 | { | - | ||||||||||||||||||
400 | QString qstr; | - | ||||||||||||||||||
401 | RuntimeHelpers::numberToString(&qstr, number, 10); | - | ||||||||||||||||||
402 | return engine->newString(qstr); executed 3013986 times by 20 tests: return engine->newString(qstr); Executed by:
| 3013986 | ||||||||||||||||||
403 | } | - | ||||||||||||||||||
404 | - | |||||||||||||||||||
405 | ReturnedValue RuntimeHelpers::objectDefaultValue(const Object *object, int typeHint) | - | ||||||||||||||||||
406 | { | - | ||||||||||||||||||
407 | ExecutionEngine *engine = object->internalClass()->engine; | - | ||||||||||||||||||
408 | if (engine->hasException)
| 404-52222 | ||||||||||||||||||
409 | return Encode::undefined(); executed 404 times by 1 test: return Encode::undefined(); Executed by:
| 404 | ||||||||||||||||||
410 | - | |||||||||||||||||||
411 | String *hint; | - | ||||||||||||||||||
412 | switch (typeHint) { | - | ||||||||||||||||||
413 | case STRING_HINT: executed 5749 times by 25 tests: case STRING_HINT: Executed by:
| 5749 | ||||||||||||||||||
414 | hint = engine->id_string(); | - | ||||||||||||||||||
415 | break; executed 5748 times by 25 tests: break; Executed by:
| 5748 | ||||||||||||||||||
416 | case NUMBER_HINT: executed 42829 times by 6 tests: case NUMBER_HINT: Executed by:
| 42829 | ||||||||||||||||||
417 | hint = engine->id_number(); | - | ||||||||||||||||||
418 | break; executed 42829 times by 6 tests: break; Executed by:
| 42829 | ||||||||||||||||||
419 | default: executed 3638 times by 8 tests: default: Executed by:
| 3638 | ||||||||||||||||||
420 | hint = engine->id_default(); | - | ||||||||||||||||||
421 | break; executed 3634 times by 8 tests: break; Executed by:
| 3634 | ||||||||||||||||||
422 | } | - | ||||||||||||||||||
423 | - | |||||||||||||||||||
424 | Scope scope(engine); | - | ||||||||||||||||||
425 | ScopedFunctionObject toPrimitive(scope, object->get(engine->symbol_toPrimitive())); | - | ||||||||||||||||||
426 | if (engine->hasException)
| 28-52204 | ||||||||||||||||||
427 | return Encode::undefined(); executed 28 times by 1 test: return Encode::undefined(); Executed by:
| 28 | ||||||||||||||||||
428 | if (toPrimitive) {
| 19715-32482 | ||||||||||||||||||
429 | ScopedValue result(scope, toPrimitive->call(object, hint, 1)); | - | ||||||||||||||||||
430 | if (engine->hasException)
| 68-32414 | ||||||||||||||||||
431 | return Encode::undefined(); executed 68 times by 1 test: return Encode::undefined(); Executed by:
| 68 | ||||||||||||||||||
432 | if (!result->isPrimitive())
| 92-32322 | ||||||||||||||||||
433 | return engine->throwTypeError(); executed 92 times by 1 test: return engine->throwTypeError(); Executed by:
| 92 | ||||||||||||||||||
434 | return result->asReturnedValue(); executed 32322 times by 3 tests: return result->asReturnedValue(); Executed by:
| 32322 | ||||||||||||||||||
435 | } | - | ||||||||||||||||||
436 | - | |||||||||||||||||||
437 | if (hint == engine->id_default())
| 3378-16320 | ||||||||||||||||||
438 | hint = engine->id_number(); executed 3380 times by 8 tests: hint = engine->id_number(); Executed by:
| 3380 | ||||||||||||||||||
439 | return ordinaryToPrimitive(engine, object, hint); executed 19699 times by 30 tests: return ordinaryToPrimitive(engine, object, hint); Executed by:
| 19699 | ||||||||||||||||||
440 | } | - | ||||||||||||||||||
441 | - | |||||||||||||||||||
442 | - | |||||||||||||||||||
443 | ReturnedValue RuntimeHelpers::ordinaryToPrimitive(ExecutionEngine *engine, const Object *object, String *typeHint) | - | ||||||||||||||||||
444 | { | - | ||||||||||||||||||
445 | Q_ASSERT(!engine->hasException); | - | ||||||||||||||||||
446 | - | |||||||||||||||||||
447 | String *meth1 = engine->id_toString(); | - | ||||||||||||||||||
448 | String *meth2 = engine->id_valueOf(); | - | ||||||||||||||||||
449 | - | |||||||||||||||||||
450 | if (typeHint->propertyKey() == engine->id_number()->propertyKey()) {
| 5759-46039 | ||||||||||||||||||
451 | qSwap(meth1, meth2); | - | ||||||||||||||||||
452 | } else { executed 46041 times by 10 tests: end of block Executed by:
| 46041 | ||||||||||||||||||
453 | Q_ASSERT(typeHint->propertyKey() == engine->id_string()->propertyKey()); | - | ||||||||||||||||||
454 | } executed 5766 times by 25 tests: end of block Executed by:
| 5766 | ||||||||||||||||||
455 | - | |||||||||||||||||||
456 | Scope scope(engine); | - | ||||||||||||||||||
457 | ScopedValue result(scope); | - | ||||||||||||||||||
458 | - | |||||||||||||||||||
459 | ScopedValue conv(scope, object->get(meth1)); | - | ||||||||||||||||||
460 | if (FunctionObject *o = conv->as<FunctionObject>()) {
| 228-51614 | ||||||||||||||||||
461 | result = o->call(object, nullptr, 0); | - | ||||||||||||||||||
462 | if (result->isPrimitive())
| 5324-46284 | ||||||||||||||||||
463 | return result->asReturnedValue(); executed 46283 times by 26 tests: return result->asReturnedValue(); Executed by:
| 46283 | ||||||||||||||||||
464 | } executed 5323 times by 7 tests: end of block Executed by:
| 5323 | ||||||||||||||||||
465 | - | |||||||||||||||||||
466 | if (engine->hasException)
| 0-5549 | ||||||||||||||||||
467 | return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||
468 | - | |||||||||||||||||||
469 | conv = object->get(meth2); | - | ||||||||||||||||||
470 | if (FunctionObject *o = conv->as<FunctionObject>()) {
| 60-5493 | ||||||||||||||||||
471 | result = o->call(object, nullptr, 0); | - | ||||||||||||||||||
472 | if (result->isPrimitive())
| 312-5179 | ||||||||||||||||||
473 | return result->asReturnedValue(); executed 5179 times by 7 tests: return result->asReturnedValue(); Executed by:
| 5179 | ||||||||||||||||||
474 | } executed 312 times by 1 test: end of block Executed by:
| 312 | ||||||||||||||||||
475 | - | |||||||||||||||||||
476 | return engine->throwTypeError(); executed 372 times by 1 test: return engine->throwTypeError(); Executed by:
| 372 | ||||||||||||||||||
477 | } | - | ||||||||||||||||||
478 | - | |||||||||||||||||||
479 | - | |||||||||||||||||||
480 | Heap::Object *RuntimeHelpers::convertToObject(ExecutionEngine *engine, const Value &value) | - | ||||||||||||||||||
481 | { | - | ||||||||||||||||||
482 | Q_ASSERT(!value.isObject()); | - | ||||||||||||||||||
483 | switch (value.type()) { | - | ||||||||||||||||||
484 | case Value::Undefined_Type: executed 366 times by 3 tests: case Value::Undefined_Type: Executed by:
| 366 | ||||||||||||||||||
485 | engine->throwTypeError(QLatin1String("Value is undefined and could not be converted to an object")); | - | ||||||||||||||||||
486 | return nullptr; executed 366 times by 3 tests: return nullptr; Executed by:
| 366 | ||||||||||||||||||
487 | case Value::Null_Type: executed 342 times by 3 tests: case Value::Null_Type: Executed by:
| 342 | ||||||||||||||||||
488 | engine->throwTypeError(QLatin1String("Value is null and could not be converted to an object")); | - | ||||||||||||||||||
489 | return nullptr; executed 342 times by 3 tests: return nullptr; Executed by:
| 342 | ||||||||||||||||||
490 | case Value::Boolean_Type: executed 300 times by 1 test: case Value::Boolean_Type: Executed by:
| 300 | ||||||||||||||||||
491 | return engine->newBooleanObject(value.booleanValue()); executed 300 times by 1 test: return engine->newBooleanObject(value.booleanValue()); Executed by:
| 300 | ||||||||||||||||||
492 | case Value::Managed_Type: executed 44954 times by 12 tests: case Value::Managed_Type: Executed by:
| 44954 | ||||||||||||||||||
493 | Q_ASSERT(value.isStringOrSymbol()); | - | ||||||||||||||||||
494 | if (!value.isString())
| 106-44845 | ||||||||||||||||||
495 | return engine->newSymbolObject(value.symbolValue()); executed 106 times by 1 test: return engine->newSymbolObject(value.symbolValue()); Executed by:
| 106 | ||||||||||||||||||
496 | return engine->newStringObject(value.stringValue()); executed 44845 times by 12 tests: return engine->newStringObject(value.stringValue()); Executed by:
| 44845 | ||||||||||||||||||
497 | case Value::Integer_Type: executed 606 times by 7 tests: case Value::Integer_Type: Executed by:
| 606 | ||||||||||||||||||
498 | default: // double executed 638 times by 8 tests: default: Executed by:
| 638 | ||||||||||||||||||
499 | return engine->newNumberObject(value.asDouble()); executed 1244 times by 9 tests: return engine->newNumberObject(value.asDouble()); Executed by:
| 1244 | ||||||||||||||||||
500 | } | - | ||||||||||||||||||
501 | } | - | ||||||||||||||||||
502 | - | |||||||||||||||||||
503 | Heap::String *RuntimeHelpers::convertToString(ExecutionEngine *engine, Value value, TypeHint hint) | - | ||||||||||||||||||
504 | { | - | ||||||||||||||||||
505 | redo: | - | ||||||||||||||||||
506 | switch (value.type()) { | - | ||||||||||||||||||
507 | case Value::Empty_Type: never executed: case Value::Empty_Type: | 0 | ||||||||||||||||||
508 | Q_ASSERT(!"empty Value encountered"); | - | ||||||||||||||||||
509 | Q_UNREACHABLE(); | - | ||||||||||||||||||
510 | case Value::Undefined_Type: code before this statement never executed: case Value::Undefined_Type: executed 1151 times by 3 tests: case Value::Undefined_Type: Executed by:
| 0-1151 | ||||||||||||||||||
511 | return engine->id_undefined()->d(); executed 1149 times by 3 tests: return engine->id_undefined()->d(); Executed by:
| 1149 | ||||||||||||||||||
512 | case Value::Null_Type: executed 152 times by 1 test: case Value::Null_Type: Executed by:
| 152 | ||||||||||||||||||
513 | return engine->id_null()->d(); executed 152 times by 1 test: return engine->id_null()->d(); Executed by:
| 152 | ||||||||||||||||||
514 | case Value::Boolean_Type: executed 963 times by 3 tests: case Value::Boolean_Type: Executed by:
| 963 | ||||||||||||||||||
515 | if (value.booleanValue())
| 475-488 | ||||||||||||||||||
516 | return engine->id_true()->d(); executed 475 times by 3 tests: return engine->id_true()->d(); Executed by:
| 475 | ||||||||||||||||||
517 | else | - | ||||||||||||||||||
518 | return engine->id_false()->d(); executed 488 times by 2 tests: return engine->id_false()->d(); Executed by:
| 488 | ||||||||||||||||||
519 | case Value::Managed_Type: { executed 1576 times by 2 tests: case Value::Managed_Type: Executed by:
| 1576 | ||||||||||||||||||
520 | if (value.isString())
| 0-1576 | ||||||||||||||||||
521 | return static_cast<const String &>(value).d(); never executed: return static_cast<const String &>(value).d(); | 0 | ||||||||||||||||||
522 | if (value.isSymbol()) {
| 32-1545 | ||||||||||||||||||
523 | engine->throwTypeError(QLatin1String("Cannot convert a symbol to a string.")); | - | ||||||||||||||||||
524 | return nullptr; executed 32 times by 1 test: return nullptr; Executed by:
| 32 | ||||||||||||||||||
525 | } | - | ||||||||||||||||||
526 | value = Primitive::fromReturnedValue(RuntimeHelpers::toPrimitive(value, hint)); | - | ||||||||||||||||||
527 | Q_ASSERT(value.isPrimitive()); | - | ||||||||||||||||||
528 | if (value.isString())
| 375-1172 | ||||||||||||||||||
529 | return static_cast<const String &>(value).d(); executed 1171 times by 2 tests: return static_cast<const String &>(value).d(); Executed by:
| 1171 | ||||||||||||||||||
530 | goto redo; executed 372 times by 1 test: goto redo; Executed by:
| 372 | ||||||||||||||||||
531 | } | - | ||||||||||||||||||
532 | case Value::Integer_Type: executed 2614215 times by 15 tests: case Value::Integer_Type: Executed by:
| 2614215 | ||||||||||||||||||
533 | return RuntimeHelpers::stringFromNumber(engine, value.int_32()); executed 2614214 times by 15 tests: return RuntimeHelpers::stringFromNumber(engine, value.int_32()); Executed by:
| 2614214 | ||||||||||||||||||
534 | default: // double executed 399725 times by 13 tests: default: Executed by:
| 399725 | ||||||||||||||||||
535 | return RuntimeHelpers::stringFromNumber(engine, value.doubleValue()); executed 399726 times by 13 tests: return RuntimeHelpers::stringFromNumber(engine, value.doubleValue()); Executed by:
| 399726 | ||||||||||||||||||
536 | } // switch | - | ||||||||||||||||||
537 | } | - | ||||||||||||||||||
538 | - | |||||||||||||||||||
539 | // This is slightly different from the method above, as | - | ||||||||||||||||||
540 | // the + operator requires a slightly different conversion | - | ||||||||||||||||||
541 | static Heap::String *convert_to_string_add(ExecutionEngine *engine, Value value) | - | ||||||||||||||||||
542 | { | - | ||||||||||||||||||
543 | return RuntimeHelpers::convertToString(engine, value, PREFERREDTYPE_HINT); executed 2395087 times by 18 tests: return RuntimeHelpers::convertToString(engine, value, PREFERREDTYPE_HINT); Executed by:
| 2395087 | ||||||||||||||||||
544 | } | - | ||||||||||||||||||
545 | - | |||||||||||||||||||
546 | QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionEngine *engine, const Value &left, const Value &right) | - | ||||||||||||||||||
547 | { | - | ||||||||||||||||||
548 | Scope scope(engine); | - | ||||||||||||||||||
549 | - | |||||||||||||||||||
550 | ScopedValue pleft(scope, RuntimeHelpers::toPrimitive(left, PREFERREDTYPE_HINT)); | - | ||||||||||||||||||
551 | ScopedValue pright(scope, RuntimeHelpers::toPrimitive(right, PREFERREDTYPE_HINT)); | - | ||||||||||||||||||
552 | String *sleft = pleft->stringValue(); | - | ||||||||||||||||||
553 | String *sright = pright->stringValue(); | - | ||||||||||||||||||
554 | if (sleft || sright) {
| 402-57837409 | ||||||||||||||||||
555 | if (!sleft) {
| 185494-57842851 | ||||||||||||||||||
556 | pleft = convert_to_string_add(engine, pleft); | - | ||||||||||||||||||
557 | sleft = static_cast<String *>(pleft.ptr); | - | ||||||||||||||||||
558 | } executed 185496 times by 8 tests: end of block Executed by:
| 185496 | ||||||||||||||||||
559 | if (!sright) {
| 2209596-55841666 | ||||||||||||||||||
560 | pright = convert_to_string_add(engine, pright); | - | ||||||||||||||||||
561 | sright = static_cast<String *>(pright.ptr); | - | ||||||||||||||||||
562 | } executed 2209594 times by 16 tests: end of block Executed by:
| 2209594 | ||||||||||||||||||
563 | if (engine->hasException)
| 32-58183347 | ||||||||||||||||||
564 | return Encode::undefined(); executed 32 times by 1 test: return Encode::undefined(); Executed by:
| 32 | ||||||||||||||||||
565 | if (!sleft->d()->length())
| 271322-57979299 | ||||||||||||||||||
566 | return sright->asReturnedValue(); executed 271321 times by 7 tests: return sright->asReturnedValue(); Executed by:
| 271321 | ||||||||||||||||||
567 | if (!sright->d()->length())
| 1139831-57028952 | ||||||||||||||||||
568 | return sleft->asReturnedValue(); executed 1139709 times by 6 tests: return sleft->asReturnedValue(); Executed by:
| 1139709 | ||||||||||||||||||
569 | MemoryManager *mm = engine->memoryManager; | - | ||||||||||||||||||
570 | return (mm->alloc<ComplexString>(sleft->d(), sright->d()))->asReturnedValue(); executed 56942701 times by 35 tests: return (mm->alloc<ComplexString>(sleft->d(), sright->d()))->asReturnedValue(); Executed by:
| 56942701 | ||||||||||||||||||
571 | } | - | ||||||||||||||||||
572 | double x = RuntimeHelpers::toNumber(pleft); | - | ||||||||||||||||||
573 | double y = RuntimeHelpers::toNumber(pright); | - | ||||||||||||||||||
574 | return Encode(x + y); executed 402 times by 3 tests: return Encode(x + y); Executed by:
| 402 | ||||||||||||||||||
575 | } | - | ||||||||||||||||||
576 | - | |||||||||||||||||||
577 | void Runtime::method_storeProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value) | - | ||||||||||||||||||
578 | { | - | ||||||||||||||||||
579 | Scope scope(engine); | - | ||||||||||||||||||
580 | QV4::Function *v4Function = engine->currentStackFrame->v4Function; | - | ||||||||||||||||||
581 | ScopedString name(scope, v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
582 | ScopedObject o(scope, object.toObject(engine)); | - | ||||||||||||||||||
583 | if ((!o || !o->put(name, value)) && v4Function->isStrict())
| 0-52630 | ||||||||||||||||||
584 | engine->throwTypeError(); never executed: engine->throwTypeError(); | 0 | ||||||||||||||||||
585 | } executed 52634 times by 66 tests: end of block Executed by:
| 52634 | ||||||||||||||||||
586 | - | |||||||||||||||||||
587 | static Q_NEVER_INLINE ReturnedValue getElementIntFallback(ExecutionEngine *engine, const Value &object, uint idx) | - | ||||||||||||||||||
588 | { | - | ||||||||||||||||||
589 | Q_ASSERT(idx < UINT_MAX); | - | ||||||||||||||||||
590 | Scope scope(engine); | - | ||||||||||||||||||
591 | - | |||||||||||||||||||
592 | ScopedObject o(scope, object); | - | ||||||||||||||||||
593 | if (!o) {
| 95522-24770144 | ||||||||||||||||||
594 | if (const String *str = object.as<String>()) {
| 57-24804282 | ||||||||||||||||||
595 | if (idx >= (uint)str->toQString().length()) {
| 38-25127630 | ||||||||||||||||||
596 | return Encode::undefined(); executed 38 times by 2 tests: return Encode::undefined(); Executed by:
| 38 | ||||||||||||||||||
597 | } | - | ||||||||||||||||||
598 | const QString s = str->toQString().mid(idx, 1); | - | ||||||||||||||||||
599 | return scope.engine->newString(s)->asReturnedValue(); executed 25086857 times by 3 tests: return scope.engine->newString(s)->asReturnedValue(); Executed by:
| 25086857 | ||||||||||||||||||
600 | } | - | ||||||||||||||||||
601 | - | |||||||||||||||||||
602 | if (object.isNullOrUndefined()) {
| 4-54 | ||||||||||||||||||
603 | QString message = QStringLiteral("Cannot read property '%1' of %2").arg(idx).arg(object.toQStringNoThrow()); | - | ||||||||||||||||||
604 | return engine->throwTypeError(message); executed 53 times by 1 test: return engine->throwTypeError(message); Executed by:
| 53 | ||||||||||||||||||
605 | } | - | ||||||||||||||||||
606 | - | |||||||||||||||||||
607 | o = RuntimeHelpers::convertToObject(scope.engine, object); | - | ||||||||||||||||||
608 | Q_ASSERT(!!o); // can't fail as null/undefined is covered above | - | ||||||||||||||||||
609 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
610 | - | |||||||||||||||||||
611 | if (o->arrayData() && !o->arrayData()->attrs) {
| 519-70912 | ||||||||||||||||||
612 | ScopedValue v(scope, o->arrayData()->get(idx)); | - | ||||||||||||||||||
613 | if (!v->isEmpty())
| 128-70267 | ||||||||||||||||||
614 | return v->asReturnedValue(); executed 128 times by 1 test: return v->asReturnedValue(); Executed by:
| 128 | ||||||||||||||||||
615 | } executed 70267 times by 16 tests: end of block Executed by:
| 70267 | ||||||||||||||||||
616 | - | |||||||||||||||||||
617 | return o->get(idx); executed 95391 times by 19 tests: return o->get(idx); Executed by:
| 95391 | ||||||||||||||||||
618 | } | - | ||||||||||||||||||
619 | - | |||||||||||||||||||
620 | static Q_NEVER_INLINE ReturnedValue getElementFallback(ExecutionEngine *engine, const Value &object, const Value &index) | - | ||||||||||||||||||
621 | { | - | ||||||||||||||||||
622 | Q_ASSERT(!index.isPositiveInt()); | - | ||||||||||||||||||
623 | - | |||||||||||||||||||
624 | Scope scope(engine); | - | ||||||||||||||||||
625 | - | |||||||||||||||||||
626 | ScopedObject o(scope, object); | - | ||||||||||||||||||
627 | if (!o) {
| 146-56286 | ||||||||||||||||||
628 | if (object.isNullOrUndefined()) {
| 17-130 | ||||||||||||||||||
629 | QString message = QStringLiteral("Cannot read property '%1' of %2").arg(index.toQStringNoThrow()).arg(object.toQStringNoThrow()); | - | ||||||||||||||||||
630 | return engine->throwTypeError(message); executed 130 times by 2 tests: return engine->throwTypeError(message); Executed by:
| 130 | ||||||||||||||||||
631 | } | - | ||||||||||||||||||
632 | - | |||||||||||||||||||
633 | o = RuntimeHelpers::convertToObject(scope.engine, object); | - | ||||||||||||||||||
634 | Q_ASSERT(!!o); // can't fail as null/undefined is covered above | - | ||||||||||||||||||
635 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||
636 | - | |||||||||||||||||||
637 | ScopedPropertyKey name(scope, index.toPropertyKey(engine)); | - | ||||||||||||||||||
638 | if (scope.hasException())
| 532-55842 | ||||||||||||||||||
639 | return Encode::undefined(); executed 532 times by 1 test: return Encode::undefined(); Executed by:
| 532 | ||||||||||||||||||
640 | return o->get(name); executed 55810 times by 14 tests: return o->get(name); Executed by:
| 55810 | ||||||||||||||||||
641 | } | - | ||||||||||||||||||
642 | - | |||||||||||||||||||
643 | ReturnedValue Runtime::method_loadElement(ExecutionEngine *engine, const Value &object, const Value &index) | - | ||||||||||||||||||
644 | { | - | ||||||||||||||||||
645 | if (index.isPositiveInt()) {
| 56402-34286590 | ||||||||||||||||||
646 | uint idx = static_cast<uint>(index.int_32()); | - | ||||||||||||||||||
647 | if (Heap::Base *b = object.heapObject()) {
| 56-34497689 | ||||||||||||||||||
648 | if (b->internalClass->vtable->isObject) {
| 9612362-24955547 | ||||||||||||||||||
649 | Heap::Object *o = static_cast<Heap::Object *>(b); | - | ||||||||||||||||||
650 | if (o->arrayData && o->arrayData->type == Heap::ArrayData::Simple) {
| 70115-9557515 | ||||||||||||||||||
651 | Heap::SimpleArrayData *s = o->arrayData.cast<Heap::SimpleArrayData>(); | - | ||||||||||||||||||
652 | if (idx < s->values.size)
| 436-9594647 | ||||||||||||||||||
653 | if (!s->data(idx).isEmpty())
| 364-9438642 | ||||||||||||||||||
654 | return s->data(idx).asReturnedValue(); executed 9423221 times by 15 tests: return s->data(idx).asReturnedValue(); Executed by:
| 9423221 | ||||||||||||||||||
655 | } executed 800 times by 1 test: end of block Executed by:
| 800 | ||||||||||||||||||
656 | } executed 95544 times by 19 tests: end of block Executed by:
| 95544 | ||||||||||||||||||
657 | } executed 25053953 times by 19 tests: end of block Executed by:
| 25053953 | ||||||||||||||||||
658 | return getElementIntFallback(engine, object, idx); executed 25071920 times by 19 tests: return getElementIntFallback(engine, object, idx); Executed by:
| 25071920 | ||||||||||||||||||
659 | } | - | ||||||||||||||||||
660 | - | |||||||||||||||||||
661 | return getElementFallback(engine, object, index); executed 56403 times by 14 tests: return getElementFallback(engine, object, index); Executed by:
| 56403 | ||||||||||||||||||
662 | } | - | ||||||||||||||||||
663 | - | |||||||||||||||||||
664 | static Q_NEVER_INLINE bool setElementFallback(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) | - | ||||||||||||||||||
665 | { | - | ||||||||||||||||||
666 | Scope scope(engine); | - | ||||||||||||||||||
667 | ScopedObject o(scope, object.toObject(engine)); | - | ||||||||||||||||||
668 | if (engine->hasException)
| 0-72043 | ||||||||||||||||||
669 | return false; never executed: return false; | 0 | ||||||||||||||||||
670 | - | |||||||||||||||||||
671 | if (index.isPositiveInt()) {
| 25633-46447 | ||||||||||||||||||
672 | uint idx = static_cast<uint>(index.int_32()); | - | ||||||||||||||||||
673 | if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) {
| 553-25729 | ||||||||||||||||||
674 | Heap::SimpleArrayData *s = o->d()->arrayData.cast<Heap::SimpleArrayData>(); | - | ||||||||||||||||||
675 | if (idx < s->values.size) {
| 0-25726 | ||||||||||||||||||
676 | s->setData(engine, idx, value); | - | ||||||||||||||||||
677 | return true; never executed: return true; | 0 | ||||||||||||||||||
678 | } | - | ||||||||||||||||||
679 | } executed 25727 times by 4 tests: end of block Executed by:
| 25727 | ||||||||||||||||||
680 | return o->put(idx, value); executed 46450 times by 7 tests: return o->put(idx, value); Executed by:
| 46450 | ||||||||||||||||||
681 | } | - | ||||||||||||||||||
682 | - | |||||||||||||||||||
683 | ScopedPropertyKey name(scope, index.toPropertyKey(engine)); | - | ||||||||||||||||||
684 | if (engine->hasException)
| 60-25571 | ||||||||||||||||||
685 | return false; executed 60 times by 1 test: return false; Executed by:
| 60 | ||||||||||||||||||
686 | return o->put(name, value); executed 25590 times by 8 tests: return o->put(name, value); Executed by:
| 25590 | ||||||||||||||||||
687 | } | - | ||||||||||||||||||
688 | - | |||||||||||||||||||
689 | void Runtime::method_storeElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) | - | ||||||||||||||||||
690 | { | - | ||||||||||||||||||
691 | if (index.isPositiveInt()) {
| 25588-49814 | ||||||||||||||||||
692 | uint idx = static_cast<uint>(index.int_32()); | - | ||||||||||||||||||
693 | if (Heap::Base *b = object.heapObject()) {
| 0-49822 | ||||||||||||||||||
694 | if (b->internalClass->vtable->isObject) {
| 4-49823 | ||||||||||||||||||
695 | Heap::Object *o = static_cast<Heap::Object *>(b); | - | ||||||||||||||||||
696 | if (o->arrayData && o->arrayData->type == Heap::ArrayData::Simple) {
| 553-29104 | ||||||||||||||||||
697 | Heap::SimpleArrayData *s = o->arrayData.cast<Heap::SimpleArrayData>(); | - | ||||||||||||||||||
698 | if (idx < s->values.size) {
| 3372-25728 | ||||||||||||||||||
699 | s->setData(engine, idx, value); | - | ||||||||||||||||||
700 | return; executed 3370 times by 3 tests: return; Executed by:
| 3370 | ||||||||||||||||||
701 | } | - | ||||||||||||||||||
702 | } executed 25728 times by 4 tests: end of block Executed by:
| 25728 | ||||||||||||||||||
703 | } executed 46448 times by 7 tests: end of block Executed by:
| 46448 | ||||||||||||||||||
704 | } executed 46454 times by 7 tests: end of block Executed by:
| 46454 | ||||||||||||||||||
705 | } executed 46456 times by 7 tests: end of block Executed by:
| 46456 | ||||||||||||||||||
706 | - | |||||||||||||||||||
707 | if (!setElementFallback(engine, object, index, value) && engine->currentStackFrame->v4Function->isStrict())
| 2478-67057 | ||||||||||||||||||
708 | engine->throwTypeError(); executed 2473 times by 1 test: engine->throwTypeError(); Executed by:
| 2473 | ||||||||||||||||||
709 | } executed 72098 times by 11 tests: end of block Executed by:
| 72098 | ||||||||||||||||||
710 | - | |||||||||||||||||||
711 | ReturnedValue Runtime::method_getIterator(ExecutionEngine *engine, const Value &in, int iterator) | - | ||||||||||||||||||
712 | { | - | ||||||||||||||||||
713 | Scope scope(engine); | - | ||||||||||||||||||
714 | ScopedObject o(scope, (Object *)nullptr); | - | ||||||||||||||||||
715 | if (!in.isNullOrUndefined())
| 460-23158 | ||||||||||||||||||
716 | o = in.toObject(engine); executed 23160 times by 12 tests: o = in.toObject(engine); Executed by:
| 23160 | ||||||||||||||||||
717 | if (engine->hasException)
| 0-23661 | ||||||||||||||||||
718 | return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||
719 | if (iterator) {
| 9100-14565 | ||||||||||||||||||
720 | if (!o)
| 416-14132 | ||||||||||||||||||
721 | return engine->throwTypeError(); executed 416 times by 1 test: return engine->throwTypeError(); Executed by:
| 416 | ||||||||||||||||||
722 | ScopedFunctionObject f(scope, o->get(engine->symbol_iterator())); | - | ||||||||||||||||||
723 | if (!f)
| 108-14094 | ||||||||||||||||||
724 | return engine->throwTypeError(); executed 108 times by 1 test: return engine->throwTypeError(); Executed by:
| 108 | ||||||||||||||||||
725 | JSCallData cData(scope, 0, nullptr, o); | - | ||||||||||||||||||
726 | ScopedObject it(scope, f->call(cData)); | - | ||||||||||||||||||
727 | if (!it)
| 256-13779 | ||||||||||||||||||
728 | return engine->throwTypeError(); executed 256 times by 1 test: return engine->throwTypeError(); Executed by:
| 256 | ||||||||||||||||||
729 | return it->asReturnedValue(); executed 13753 times by 1 test: return it->asReturnedValue(); Executed by:
| 13753 | ||||||||||||||||||
730 | } | - | ||||||||||||||||||
731 | return engine->newForInIteratorObject(o)->asReturnedValue(); executed 9080 times by 12 tests: return engine->newForInIteratorObject(o)->asReturnedValue(); Executed by:
| 9080 | ||||||||||||||||||
732 | } | - | ||||||||||||||||||
733 | - | |||||||||||||||||||
734 | ReturnedValue Runtime::method_iteratorNext(ExecutionEngine *engine, const Value &iterator, Value *value) | - | ||||||||||||||||||
735 | { | - | ||||||||||||||||||
736 | Q_ASSERT(iterator.isObject()); | - | ||||||||||||||||||
737 | - | |||||||||||||||||||
738 | Scope scope(engine); | - | ||||||||||||||||||
739 | ScopedFunctionObject f(scope, static_cast<const Object &>(iterator).get(engine->id_next())); | - | ||||||||||||||||||
740 | if (!f)
| 36-51374 | ||||||||||||||||||
741 | return engine->throwTypeError(); executed 36 times by 1 test: return engine->throwTypeError(); Executed by:
| 36 | ||||||||||||||||||
742 | JSCallData cData(scope, 0, nullptr, &iterator); | - | ||||||||||||||||||
743 | ScopedObject o(scope, f->call(cData)); | - | ||||||||||||||||||
744 | if (!o)
| 815-50443 | ||||||||||||||||||
745 | return engine->throwTypeError(); executed 815 times by 1 test: return engine->throwTypeError(); Executed by:
| 815 | ||||||||||||||||||
746 | ScopedValue d(scope, o->get(engine->id_done())); | - | ||||||||||||||||||
747 | bool done = d->toBoolean(); | - | ||||||||||||||||||
748 | if (done) {
| 16734-33726 | ||||||||||||||||||
749 | *value = Encode::undefined(); | - | ||||||||||||||||||
750 | } else { executed 16732 times by 12 tests: end of block Executed by:
| 16732 | ||||||||||||||||||
751 | *value = o->get(engine->id_value()); | - | ||||||||||||||||||
752 | } executed 33811 times by 12 tests: end of block Executed by:
| 33811 | ||||||||||||||||||
753 | return Encode(done); executed 50519 times by 12 tests: return Encode(done); Executed by:
| 50519 | ||||||||||||||||||
754 | } | - | ||||||||||||||||||
755 | - | |||||||||||||||||||
756 | ReturnedValue Runtime::method_iteratorClose(ExecutionEngine *engine, const Value &iterator, const Value &done) | - | ||||||||||||||||||
757 | { | - | ||||||||||||||||||
758 | Q_ASSERT(iterator.isObject()); | - | ||||||||||||||||||
759 | Q_ASSERT(done.isBoolean()); | - | ||||||||||||||||||
760 | if (done.booleanValue())
| 3107-3606 | ||||||||||||||||||
761 | return Encode::undefined(); executed 3107 times by 1 test: return Encode::undefined(); Executed by:
| 3107 | ||||||||||||||||||
762 | - | |||||||||||||||||||
763 | Scope scope(engine); | - | ||||||||||||||||||
764 | bool hadException = engine->hasException; | - | ||||||||||||||||||
765 | ScopedValue e(scope); | - | ||||||||||||||||||
766 | if (hadException) {
| 16-3584 | ||||||||||||||||||
767 | e = *engine->exceptionValue; | - | ||||||||||||||||||
768 | engine->hasException = false; | - | ||||||||||||||||||
769 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||
770 | ScopedFunctionObject f(scope, static_cast<const Object &>(iterator).get(engine->id_return())); | - | ||||||||||||||||||
771 | ScopedObject o(scope); | - | ||||||||||||||||||
772 | if (f) {
| 671-2937 | ||||||||||||||||||
773 | JSCallData cData(scope, 0, nullptr, &iterator); | - | ||||||||||||||||||
774 | o = f->call(cData); | - | ||||||||||||||||||
775 | } executed 672 times by 1 test: end of block Executed by:
| 672 | ||||||||||||||||||
776 | if (hadException || !f) {
| 16-3591 | ||||||||||||||||||
777 | *engine->exceptionValue = e; | - | ||||||||||||||||||
778 | engine->hasException = hadException; | - | ||||||||||||||||||
779 | return Encode::undefined(); executed 2948 times by 1 test: return Encode::undefined(); Executed by:
| 2948 | ||||||||||||||||||
780 | } | - | ||||||||||||||||||
781 | if (engine->hasException)
| 40-620 | ||||||||||||||||||
782 | return Encode::undefined(); executed 40 times by 1 test: return Encode::undefined(); Executed by:
| 40 | ||||||||||||||||||
783 | - | |||||||||||||||||||
784 | if (!o)
| 44-576 | ||||||||||||||||||
785 | return engine->throwTypeError(); executed 44 times by 1 test: return engine->throwTypeError(); Executed by:
| 44 | ||||||||||||||||||
786 | return Encode::undefined(); executed 576 times by 1 test: return Encode::undefined(); Executed by:
| 576 | ||||||||||||||||||
787 | } | - | ||||||||||||||||||
788 | - | |||||||||||||||||||
789 | ReturnedValue Runtime::method_destructureRestElement(ExecutionEngine *engine, const Value &iterator) | - | ||||||||||||||||||
790 | { | - | ||||||||||||||||||
791 | Q_ASSERT(iterator.isObject()); | - | ||||||||||||||||||
792 | - | |||||||||||||||||||
793 | Scope scope(engine); | - | ||||||||||||||||||
794 | ScopedArrayObject array(scope, engine->newArrayObject()); | - | ||||||||||||||||||
795 | array->arrayCreate(); | - | ||||||||||||||||||
796 | uint index = 0; | - | ||||||||||||||||||
797 | while (1) { | - | ||||||||||||||||||
798 | ScopedValue n(scope); | - | ||||||||||||||||||
799 | ScopedValue done(scope, method_iteratorNext(engine, iterator, n)); | - | ||||||||||||||||||
800 | if (engine->hasException)
| 360-7580 | ||||||||||||||||||
801 | return Encode::undefined(); executed 360 times by 1 test: return Encode::undefined(); Executed by:
| 360 | ||||||||||||||||||
802 | Q_ASSERT(done->isBoolean()); | - | ||||||||||||||||||
803 | if (done->booleanValue())
| 2252-5328 | ||||||||||||||||||
804 | break; executed 2252 times by 1 test: break; Executed by:
| 2252 | ||||||||||||||||||
805 | array->arraySet(index, n); | - | ||||||||||||||||||
806 | ++index; | - | ||||||||||||||||||
807 | } executed 5324 times by 1 test: end of block Executed by:
| 5324 | ||||||||||||||||||
808 | return array->asReturnedValue(); executed 2252 times by 1 test: return array->asReturnedValue(); Executed by:
| 2252 | ||||||||||||||||||
809 | } | - | ||||||||||||||||||
810 | - | |||||||||||||||||||
811 | void Runtime::method_storeNameSloppy(ExecutionEngine *engine, int nameIndex, const Value &value) | - | ||||||||||||||||||
812 | { | - | ||||||||||||||||||
813 | Scope scope(engine); | - | ||||||||||||||||||
814 | ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
815 | ExecutionContext::Error e = static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context).setProperty(name, value); | - | ||||||||||||||||||
816 | - | |||||||||||||||||||
817 | if (e == ExecutionContext::RangeError)
| 655-37125187 | ||||||||||||||||||
818 | engine->globalObject->put(name, value); executed 655 times by 3 tests: engine->globalObject->put(name, value); Executed by:
| 655 | ||||||||||||||||||
819 | } executed 37129448 times by 41 tests: end of block Executed by:
| 37129448 | ||||||||||||||||||
820 | - | |||||||||||||||||||
821 | void Runtime::method_storeNameStrict(ExecutionEngine *engine, int nameIndex, const Value &value) | - | ||||||||||||||||||
822 | { | - | ||||||||||||||||||
823 | Scope scope(engine); | - | ||||||||||||||||||
824 | ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
825 | ExecutionContext::Error e = static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context).setProperty(name, value); | - | ||||||||||||||||||
826 | if (e == ExecutionContext::TypeError)
| 100-36249757 | ||||||||||||||||||
827 | engine->throwTypeError(); executed 99 times by 1 test: engine->throwTypeError(); Executed by:
| 99 | ||||||||||||||||||
828 | else if (e == ExecutionContext::RangeError)
| 132-36250661 | ||||||||||||||||||
829 | engine->throwReferenceError(name); executed 132 times by 1 test: engine->throwReferenceError(name); Executed by:
| 132 | ||||||||||||||||||
830 | } executed 36253804 times by 4 tests: end of block Executed by:
| 36253804 | ||||||||||||||||||
831 | - | |||||||||||||||||||
832 | ReturnedValue Runtime::method_loadProperty(ExecutionEngine *engine, const Value &object, int nameIndex) | - | ||||||||||||||||||
833 | { | - | ||||||||||||||||||
834 | Scope scope(engine); | - | ||||||||||||||||||
835 | ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
836 | - | |||||||||||||||||||
837 | ScopedObject o(scope, object); | - | ||||||||||||||||||
838 | if (o)
| 44920-1174858 | ||||||||||||||||||
839 | return o->get(name); executed 1174858 times by 97 tests: return o->get(name); Executed by:
| 1174858 | ||||||||||||||||||
840 | - | |||||||||||||||||||
841 | if (object.isNullOrUndefined()) {
| 190-44730 | ||||||||||||||||||
842 | QString message = QStringLiteral("Cannot read property '%1' of %2").arg(name->toQString()).arg(object.toQStringNoThrow()); | - | ||||||||||||||||||
843 | return engine->throwTypeError(message); executed 190 times by 14 tests: return engine->throwTypeError(message); Executed by:
| 190 | ||||||||||||||||||
844 | } | - | ||||||||||||||||||
845 | - | |||||||||||||||||||
846 | o = RuntimeHelpers::convertToObject(scope.engine, object); | - | ||||||||||||||||||
847 | if (!o) // type error
| 0-44730 | ||||||||||||||||||
848 | return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||
849 | return o->get(name); executed 44730 times by 11 tests: return o->get(name); Executed by:
| 44730 | ||||||||||||||||||
850 | } | - | ||||||||||||||||||
851 | - | |||||||||||||||||||
852 | ReturnedValue Runtime::method_loadName(ExecutionEngine *engine, int nameIndex) | - | ||||||||||||||||||
853 | { | - | ||||||||||||||||||
854 | Scope scope(engine); | - | ||||||||||||||||||
855 | ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
856 | return static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context).getProperty(name); executed 5530077 times by 89 tests: return static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context).getProperty(name); Executed by:
| 5530077 | ||||||||||||||||||
857 | } | - | ||||||||||||||||||
858 | - | |||||||||||||||||||
859 | ReturnedValue Runtime::method_loadSuperProperty(ExecutionEngine *engine, const Value &property) | - | ||||||||||||||||||
860 | { | - | ||||||||||||||||||
861 | Scope scope(engine); | - | ||||||||||||||||||
862 | ScopedObject base(scope, engine->currentStackFrame->thisObject()); | - | ||||||||||||||||||
863 | if (!base)
| 44-243 | ||||||||||||||||||
864 | return engine->throwTypeError(); executed 44 times by 1 test: return engine->throwTypeError(); Executed by:
| 44 | ||||||||||||||||||
865 | ScopedObject proto(scope, base->getPrototypeOf()); | - | ||||||||||||||||||
866 | if (!proto)
| 0-243 | ||||||||||||||||||
867 | return engine->throwTypeError(); never executed: return engine->throwTypeError(); | 0 | ||||||||||||||||||
868 | ScopedPropertyKey key(scope, property.toPropertyKey(engine)); | - | ||||||||||||||||||
869 | if (engine->hasException)
| 0-242 | ||||||||||||||||||
870 | return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||
871 | return proto->get(key, base); executed 242 times by 1 test: return proto->get(key, base); Executed by:
| 242 | ||||||||||||||||||
872 | } | - | ||||||||||||||||||
873 | - | |||||||||||||||||||
874 | void Runtime::method_storeSuperProperty(ExecutionEngine *engine, const Value &property, const Value &value) | - | ||||||||||||||||||
875 | { | - | ||||||||||||||||||
876 | Scope scope(engine); | - | ||||||||||||||||||
877 | ScopedObject base(scope, engine->currentStackFrame->thisObject()); | - | ||||||||||||||||||
878 | if (!base) {
| 0-40 | ||||||||||||||||||
879 | engine->throwTypeError(); | - | ||||||||||||||||||
880 | return; never executed: return; | 0 | ||||||||||||||||||
881 | } | - | ||||||||||||||||||
882 | ScopedObject proto(scope, base->getPrototypeOf()); | - | ||||||||||||||||||
883 | if (!proto) {
| 0-40 | ||||||||||||||||||
884 | engine->throwTypeError(); | - | ||||||||||||||||||
885 | return; never executed: return; | 0 | ||||||||||||||||||
886 | } | - | ||||||||||||||||||
887 | ScopedPropertyKey key(scope, property.toPropertyKey(engine)); | - | ||||||||||||||||||
888 | if (engine->hasException)
| 0-40 | ||||||||||||||||||
889 | return; never executed: return; | 0 | ||||||||||||||||||
890 | bool result = proto->put(key, value, base); | - | ||||||||||||||||||
891 | if (!result && engine->currentStackFrame->v4Function->isStrict())
| 0-40 | ||||||||||||||||||
892 | engine->throwTypeError(); never executed: engine->throwTypeError(); | 0 | ||||||||||||||||||
893 | } executed 40 times by 1 test: end of block Executed by:
| 40 | ||||||||||||||||||
894 | - | |||||||||||||||||||
895 | #endif // V4_BOOTSTRAP | - | ||||||||||||||||||
896 | - | |||||||||||||||||||
897 | uint RuntimeHelpers::equalHelper(const Value &x, const Value &y) | - | ||||||||||||||||||
898 | { | - | ||||||||||||||||||
899 | Q_ASSERT(x.type() != y.type() || (x.isManaged() && (x.isString() != y.isString()))); | - | ||||||||||||||||||
900 | - | |||||||||||||||||||
901 | if (x.isNumber() && y.isNumber())
| 0 | ||||||||||||||||||
902 | return x.asDouble() == y.asDouble(); never executed: return x.asDouble() == y.asDouble(); | 0 | ||||||||||||||||||
903 | if (x.isNull() && y.isUndefined()) {
| 0 | ||||||||||||||||||
904 | return true; never executed: return true; | 0 | ||||||||||||||||||
905 | } else if (x.isUndefined() && y.isNull()) {
| 0 | ||||||||||||||||||
906 | return true; never executed: return true; | 0 | ||||||||||||||||||
907 | } else if (x.isNumber() && y.isString()) {
| 0 | ||||||||||||||||||
908 | double dy = RuntimeHelpers::toNumber(y); | - | ||||||||||||||||||
909 | return x.asDouble() == dy; never executed: return x.asDouble() == dy; | 0 | ||||||||||||||||||
910 | } else if (x.isString() && y.isNumber()) {
| 0 | ||||||||||||||||||
911 | double dx = RuntimeHelpers::toNumber(x); | - | ||||||||||||||||||
912 | return dx == y.asDouble(); never executed: return dx == y.asDouble(); | 0 | ||||||||||||||||||
913 | } else if (x.isBoolean()) {
| 0 | ||||||||||||||||||
914 | return Runtime::method_compareEqual(Primitive::fromDouble((double) x.booleanValue()), y); never executed: return Runtime::method_compareEqual(Primitive::fromDouble((double) x.booleanValue()), y); | 0 | ||||||||||||||||||
915 | } else if (y.isBoolean()) {
| 0 | ||||||||||||||||||
916 | return Runtime::method_compareEqual(x, Primitive::fromDouble((double) y.booleanValue())); never executed: return Runtime::method_compareEqual(x, Primitive::fromDouble((double) y.booleanValue())); | 0 | ||||||||||||||||||
917 | } else { | - | ||||||||||||||||||
918 | #ifdef V4_BOOTSTRAP | - | ||||||||||||||||||
919 | Q_UNIMPLEMENTED(); | - | ||||||||||||||||||
920 | #else | - | ||||||||||||||||||
921 | Object *xo = x.objectValue(); | - | ||||||||||||||||||
922 | Object *yo = y.objectValue(); | - | ||||||||||||||||||
923 | if (yo && (x.isNumber() || x.isString())) {
| 0 | ||||||||||||||||||
924 | Scope scope(yo->engine()); | - | ||||||||||||||||||
925 | ScopedValue py(scope, RuntimeHelpers::objectDefaultValue(yo, PREFERREDTYPE_HINT)); | - | ||||||||||||||||||
926 | return Runtime::method_compareEqual(x, py); never executed: return Runtime::method_compareEqual(x, py); | 0 | ||||||||||||||||||
927 | } else if (xo && (y.isNumber() || y.isString())) {
| 0 | ||||||||||||||||||
928 | Scope scope(xo->engine()); | - | ||||||||||||||||||
929 | ScopedValue px(scope, RuntimeHelpers::objectDefaultValue(xo, PREFERREDTYPE_HINT)); | - | ||||||||||||||||||
930 | return Runtime::method_compareEqual(px, y); never executed: return Runtime::method_compareEqual(px, y); | 0 | ||||||||||||||||||
931 | } | - | ||||||||||||||||||
932 | #endif | - | ||||||||||||||||||
933 | } never executed: end of block | 0 | ||||||||||||||||||
934 | - | |||||||||||||||||||
935 | return false; never executed: return false; | 0 | ||||||||||||||||||
936 | } | - | ||||||||||||||||||
937 | - | |||||||||||||||||||
938 | Bool RuntimeHelpers::strictEqual(const Value &x, const Value &y) | - | ||||||||||||||||||
939 | { | - | ||||||||||||||||||
940 | TRACE2(x, y); | - | ||||||||||||||||||
941 | - | |||||||||||||||||||
942 | if (x.rawValue() == y.rawValue())
| 16337-31668862 | ||||||||||||||||||
943 | // NaN != NaN | - | ||||||||||||||||||
944 | return !x.isNaN(); executed 16337 times by 10 tests: return !x.isNaN(); Executed by:
| 16337 | ||||||||||||||||||
945 | - | |||||||||||||||||||
946 | if (x.isNumber())
| 13114268-18551307 | ||||||||||||||||||
947 | return y.isNumber() && x.asDouble() == y.asDouble(); executed 18551304 times by 15 tests: return y.isNumber() && x.asDouble() == y.asDouble(); Executed by:
| 18551304 | ||||||||||||||||||
948 | if (x.isManaged())
| 297603-12838325 | ||||||||||||||||||
949 | return y.isManaged() && x.cast<Managed>()->isEqualTo(y.cast<Managed>()); executed 12839433 times by 15 tests: return y.isManaged() && x.cast<Managed>()->isEqualTo(y.cast<Managed>()); Executed by:
| 12839433 | ||||||||||||||||||
950 | return false; executed 297615 times by 9 tests: return false; Executed by:
| 297615 | ||||||||||||||||||
951 | } | - | ||||||||||||||||||
952 | - | |||||||||||||||||||
953 | QV4::Bool Runtime::method_compareGreaterThan(const Value &l, const Value &r) | - | ||||||||||||||||||
954 | { | - | ||||||||||||||||||
955 | TRACE2(l, r); | - | ||||||||||||||||||
956 | if (l.isInteger() && r.isInteger())
| 39-3684 | ||||||||||||||||||
957 | return l.integerValue() > r.integerValue(); executed 38 times by 1 test: return l.integerValue() > r.integerValue(); Executed by:
| 38 | ||||||||||||||||||
958 | if (l.isNumber() && r.isNumber())
| 87-2730 | ||||||||||||||||||
959 | return l.asDouble() > r.asDouble(); executed 2642 times by 9 tests: return l.asDouble() > r.asDouble(); Executed by:
| 2642 | ||||||||||||||||||
960 | String *sl = l.stringValue(); | - | ||||||||||||||||||
961 | String *sr = r.stringValue(); | - | ||||||||||||||||||
962 | if (sl && sr) {
| 64-703 | ||||||||||||||||||
963 | #ifdef V4_BOOTSTRAP | - | ||||||||||||||||||
964 | Q_UNIMPLEMENTED(); | - | ||||||||||||||||||
965 | return false; | - | ||||||||||||||||||
966 | #else | - | ||||||||||||||||||
967 | return sr->compare(sl); executed 639 times by 1 test: return sr->compare(sl); Executed by:
| 639 | ||||||||||||||||||
968 | #endif | - | ||||||||||||||||||
969 | } | - | ||||||||||||||||||
970 | - | |||||||||||||||||||
971 | Object *ro = r.objectValue(); | - | ||||||||||||||||||
972 | Object *lo = l.objectValue(); | - | ||||||||||||||||||
973 | if (ro || lo) {
| 76-323 | ||||||||||||||||||
974 | #ifdef V4_BOOTSTRAP | - | ||||||||||||||||||
975 | Q_UNIMPLEMENTED(); | - | ||||||||||||||||||
976 | #else | - | ||||||||||||||||||
977 | QV4::ExecutionEngine *e = (lo ? lo : ro)->engine();
| 76-146 | ||||||||||||||||||
978 | QV4::Scope scope(e); | - | ||||||||||||||||||
979 | QV4::ScopedValue pl(scope, lo ? RuntimeHelpers::objectDefaultValue(lo, QV4::NUMBER_HINT) : l.asReturnedValue()); | - | ||||||||||||||||||
980 | QV4::ScopedValue pr(scope, ro ? RuntimeHelpers::objectDefaultValue(ro, QV4::NUMBER_HINT) : r.asReturnedValue()); | - | ||||||||||||||||||
981 | return Runtime::method_compareGreaterThan(pl, pr); executed 223 times by 1 test: return Runtime::method_compareGreaterThan(pl, pr); Executed by:
| 223 | ||||||||||||||||||
982 | #endif | - | ||||||||||||||||||
983 | } | - | ||||||||||||||||||
984 | - | |||||||||||||||||||
985 | double dl = RuntimeHelpers::toNumber(l); | - | ||||||||||||||||||
986 | double dr = RuntimeHelpers::toNumber(r); | - | ||||||||||||||||||
987 | return dl > dr; executed 248 times by 1 test: return dl > dr; Executed by:
| 248 | ||||||||||||||||||
988 | } | - | ||||||||||||||||||
989 | - | |||||||||||||||||||
990 | QV4::Bool Runtime::method_compareLessThan(const Value &l, const Value &r) | - | ||||||||||||||||||
991 | { | - | ||||||||||||||||||
992 | TRACE2(l, r); | - | ||||||||||||||||||
993 | if (l.isInteger() && r.isInteger())
| 24-3229 | ||||||||||||||||||
994 | return l.integerValue() < r.integerValue(); executed 24 times by 1 test: return l.integerValue() < r.integerValue(); Executed by:
| 24 | ||||||||||||||||||
995 | if (l.isNumber() && r.isNumber())
| 88-3139 | ||||||||||||||||||
996 | return l.asDouble() < r.asDouble(); executed 320 times by 6 tests: return l.asDouble() < r.asDouble(); Executed by:
| 320 | ||||||||||||||||||
997 | String *sl = l.stringValue(); | - | ||||||||||||||||||
998 | String *sr = r.stringValue(); | - | ||||||||||||||||||
999 | if (sl && sr) {
| 216-2834 | ||||||||||||||||||
1000 | #ifdef V4_BOOTSTRAP | - | ||||||||||||||||||
1001 | Q_UNIMPLEMENTED(); | - | ||||||||||||||||||
1002 | return false; | - | ||||||||||||||||||
1003 | #else | - | ||||||||||||||||||
1004 | return sl->compare(sr); executed 2617 times by 3 tests: return sl->compare(sr); Executed by:
| 2617 | ||||||||||||||||||
1005 | #endif | - | ||||||||||||||||||
1006 | } | - | ||||||||||||||||||
1007 | - | |||||||||||||||||||
1008 | Object *ro = r.objectValue(); | - | ||||||||||||||||||
1009 | Object *lo = l.objectValue(); | - | ||||||||||||||||||
1010 | if (ro || lo) {
| 80-472 | ||||||||||||||||||
1011 | #ifdef V4_BOOTSTRAP | - | ||||||||||||||||||
1012 | Q_UNIMPLEMENTED(); | - | ||||||||||||||||||
1013 | #else | - | ||||||||||||||||||
1014 | QV4::ExecutionEngine *e = (lo ? lo : ro)->engine();
| 80-136 | ||||||||||||||||||
1015 | QV4::Scope scope(e); | - | ||||||||||||||||||
1016 | QV4::ScopedValue pl(scope, lo ? RuntimeHelpers::objectDefaultValue(lo, QV4::NUMBER_HINT) : l.asReturnedValue()); | - | ||||||||||||||||||
1017 | QV4::ScopedValue pr(scope, ro ? RuntimeHelpers::objectDefaultValue(ro, QV4::NUMBER_HINT) : r.asReturnedValue()); | - | ||||||||||||||||||
1018 | return Runtime::method_compareLessThan(pl, pr); executed 216 times by 1 test: return Runtime::method_compareLessThan(pl, pr); Executed by:
| 216 | ||||||||||||||||||
1019 | #endif | - | ||||||||||||||||||
1020 | } | - | ||||||||||||||||||
1021 | - | |||||||||||||||||||
1022 | double dl = RuntimeHelpers::toNumber(l); | - | ||||||||||||||||||
1023 | double dr = RuntimeHelpers::toNumber(r); | - | ||||||||||||||||||
1024 | return dl < dr; executed 392 times by 2 tests: return dl < dr; Executed by:
| 392 | ||||||||||||||||||
1025 | } | - | ||||||||||||||||||
1026 | - | |||||||||||||||||||
1027 | QV4::Bool Runtime::method_compareGreaterEqual(const Value &l, const Value &r) | - | ||||||||||||||||||
1028 | { | - | ||||||||||||||||||
1029 | TRACE2(l, r); | - | ||||||||||||||||||
1030 | if (l.isInteger() && r.isInteger())
| 24-891 | ||||||||||||||||||
1031 | return l.integerValue() >= r.integerValue(); executed 24 times by 1 test: return l.integerValue() >= r.integerValue(); Executed by:
| 24 | ||||||||||||||||||
1032 | if (l.isNumber() && r.isNumber())
| 88-534 | ||||||||||||||||||
1033 | return l.asDouble() >= r.asDouble(); executed 338 times by 4 tests: return l.asDouble() >= r.asDouble(); Executed by:
| 338 | ||||||||||||||||||
1034 | String *sl = l.stringValue(); | - | ||||||||||||||||||
1035 | String *sr = r.stringValue(); | - | ||||||||||||||||||
1036 | if (sl && sr) {
| 64-392 | ||||||||||||||||||
1037 | #ifdef V4_BOOTSTRAP | - | ||||||||||||||||||
1038 | Q_UNIMPLEMENTED(); | - | ||||||||||||||||||
1039 | return false; | - | ||||||||||||||||||
1040 | #else | - | ||||||||||||||||||
1041 | return !sl->compare(sr); executed 168 times by 1 test: return !sl->compare(sr); Executed by:
| 168 | ||||||||||||||||||
1042 | #endif | - | ||||||||||||||||||
1043 | } | - | ||||||||||||||||||
1044 | - | |||||||||||||||||||
1045 | Object *ro = r.objectValue(); | - | ||||||||||||||||||
1046 | Object *lo = l.objectValue(); | - | ||||||||||||||||||
1047 | if (ro || lo) {
| 75-324 | ||||||||||||||||||
1048 | #ifdef V4_BOOTSTRAP | - | ||||||||||||||||||
1049 | Q_UNIMPLEMENTED(); | - | ||||||||||||||||||
1050 | #else | - | ||||||||||||||||||
1051 | QV4::ExecutionEngine *e = (lo ? lo : ro)->engine();
| 76-131 | ||||||||||||||||||
1052 | QV4::Scope scope(e); | - | ||||||||||||||||||
1053 | QV4::ScopedValue pl(scope, lo ? RuntimeHelpers::objectDefaultValue(lo, QV4::NUMBER_HINT) : l.asReturnedValue()); | - | ||||||||||||||||||
1054 | QV4::ScopedValue pr(scope, ro ? RuntimeHelpers::objectDefaultValue(ro, QV4::NUMBER_HINT) : r.asReturnedValue()); | - | ||||||||||||||||||
1055 | return Runtime::method_compareGreaterEqual(pl, pr); executed 208 times by 1 test: return Runtime::method_compareGreaterEqual(pl, pr); Executed by:
| 208 | ||||||||||||||||||
1056 | #endif | - | ||||||||||||||||||
1057 | } | - | ||||||||||||||||||
1058 | - | |||||||||||||||||||
1059 | double dl = RuntimeHelpers::toNumber(l); | - | ||||||||||||||||||
1060 | double dr = RuntimeHelpers::toNumber(r); | - | ||||||||||||||||||
1061 | return dl >= dr; executed 247 times by 1 test: return dl >= dr; Executed by:
| 247 | ||||||||||||||||||
1062 | } | - | ||||||||||||||||||
1063 | - | |||||||||||||||||||
1064 | QV4::Bool Runtime::method_compareLessEqual(const Value &l, const Value &r) | - | ||||||||||||||||||
1065 | { | - | ||||||||||||||||||
1066 | TRACE2(l, r); | - | ||||||||||||||||||
1067 | if (l.isInteger() && r.isInteger())
| 44-7457 | ||||||||||||||||||
1068 | return l.integerValue() <= r.integerValue(); executed 44 times by 1 test: return l.integerValue() <= r.integerValue(); Executed by:
| 44 | ||||||||||||||||||
1069 | if (l.isNumber() && r.isNumber())
| 88-7234 | ||||||||||||||||||
1070 | return l.asDouble() <= r.asDouble(); executed 202 times by 6 tests: return l.asDouble() <= r.asDouble(); Executed by:
| 202 | ||||||||||||||||||
1071 | String *sl = l.stringValue(); | - | ||||||||||||||||||
1072 | String *sr = r.stringValue(); | - | ||||||||||||||||||
1073 | if (sl && sr) {
| 64-6913 | ||||||||||||||||||
1074 | #ifdef V4_BOOTSTRAP | - | ||||||||||||||||||
1075 | Q_UNIMPLEMENTED(); | - | ||||||||||||||||||
1076 | return false; | - | ||||||||||||||||||
1077 | #else | - | ||||||||||||||||||
1078 | return !sr->compare(sl); executed 6847 times by 1 test: return !sr->compare(sl); Executed by:
| 6847 | ||||||||||||||||||
1079 | #endif | - | ||||||||||||||||||
1080 | } | - | ||||||||||||||||||
1081 | - | |||||||||||||||||||
1082 | Object *ro = r.objectValue(); | - | ||||||||||||||||||
1083 | Object *lo = l.objectValue(); | - | ||||||||||||||||||
1084 | if (ro || lo) {
| 76-324 | ||||||||||||||||||
1085 | #ifdef V4_BOOTSTRAP | - | ||||||||||||||||||
1086 | Q_UNIMPLEMENTED(); | - | ||||||||||||||||||
1087 | #else | - | ||||||||||||||||||
1088 | QV4::ExecutionEngine *e = (lo ? lo : ro)->engine();
| 76-151 | ||||||||||||||||||
1089 | QV4::Scope scope(e); | - | ||||||||||||||||||
1090 | QV4::ScopedValue pl(scope, lo ? RuntimeHelpers::objectDefaultValue(lo, QV4::NUMBER_HINT) : l.asReturnedValue()); | - | ||||||||||||||||||
1091 | QV4::ScopedValue pr(scope, ro ? RuntimeHelpers::objectDefaultValue(ro, QV4::NUMBER_HINT) : r.asReturnedValue()); | - | ||||||||||||||||||
1092 | return Runtime::method_compareLessEqual(pl, pr); executed 228 times by 1 test: return Runtime::method_compareLessEqual(pl, pr); Executed by:
| 228 | ||||||||||||||||||
1093 | #endif | - | ||||||||||||||||||
1094 | } | - | ||||||||||||||||||
1095 | - | |||||||||||||||||||
1096 | double dl = RuntimeHelpers::toNumber(l); | - | ||||||||||||||||||
1097 | double dr = RuntimeHelpers::toNumber(r); | - | ||||||||||||||||||
1098 | return dl <= dr; executed 245 times by 1 test: return dl <= dr; Executed by:
| 245 | ||||||||||||||||||
1099 | } | - | ||||||||||||||||||
1100 | - | |||||||||||||||||||
1101 | #ifndef V4_BOOTSTRAP | - | ||||||||||||||||||
1102 | Bool Runtime::method_compareInstanceof(ExecutionEngine *engine, const Value &left, const Value &right) | - | ||||||||||||||||||
1103 | { | - | ||||||||||||||||||
1104 | TRACE2(left, right); | - | ||||||||||||||||||
1105 | - | |||||||||||||||||||
1106 | Scope scope(engine); | - | ||||||||||||||||||
1107 | ScopedValue v(scope, method_instanceof(engine, left, right)); | - | ||||||||||||||||||
1108 | return v->booleanValue(); never executed: return v->booleanValue(); | 0 | ||||||||||||||||||
1109 | } | - | ||||||||||||||||||
1110 | - | |||||||||||||||||||
1111 | uint Runtime::method_compareIn(ExecutionEngine *engine, const Value &left, const Value &right) | - | ||||||||||||||||||
1112 | { | - | ||||||||||||||||||
1113 | TRACE2(left, right); | - | ||||||||||||||||||
1114 | - | |||||||||||||||||||
1115 | Scope scope(engine); | - | ||||||||||||||||||
1116 | ScopedValue v(scope, method_in(engine, left, right)); | - | ||||||||||||||||||
1117 | return v->booleanValue(); never executed: return v->booleanValue(); | 0 | ||||||||||||||||||
1118 | } | - | ||||||||||||||||||
1119 | - | |||||||||||||||||||
1120 | - | |||||||||||||||||||
1121 | ReturnedValue Runtime::method_callGlobalLookup(ExecutionEngine *engine, uint index, Value *argv, int argc) | - | ||||||||||||||||||
1122 | { | - | ||||||||||||||||||
1123 | Lookup *l = engine->currentStackFrame->v4Function->compilationUnit->runtimeLookups + index; | - | ||||||||||||||||||
1124 | Value function = Value::fromReturnedValue(l->globalGetter(l, engine)); | - | ||||||||||||||||||
1125 | if (!function.isFunctionObject())
| 140-26886643 | ||||||||||||||||||
1126 | return engine->throwTypeError(); executed 140 times by 1 test: return engine->throwTypeError(); Executed by:
| 140 | ||||||||||||||||||
1127 | - | |||||||||||||||||||
1128 | Value thisObject = Primitive::undefinedValue(); | - | ||||||||||||||||||
1129 | return static_cast<FunctionObject &>(function).call(&thisObject, argv, argc); executed 26901057 times by 2 tests: return static_cast<FunctionObject &>(function).call(&thisObject, argv, argc); Executed by:
| 26901057 | ||||||||||||||||||
1130 | } | - | ||||||||||||||||||
1131 | - | |||||||||||||||||||
1132 | ReturnedValue Runtime::method_callPossiblyDirectEval(ExecutionEngine *engine, Value *argv, int argc) | - | ||||||||||||||||||
1133 | { | - | ||||||||||||||||||
1134 | Scope scope(engine); | - | ||||||||||||||||||
1135 | ScopedValue thisObject(scope); | - | ||||||||||||||||||
1136 | - | |||||||||||||||||||
1137 | ExecutionContext &ctx = static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context); | - | ||||||||||||||||||
1138 | ScopedFunctionObject function(scope, ctx.getPropertyAndBase(engine->id_eval(), thisObject)); | - | ||||||||||||||||||
1139 | if (engine->hasException)
| 0-1580728 | ||||||||||||||||||
1140 | return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||
1141 | - | |||||||||||||||||||
1142 | if (!function) {
| 0-1580745 | ||||||||||||||||||
1143 | QString objectAsString = QStringLiteral("[null]"); | - | ||||||||||||||||||
1144 | if (!thisObject->isUndefined())
| 0 | ||||||||||||||||||
1145 | objectAsString = thisObject->toQStringNoThrow(); never executed: objectAsString = thisObject->toQStringNoThrow(); | 0 | ||||||||||||||||||
1146 | QString msg = QStringLiteral("Property 'eval' of object %2 is not a function").arg(objectAsString); | - | ||||||||||||||||||
1147 | return engine->throwTypeError(msg); never executed: return engine->throwTypeError(msg); | 0 | ||||||||||||||||||
1148 | } | - | ||||||||||||||||||
1149 | - | |||||||||||||||||||
1150 | if (function->d() == engine->evalFunction()->d())
| 1187-1579469 | ||||||||||||||||||
1151 | return static_cast<EvalFunction *>(function.getPointer())->evalCall(thisObject, argv, argc, true); executed 1579460 times by 7 tests: return static_cast<EvalFunction *>(function.getPointer())->evalCall(thisObject, argv, argc, true); Executed by:
| 1579460 | ||||||||||||||||||
1152 | - | |||||||||||||||||||
1153 | return function->call(thisObject, argv, argc); executed 1187 times by 1 test: return function->call(thisObject, argv, argc); Executed by:
| 1187 | ||||||||||||||||||
1154 | } | - | ||||||||||||||||||
1155 | - | |||||||||||||||||||
1156 | ReturnedValue Runtime::method_callName(ExecutionEngine *engine, int nameIndex, Value *argv, int argc) | - | ||||||||||||||||||
1157 | { | - | ||||||||||||||||||
1158 | Scope scope(engine); | - | ||||||||||||||||||
1159 | ScopedValue thisObject(scope); | - | ||||||||||||||||||
1160 | ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
1161 | - | |||||||||||||||||||
1162 | ExecutionContext &ctx = static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context); | - | ||||||||||||||||||
1163 | ScopedFunctionObject f(scope, ctx.getPropertyAndBase(name, thisObject)); | - | ||||||||||||||||||
1164 | if (engine->hasException)
| 20-52483 | ||||||||||||||||||
1165 | return Encode::undefined(); executed 20 times by 6 tests: return Encode::undefined(); Executed by:
| 20 | ||||||||||||||||||
1166 | - | |||||||||||||||||||
1167 | if (!f) {
| 2-52482 | ||||||||||||||||||
1168 | QString objectAsString = QStringLiteral("[null]"); | - | ||||||||||||||||||
1169 | if (!thisObject->isUndefined())
| 0-2 | ||||||||||||||||||
1170 | objectAsString = thisObject->toQStringNoThrow(); executed 2 times by 1 test: objectAsString = thisObject->toQStringNoThrow(); Executed by:
| 2 | ||||||||||||||||||
1171 | QString msg = QStringLiteral("Property '%1' of object %2 is not a function") | - | ||||||||||||||||||
1172 | .arg(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]->toQString(), | - | ||||||||||||||||||
1173 | objectAsString); | - | ||||||||||||||||||
1174 | return engine->throwTypeError(msg); executed 2 times by 1 test: return engine->throwTypeError(msg); Executed by:
| 2 | ||||||||||||||||||
1175 | } | - | ||||||||||||||||||
1176 | - | |||||||||||||||||||
1177 | return f->call(thisObject, argv, argc); executed 52482 times by 42 tests: return f->call(thisObject, argv, argc); Executed by:
| 52482 | ||||||||||||||||||
1178 | } | - | ||||||||||||||||||
1179 | - | |||||||||||||||||||
1180 | ReturnedValue Runtime::method_callProperty(ExecutionEngine *engine, Value *base, int nameIndex, Value *argv, int argc) | - | ||||||||||||||||||
1181 | { | - | ||||||||||||||||||
1182 | Scope scope(engine); | - | ||||||||||||||||||
1183 | ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
1184 | ScopedObject lookupObject(scope, base); | - | ||||||||||||||||||
1185 | - | |||||||||||||||||||
1186 | if (!lookupObject) {
| 11332-472284 | ||||||||||||||||||
1187 | Q_ASSERT(!base->isEmpty()); | - | ||||||||||||||||||
1188 | if (base->isNullOrUndefined()) {
| 8-11324 | ||||||||||||||||||
1189 | QString message = QStringLiteral("Cannot call method '%1' of %2") | - | ||||||||||||||||||
1190 | .arg(name->toQString(), base->toQStringNoThrow()); | - | ||||||||||||||||||
1191 | return engine->throwTypeError(message); executed 8 times by 1 test: return engine->throwTypeError(message); Executed by:
| 8 | ||||||||||||||||||
1192 | } | - | ||||||||||||||||||
1193 | - | |||||||||||||||||||
1194 | if (base->isManaged()) {
| 376-10948 | ||||||||||||||||||
1195 | Managed *m = static_cast<Managed *>(base); | - | ||||||||||||||||||
1196 | lookupObject = m->internalClass()->prototype; | - | ||||||||||||||||||
1197 | Q_ASSERT(m->internalClass()->prototype); | - | ||||||||||||||||||
1198 | } else { executed 10948 times by 14 tests: end of block Executed by:
| 10948 | ||||||||||||||||||
1199 | lookupObject = RuntimeHelpers::convertToObject(engine, *base); | - | ||||||||||||||||||
1200 | if (engine->hasException) // type error
| 0-376 | ||||||||||||||||||
1201 | return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||
1202 | if (!engine->currentStackFrame->v4Function->isStrict())
| 0-376 | ||||||||||||||||||
1203 | base = lookupObject; executed 376 times by 5 tests: base = lookupObject; Executed by:
| 376 | ||||||||||||||||||
1204 | } executed 376 times by 5 tests: end of block Executed by:
| 376 | ||||||||||||||||||
1205 | } | - | ||||||||||||||||||
1206 | - | |||||||||||||||||||
1207 | ScopedFunctionObject f(scope, static_cast<Object *>(lookupObject)->get(name)); | - | ||||||||||||||||||
1208 | - | |||||||||||||||||||
1209 | if (!f) {
| 14-483594 | ||||||||||||||||||
1210 | QString error = QStringLiteral("Property '%1' of object %2 is not a function") | - | ||||||||||||||||||
1211 | .arg(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]->toQString(), | - | ||||||||||||||||||
1212 | base->toQStringNoThrow()); | - | ||||||||||||||||||
1213 | return engine->throwTypeError(error); executed 14 times by 2 tests: return engine->throwTypeError(error); Executed by:
| 14 | ||||||||||||||||||
1214 | } | - | ||||||||||||||||||
1215 | - | |||||||||||||||||||
1216 | return f->call(base, argv, argc); executed 483594 times by 78 tests: return f->call(base, argv, argc); Executed by:
| 483594 | ||||||||||||||||||
1217 | } | - | ||||||||||||||||||
1218 | - | |||||||||||||||||||
1219 | ReturnedValue Runtime::method_callPropertyLookup(ExecutionEngine *engine, Value *base, uint index, Value *argv, int argc) | - | ||||||||||||||||||
1220 | { | - | ||||||||||||||||||
1221 | Lookup *l = engine->currentStackFrame->v4Function->compilationUnit->runtimeLookups + index; | - | ||||||||||||||||||
1222 | // ok to have the value on the stack here | - | ||||||||||||||||||
1223 | Value f = Value::fromReturnedValue(l->getter(l, engine, *base)); | - | ||||||||||||||||||
1224 | - | |||||||||||||||||||
1225 | if (!f.isFunctionObject())
| 0-48 | ||||||||||||||||||
1226 | return engine->throwTypeError(); never executed: return engine->throwTypeError(); | 0 | ||||||||||||||||||
1227 | - | |||||||||||||||||||
1228 | return static_cast<FunctionObject &>(f).call(base, argv, argc); executed 48 times by 3 tests: return static_cast<FunctionObject &>(f).call(base, argv, argc); Executed by:
| 48 | ||||||||||||||||||
1229 | } | - | ||||||||||||||||||
1230 | - | |||||||||||||||||||
1231 | ReturnedValue Runtime::method_callElement(ExecutionEngine *engine, Value *base, const Value &index, Value *argv, int argc) | - | ||||||||||||||||||
1232 | { | - | ||||||||||||||||||
1233 | Scope scope(engine); | - | ||||||||||||||||||
1234 | ScopedValue thisObject(scope, base->toObject(engine)); | - | ||||||||||||||||||
1235 | base = thisObject; | - | ||||||||||||||||||
1236 | - | |||||||||||||||||||
1237 | ScopedPropertyKey str(scope, index.toPropertyKey(engine)); | - | ||||||||||||||||||
1238 | if (engine->hasException)
| 0-1903 | ||||||||||||||||||
1239 | return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||
1240 | - | |||||||||||||||||||
1241 | ScopedFunctionObject f(scope, static_cast<Object *>(base)->get(str)); | - | ||||||||||||||||||
1242 | if (!f)
| 328-1575 | ||||||||||||||||||
1243 | return engine->throwTypeError(); executed 328 times by 1 test: return engine->throwTypeError(); Executed by:
| 328 | ||||||||||||||||||
1244 | - | |||||||||||||||||||
1245 | return f->call(base, argv, argc); executed 1575 times by 6 tests: return f->call(base, argv, argc); Executed by:
| 1575 | ||||||||||||||||||
1246 | } | - | ||||||||||||||||||
1247 | - | |||||||||||||||||||
1248 | ReturnedValue Runtime::method_callValue(ExecutionEngine *engine, const Value &func, Value *argv, int argc) | - | ||||||||||||||||||
1249 | { | - | ||||||||||||||||||
1250 | if (!func.isFunctionObject())
| 0-472 | ||||||||||||||||||
1251 | return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow())); never executed: return engine->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "%1 is not a function")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "%1 is not a function" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()).arg(func.toQStringNoThrow())); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
1252 | return static_cast<const FunctionObject &>(func).call(nullptr, argv, argc); executed 472 times by 5 tests: return static_cast<const FunctionObject &>(func).call(nullptr, argv, argc); Executed by:
| 472 | ||||||||||||||||||
1253 | } | - | ||||||||||||||||||
1254 | - | |||||||||||||||||||
1255 | ReturnedValue Runtime::method_callQmlScopeObjectProperty(ExecutionEngine *engine, Value *base, | - | ||||||||||||||||||
1256 | int propertyIndex, Value *argv, int argc) | - | ||||||||||||||||||
1257 | { | - | ||||||||||||||||||
1258 | Scope scope(engine); | - | ||||||||||||||||||
1259 | ScopedFunctionObject fo(scope, method_loadQmlScopeObjectProperty(engine, *base, propertyIndex, | - | ||||||||||||||||||
1260 | /*captureRequired*/true)); | - | ||||||||||||||||||
1261 | if (!fo) {
| 2-14 | ||||||||||||||||||
1262 | QString error = QStringLiteral("Property '%1' of scope object is not a function").arg(propertyIndex); | - | ||||||||||||||||||
1263 | return engine->throwTypeError(error); executed 2 times by 1 test: return engine->throwTypeError(error); Executed by:
| 2 | ||||||||||||||||||
1264 | } | - | ||||||||||||||||||
1265 | - | |||||||||||||||||||
1266 | QObject *qmlScopeObj = static_cast<QmlContext *>(base)->d()->qml()->scopeObject; | - | ||||||||||||||||||
1267 | ScopedValue qmlScopeValue(scope, QObjectWrapper::wrap(engine, qmlScopeObj)); | - | ||||||||||||||||||
1268 | return fo->call(qmlScopeValue, argv, argc); executed 14 times by 1 test: return fo->call(qmlScopeValue, argv, argc); Executed by:
| 14 | ||||||||||||||||||
1269 | } | - | ||||||||||||||||||
1270 | - | |||||||||||||||||||
1271 | ReturnedValue Runtime::method_callQmlContextObjectProperty(ExecutionEngine *engine, Value *base, | - | ||||||||||||||||||
1272 | int propertyIndex, Value *argv, int argc) | - | ||||||||||||||||||
1273 | { | - | ||||||||||||||||||
1274 | Scope scope(engine); | - | ||||||||||||||||||
1275 | ScopedFunctionObject fo(scope, method_loadQmlContextObjectProperty(engine, *base, propertyIndex, | - | ||||||||||||||||||
1276 | /*captureRequired*/true)); | - | ||||||||||||||||||
1277 | if (!fo) {
| 0 | ||||||||||||||||||
1278 | QString error = QStringLiteral("Property '%1' of context object is not a function").arg(propertyIndex); | - | ||||||||||||||||||
1279 | return engine->throwTypeError(error); never executed: return engine->throwTypeError(error); | 0 | ||||||||||||||||||
1280 | } | - | ||||||||||||||||||
1281 | - | |||||||||||||||||||
1282 | QObject *qmlContextObj = static_cast<QmlContext *>(base)->d()->qml()->context->contextData()->contextObject; | - | ||||||||||||||||||
1283 | ScopedValue qmlContextValue(scope, QObjectWrapper::wrap(engine, qmlContextObj)); | - | ||||||||||||||||||
1284 | return fo->call(qmlContextValue, argv, argc); never executed: return fo->call(qmlContextValue, argv, argc); | 0 | ||||||||||||||||||
1285 | } | - | ||||||||||||||||||
1286 | - | |||||||||||||||||||
1287 | struct CallArgs { | - | ||||||||||||||||||
1288 | Value *argv; | - | ||||||||||||||||||
1289 | int argc; | - | ||||||||||||||||||
1290 | }; | - | ||||||||||||||||||
1291 | - | |||||||||||||||||||
1292 | static CallArgs createSpreadArguments(Scope &scope, Value *argv, int argc) | - | ||||||||||||||||||
1293 | { | - | ||||||||||||||||||
1294 | ScopedValue it(scope); | - | ||||||||||||||||||
1295 | ScopedValue done(scope); | - | ||||||||||||||||||
1296 | - | |||||||||||||||||||
1297 | int argCount = 0; | - | ||||||||||||||||||
1298 | - | |||||||||||||||||||
1299 | Value *v = scope.alloc<Scope::Uninitialized>(); | - | ||||||||||||||||||
1300 | Value *arguments = v; | - | ||||||||||||||||||
1301 | for (int i = 0; i < argc; ++i) {
| 116-457 | ||||||||||||||||||
1302 | if (!argv[i].isEmpty()) {
| 199-258 | ||||||||||||||||||
1303 | *v = argv[i]; | - | ||||||||||||||||||
1304 | ++argCount; | - | ||||||||||||||||||
1305 | v = scope.alloc<Scope::Uninitialized>(); | - | ||||||||||||||||||
1306 | continue; executed 199 times by 1 test: continue; Executed by:
| 199 | ||||||||||||||||||
1307 | } | - | ||||||||||||||||||
1308 | // spread element | - | ||||||||||||||||||
1309 | ++i; | - | ||||||||||||||||||
1310 | it = Runtime::method_getIterator(scope.engine, argv[i], /* ForInIterator */ 1); | - | ||||||||||||||||||
1311 | if (scope.engine->hasException)
| 72-188 | ||||||||||||||||||
1312 | return { nullptr, 0 }; executed 72 times by 1 test: return { nullptr, 0 }; Executed by:
| 72 | ||||||||||||||||||
1313 | while (1) { | - | ||||||||||||||||||
1314 | done = Runtime::method_iteratorNext(scope.engine, it, v); | - | ||||||||||||||||||
1315 | if (scope.engine->hasException)
| 72-316 | ||||||||||||||||||
1316 | return { nullptr, 0 }; executed 72 times by 1 test: return { nullptr, 0 }; Executed by:
| 72 | ||||||||||||||||||
1317 | Q_ASSERT(done->isBoolean()); | - | ||||||||||||||||||
1318 | if (done->booleanValue())
| 116-200 | ||||||||||||||||||
1319 | break; executed 116 times by 1 test: break; Executed by:
| 116 | ||||||||||||||||||
1320 | ++argCount; | - | ||||||||||||||||||
1321 | v = scope.alloc<Scope::Uninitialized>(); | - | ||||||||||||||||||
1322 | } executed 200 times by 1 test: end of block Executed by:
| 200 | ||||||||||||||||||
1323 | } executed 116 times by 1 test: end of block Executed by:
| 116 | ||||||||||||||||||
1324 | return { arguments, argCount }; executed 116 times by 1 test: return { arguments, argCount }; Executed by:
| 116 | ||||||||||||||||||
1325 | } | - | ||||||||||||||||||
1326 | - | |||||||||||||||||||
1327 | ReturnedValue Runtime::method_callWithSpread(ExecutionEngine *engine, const Value &function, const Value &thisObject, Value *argv, int argc) | - | ||||||||||||||||||
1328 | { | - | ||||||||||||||||||
1329 | Q_ASSERT(argc >= 1); | - | ||||||||||||||||||
1330 | if (!function.isFunctionObject())
| 0-100 | ||||||||||||||||||
1331 | return engine->throwTypeError(); never executed: return engine->throwTypeError(); | 0 | ||||||||||||||||||
1332 | - | |||||||||||||||||||
1333 | Scope scope(engine); | - | ||||||||||||||||||
1334 | CallArgs arguments = createSpreadArguments(scope, argv, argc); | - | ||||||||||||||||||
1335 | if (engine->hasException)
| 48-52 | ||||||||||||||||||
1336 | return Encode::undefined(); executed 48 times by 1 test: return Encode::undefined(); Executed by:
| 48 | ||||||||||||||||||
1337 | - | |||||||||||||||||||
1338 | return static_cast<const FunctionObject &>(function).call(&thisObject, arguments.argv, arguments.argc); executed 52 times by 1 test: return static_cast<const FunctionObject &>(function).call(&thisObject, arguments.argv, arguments.argc); Executed by:
| 52 | ||||||||||||||||||
1339 | } | - | ||||||||||||||||||
1340 | - | |||||||||||||||||||
1341 | ReturnedValue Runtime::method_construct(ExecutionEngine *engine, const Value &function, const Value &newTarget, Value *argv, int argc) | - | ||||||||||||||||||
1342 | { | - | ||||||||||||||||||
1343 | if (!function.isFunctionObject())
| 206-113560 | ||||||||||||||||||
1344 | return engine->throwTypeError(); executed 206 times by 1 test: return engine->throwTypeError(); Executed by:
| 206 | ||||||||||||||||||
1345 | - | |||||||||||||||||||
1346 | return static_cast<const FunctionObject &>(function).callAsConstructor(argv, argc, &newTarget); executed 113556 times by 18 tests: return static_cast<const FunctionObject &>(function).callAsConstructor(argv, argc, &newTarget); Executed by:
| 113556 | ||||||||||||||||||
1347 | } | - | ||||||||||||||||||
1348 | - | |||||||||||||||||||
1349 | ReturnedValue Runtime::method_constructWithSpread(ExecutionEngine *engine, const Value &function, const Value &newTarget, Value *argv, int argc) | - | ||||||||||||||||||
1350 | { | - | ||||||||||||||||||
1351 | Q_UNIMPLEMENTED(); | - | ||||||||||||||||||
1352 | if (!function.isFunctionObject())
| 0-160 | ||||||||||||||||||
1353 | return engine->throwTypeError(); never executed: return engine->throwTypeError(); | 0 | ||||||||||||||||||
1354 | - | |||||||||||||||||||
1355 | Scope scope(engine); | - | ||||||||||||||||||
1356 | CallArgs arguments = createSpreadArguments(scope, argv, argc); | - | ||||||||||||||||||
1357 | if (engine->hasException)
| 64-96 | ||||||||||||||||||
1358 | return Encode::undefined(); executed 96 times by 1 test: return Encode::undefined(); Executed by:
| 96 | ||||||||||||||||||
1359 | - | |||||||||||||||||||
1360 | return static_cast<const FunctionObject &>(function).callAsConstructor(arguments.argv, arguments.argc, &newTarget); executed 64 times by 1 test: return static_cast<const FunctionObject &>(function).callAsConstructor(arguments.argv, arguments.argc, &newTarget); Executed by:
| 64 | ||||||||||||||||||
1361 | } | - | ||||||||||||||||||
1362 | - | |||||||||||||||||||
1363 | void Runtime::method_throwException(ExecutionEngine *engine, const Value &value) | - | ||||||||||||||||||
1364 | { | - | ||||||||||||||||||
1365 | if (!value.isEmpty())
| 0-17309 | ||||||||||||||||||
1366 | engine->throwError(value); executed 17309 times by 9 tests: engine->throwError(value); Executed by:
| 17309 | ||||||||||||||||||
1367 | } executed 17301 times by 9 tests: end of block Executed by:
| 17301 | ||||||||||||||||||
1368 | - | |||||||||||||||||||
1369 | ReturnedValue Runtime::method_typeofValue(ExecutionEngine *engine, const Value &value) | - | ||||||||||||||||||
1370 | { | - | ||||||||||||||||||
1371 | Scope scope(engine); | - | ||||||||||||||||||
1372 | ScopedString res(scope); | - | ||||||||||||||||||
1373 | switch (value.type()) { | - | ||||||||||||||||||
1374 | case Value::Undefined_Type: executed 2122 times by 4 tests: case Value::Undefined_Type: Executed by:
| 2122 | ||||||||||||||||||
1375 | res = engine->id_undefined(); | - | ||||||||||||||||||
1376 | break; executed 2125 times by 4 tests: break; Executed by:
| 2125 | ||||||||||||||||||
1377 | case Value::Null_Type: executed 30 times by 5 tests: case Value::Null_Type: Executed by:
| 30 | ||||||||||||||||||
1378 | res = engine->id_object(); | - | ||||||||||||||||||
1379 | break; executed 30 times by 5 tests: break; Executed by:
| 30 | ||||||||||||||||||
1380 | case Value::Boolean_Type: executed 148 times by 4 tests: case Value::Boolean_Type: Executed by:
| 148 | ||||||||||||||||||
1381 | res = engine->id_boolean(); | - | ||||||||||||||||||
1382 | break; executed 148 times by 4 tests: break; Executed by:
| 148 | ||||||||||||||||||
1383 | case Value::Managed_Type: executed 83799 times by 10 tests: case Value::Managed_Type: Executed by:
| 83799 | ||||||||||||||||||
1384 | if (value.isString())
| 6923-76792 | ||||||||||||||||||
1385 | res = engine->id_string(); executed 6918 times by 8 tests: res = engine->id_string(); Executed by:
| 6918 | ||||||||||||||||||
1386 | else if (value.isSymbol())
| 212-76608 | ||||||||||||||||||
1387 | res = engine->id_symbol(); executed 212 times by 1 test: res = engine->id_symbol(); Executed by:
| 212 | ||||||||||||||||||
1388 | else if (value.objectValue()->as<FunctionObject>())
| 37190-39445 | ||||||||||||||||||
1389 | res = engine->id_function(); executed 37162 times by 5 tests: res = engine->id_function(); Executed by:
| 37162 | ||||||||||||||||||
1390 | else | - | ||||||||||||||||||
1391 | res = engine->id_object(); // ### implementation-defined executed 39432 times by 7 tests: res = engine->id_object(); Executed by:
| 39432 | ||||||||||||||||||
1392 | break; executed 83723 times by 10 tests: break; Executed by:
| 83723 | ||||||||||||||||||
1393 | default: executed 1432 times by 7 tests: default: Executed by:
| 1432 | ||||||||||||||||||
1394 | res = engine->id_number(); | - | ||||||||||||||||||
1395 | break; executed 1432 times by 7 tests: break; Executed by:
| 1432 | ||||||||||||||||||
1396 | } | - | ||||||||||||||||||
1397 | return res.asReturnedValue(); executed 87355 times by 10 tests: return res.asReturnedValue(); Executed by:
| 87355 | ||||||||||||||||||
1398 | } | - | ||||||||||||||||||
1399 | - | |||||||||||||||||||
1400 | QV4::ReturnedValue Runtime::method_typeofName(ExecutionEngine *engine, int nameIndex) | - | ||||||||||||||||||
1401 | { | - | ||||||||||||||||||
1402 | Scope scope(engine); | - | ||||||||||||||||||
1403 | ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
1404 | ScopedValue prop(scope, static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context).getProperty(name)); | - | ||||||||||||||||||
1405 | // typeof doesn't throw. clear any possible exception | - | ||||||||||||||||||
1406 | scope.engine->hasException = false; | - | ||||||||||||||||||
1407 | return method_typeofValue(engine, prop); executed 2895 times by 4 tests: return method_typeofValue(engine, prop); Executed by:
| 2895 | ||||||||||||||||||
1408 | } | - | ||||||||||||||||||
1409 | - | |||||||||||||||||||
1410 | ReturnedValue Runtime::method_createWithContext(ExecutionEngine *engine, Value *jsStackFrame) | - | ||||||||||||||||||
1411 | { | - | ||||||||||||||||||
1412 | QV4::Value &accumulator = jsStackFrame[CallData::Accumulator]; | - | ||||||||||||||||||
1413 | accumulator = accumulator.toObject(engine); | - | ||||||||||||||||||
1414 | if (engine->hasException)
| 7-657 | ||||||||||||||||||
1415 | return Encode::undefined(); executed 7 times by 2 tests: return Encode::undefined(); Executed by:
| 7 | ||||||||||||||||||
1416 | Q_ASSERT(accumulator.isObject()); | - | ||||||||||||||||||
1417 | const Object &obj = static_cast<const Object &>(accumulator); | - | ||||||||||||||||||
1418 | ExecutionContext *context = static_cast<ExecutionContext *>(jsStackFrame + CallData::Context); | - | ||||||||||||||||||
1419 | return context->newWithContext(obj.d())->asReturnedValue(); executed 659 times by 4 tests: return context->newWithContext(obj.d())->asReturnedValue(); Executed by:
| 659 | ||||||||||||||||||
1420 | } | - | ||||||||||||||||||
1421 | - | |||||||||||||||||||
1422 | ReturnedValue Runtime::method_createCatchContext(ExecutionContext *parent, int blockIndex, int exceptionVarNameIndex) | - | ||||||||||||||||||
1423 | { | - | ||||||||||||||||||
1424 | ExecutionEngine *e = parent->engine(); | - | ||||||||||||||||||
1425 | return parent->newCatchContext(e->currentStackFrame, blockIndex, executed 4320786 times by 13 tests: return parent->newCatchContext(e->currentStackFrame, blockIndex, e->currentStackFrame->v4Function->compilationUnit->runtimeStrings[exceptionVarNameIndex])->asReturnedValue(); Executed by:
| 4320786 | ||||||||||||||||||
1426 | e->currentStackFrame->v4Function->compilationUnit->runtimeStrings[exceptionVarNameIndex])->asReturnedValue(); executed 4320786 times by 13 tests: return parent->newCatchContext(e->currentStackFrame, blockIndex, e->currentStackFrame->v4Function->compilationUnit->runtimeStrings[exceptionVarNameIndex])->asReturnedValue(); Executed by:
| 4320786 | ||||||||||||||||||
1427 | } | - | ||||||||||||||||||
1428 | - | |||||||||||||||||||
1429 | ReturnedValue Runtime::method_createBlockContext(ExecutionContext *parent, int index) | - | ||||||||||||||||||
1430 | { | - | ||||||||||||||||||
1431 | ExecutionEngine *e = parent->engine(); | - | ||||||||||||||||||
1432 | return parent->newBlockContext(e->currentStackFrame, index)->asReturnedValue(); executed 562 times by 2 tests: return parent->newBlockContext(e->currentStackFrame, index)->asReturnedValue(); Executed by:
| 562 | ||||||||||||||||||
1433 | } | - | ||||||||||||||||||
1434 | - | |||||||||||||||||||
1435 | ReturnedValue Runtime::method_cloneBlockContext(ExecutionContext *previous) | - | ||||||||||||||||||
1436 | { | - | ||||||||||||||||||
1437 | return ExecutionContext::cloneBlockContext(static_cast<Heap::CallContext *>(previous->d()))->asReturnedValue(); executed 194 times by 2 tests: return ExecutionContext::cloneBlockContext(static_cast<Heap::CallContext *>(previous->d()))->asReturnedValue(); Executed by:
| 194 | ||||||||||||||||||
1438 | } | - | ||||||||||||||||||
1439 | - | |||||||||||||||||||
1440 | - | |||||||||||||||||||
1441 | ReturnedValue Runtime::method_createScriptContext(ExecutionEngine *engine, int index) | - | ||||||||||||||||||
1442 | { | - | ||||||||||||||||||
1443 | Q_ASSERT(engine->currentStackFrame->context()->d()->type == Heap::ExecutionContext::Type_GlobalContext || |