| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4context.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 <QString> | - | ||||||
| 41 | #include "qv4debugging_p.h" | - | ||||||
| 42 | #include <qv4context_p.h> | - | ||||||
| 43 | #include <qv4object_p.h> | - | ||||||
| 44 | #include <qv4objectproto_p.h> | - | ||||||
| 45 | #include <private/qv4mm_p.h> | - | ||||||
| 46 | #include <qv4argumentsobject_p.h> | - | ||||||
| 47 | #include "qv4function_p.h" | - | ||||||
| 48 | #include "qv4errorobject_p.h" | - | ||||||
| 49 | #include "qv4string_p.h" | - | ||||||
| 50 | #include "qv4qmlcontext_p.h" | - | ||||||
| 51 | #include "qv4stackframe_p.h" | - | ||||||
| 52 | - | |||||||
| 53 | using namespace QV4; | - | ||||||
| 54 | - | |||||||
| 55 | DEFINE_MANAGED_VTABLE(ExecutionContext); | - | ||||||
| 56 | DEFINE_MANAGED_VTABLE(CallContext); | - | ||||||
| 57 | - | |||||||
| 58 | Heap::CallContext *ExecutionContext::newBlockContext(CppStackFrame *frame, int blockIndex) | - | ||||||
| 59 | { | - | ||||||
| 60 | Function *function = frame->v4Function; | - | ||||||
| 61 | - | |||||||
| 62 | Heap::InternalClass *ic = function->compilationUnit->runtimeBlocks.at(blockIndex); | - | ||||||
| 63 | uint nLocals = ic->size; | - | ||||||
| 64 | size_t requiredMemory = sizeof(CallContext::Data) - sizeof(Value) + sizeof(Value) * nLocals; | - | ||||||
| 65 | - | |||||||
| 66 | ExecutionEngine *v4 = function->internalClass->engine; | - | ||||||
| 67 | Heap::CallContext *c = v4->memoryManager->allocManaged<CallContext>(requiredMemory, ic); | - | ||||||
| 68 | c->init(); | - | ||||||
| 69 | c->type = Heap::ExecutionContext::Type_BlockContext; | - | ||||||
| 70 | - | |||||||
| 71 | Heap::ExecutionContext *outer = static_cast<Heap::ExecutionContext *>(frame->context()->m()); | - | ||||||
| 72 | c->outer.set(v4, outer); | - | ||||||
| 73 | c->function.set(v4, static_cast<Heap::FunctionObject *>(frame->jsFrame->function.m())); | - | ||||||
| 74 | - | |||||||
| 75 | c->locals.size = nLocals; | - | ||||||
| 76 | c->locals.alloc = nLocals; | - | ||||||
| 77 | - | |||||||
| 78 | return c; executed 4346263 times by 13 tests: return c;Executed by:
| 4346263 | ||||||
| 79 | } | - | ||||||
| 80 | - | |||||||
| 81 | Heap::CallContext *ExecutionContext::cloneBlockContext(Heap::CallContext *context) | - | ||||||
| 82 | { | - | ||||||
| 83 | uint nLocals = context->locals.alloc; | - | ||||||
| 84 | size_t requiredMemory = sizeof(CallContext::Data) - sizeof(Value) + sizeof(Value) * nLocals; | - | ||||||
| 85 | - | |||||||
| 86 | ExecutionEngine *v4 = context->internalClass->engine; | - | ||||||
| 87 | Heap::CallContext *c = v4->memoryManager->allocManaged<CallContext>(requiredMemory, context->internalClass); | - | ||||||
| 88 | memcpy(c, context, requiredMemory); | - | ||||||
| 89 | - | |||||||
| 90 | return c; executed 194 times by 2 tests: return c;Executed by:
| 194 | ||||||
| 91 | - | |||||||
| 92 | } | - | ||||||
| 93 | - | |||||||
| 94 | Heap::CallContext *ExecutionContext::newCallContext(CppStackFrame *frame) | - | ||||||
| 95 | { | - | ||||||
| 96 | Function *function = frame->v4Function; | - | ||||||
| 97 | Heap::ExecutionContext *outer = static_cast<Heap::ExecutionContext *>(frame->context()->m()); | - | ||||||
| 98 | - | |||||||
| 99 | uint nFormals = qMax(static_cast<uint>(frame->originalArgumentsCount), function->nFormals); | - | ||||||
| 100 | uint localsAndFormals = function->compiledFunction->nLocals + nFormals; | - | ||||||
| 101 | size_t requiredMemory = sizeof(CallContext::Data) - sizeof(Value) + sizeof(Value) * (localsAndFormals); | - | ||||||
| 102 | - | |||||||
| 103 | ExecutionEngine *v4 = outer->internalClass->engine; | - | ||||||
| 104 | Heap::CallContext *c = v4->memoryManager->allocManaged<CallContext>(requiredMemory, function->internalClass); | - | ||||||
| 105 | c->init(); | - | ||||||
| 106 | - | |||||||
| 107 | c->outer.set(v4, outer); | - | ||||||
| 108 | c->function.set(v4, static_cast<Heap::FunctionObject *>(frame->jsFrame->function.m())); | - | ||||||
| 109 | - | |||||||
| 110 | const CompiledData::Function *compiledFunction = function->compiledFunction; | - | ||||||
| 111 | uint nLocals = compiledFunction->nLocals; | - | ||||||
| 112 | c->locals.size = nLocals; | - | ||||||
| 113 | c->locals.alloc = localsAndFormals; | - | ||||||
| 114 | // memory allocated from the JS heap is 0 initialized, so check if empty is 0 | - | ||||||
| 115 | Q_ASSERT(Primitive::undefinedValue().asReturnedValue() == 0); | - | ||||||
| 116 | - | |||||||
| 117 | Value *args = c->locals.values + nLocals; | - | ||||||
| 118 | ::memcpy(args, frame->originalArguments, frame->originalArgumentsCount * sizeof(Value)); | - | ||||||
| 119 | c->nArgs = frame->originalArgumentsCount; | - | ||||||
| 120 | for (uint i = frame->originalArgumentsCount; i < function->nFormals; ++i)
| 2412-17898 | ||||||
| 121 | args[i] = Encode::undefined(); executed 2411 times by 8 tests: args[i] = Encode::undefined();Executed by:
| 2411 | ||||||
| 122 | - | |||||||
| 123 | return c; executed 17894 times by 27 tests: return c;Executed by:
| 17894 | ||||||
| 124 | } | - | ||||||
| 125 | - | |||||||
| 126 | Heap::ExecutionContext *ExecutionContext::newWithContext(Heap::Object *with) | - | ||||||
| 127 | { | - | ||||||
| 128 | Heap::ExecutionContext *c = engine()->memoryManager->alloc<ExecutionContext>(Heap::ExecutionContext::Type_WithContext); | - | ||||||
| 129 | c->outer.set(engine(), d()); | - | ||||||
| 130 | c->activation.set(engine(), with); | - | ||||||
| 131 | - | |||||||
| 132 | return c; executed 657 times by 4 tests: return c;Executed by:
| 657 | ||||||
| 133 | } | - | ||||||
| 134 | - | |||||||
| 135 | Heap::ExecutionContext *ExecutionContext::newCatchContext(CppStackFrame *frame, int blockIndex, Heap::String *exceptionVarName) | - | ||||||
| 136 | { | - | ||||||
| 137 | Scope scope(frame->context()); | - | ||||||
| 138 | ScopedString name(scope, exceptionVarName); | - | ||||||
| 139 | ScopedValue val(scope, scope.engine->catchException(nullptr)); | - | ||||||
| 140 | ScopedContext ctx(scope, newBlockContext(frame, blockIndex)); | - | ||||||
| 141 | ctx->setProperty(name, val); | - | ||||||
| 142 | return ctx->d(); executed 4372343 times by 13 tests: return ctx->d();Executed by:
| 4372343 | ||||||
| 143 | } | - | ||||||
| 144 | - | |||||||
| 145 | void ExecutionContext::createMutableBinding(String *name, bool deletable) | - | ||||||
| 146 | { | - | ||||||
| 147 | Scope scope(this); | - | ||||||
| 148 | - | |||||||
| 149 | // find the right context to create the binding on | - | ||||||
| 150 | ScopedObject activation(scope); | - | ||||||
| 151 | ScopedContext ctx(scope, this); | - | ||||||
| 152 | while (ctx) {
| 517053-542086 | ||||||
| 153 | switch (ctx->d()->type) { | - | ||||||
| 154 | case Heap::ExecutionContext::Type_CallContext: executed 157 times by 1 test: case Heap::ExecutionContext::Type_CallContext:Executed by:
| 157 | ||||||
| 155 | if (!activation) {
| 28-129 | ||||||
| 156 | Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx->d()); | - | ||||||
| 157 | if (!c->activation)
| 2-127 | ||||||
| 158 | c->activation.set(scope.engine, scope.engine->newObject()); executed 127 times by 1 test: c->activation.set(scope.engine, scope.engine->newObject());Executed by:
| 127 | ||||||
| 159 | activation = c->activation; | - | ||||||
| 160 | } executed 130 times by 1 test: end of blockExecuted by:
| 130 | ||||||
| 161 | break; executed 158 times by 1 test: break;Executed by:
| 158 | ||||||
| 162 | case Heap::ExecutionContext::Type_QmlContext: { executed 1484 times by 15 tests: case Heap::ExecutionContext::Type_QmlContext:Executed by:
| 1484 | ||||||
| 163 | // this is ugly, as it overrides the inner callcontext, but has to stay as long | - | ||||||
| 164 | // as bindings still get their own callcontext | - | ||||||
| 165 | activation = ctx->d()->activation; | - | ||||||
| 166 | break; executed 1484 times by 15 tests: break;Executed by:
| 1484 | ||||||
| 167 | } | - | ||||||
| 168 | case Heap::ExecutionContext::Type_GlobalContext: { executed 516251 times by 21 tests: case Heap::ExecutionContext::Type_GlobalContext:Executed by:
| 516251 | ||||||
| 169 | Q_ASSERT(scope.engine->globalObject->d() == ctx->d()->activation); | - | ||||||
| 170 | if (!activation)
| 1614-514605 | ||||||
| 171 | activation = ctx->d()->activation; executed 514575 times by 7 tests: activation = ctx->d()->activation;Executed by:
| 514575 | ||||||
| 172 | break; executed 516465 times by 21 tests: break;Executed by:
| 516465 | ||||||
| 173 | } | - | ||||||
| 174 | case Heap::ExecutionContext::Type_BlockContext: executed 24308 times by 2 tests: case Heap::ExecutionContext::Type_BlockContext:Executed by:
| 24308 | ||||||
| 175 | // never create activation records on block contexts | - | ||||||
| 176 | default: never executed: default: | 0 | ||||||
| 177 | break; executed 24304 times by 2 tests: break;Executed by:
| 24304 | ||||||
| 178 | } | - | ||||||
| 179 | ctx = ctx->d()->outer; | - | ||||||
| 180 | } executed 543040 times by 21 tests: end of blockExecuted by:
| 543040 | ||||||
| 181 | - | |||||||
| 182 | PropertyKey id = name->toPropertyKey(); | - | ||||||
| 183 | if (activation->getOwnProperty(id) != Attr_Invalid)
| 384-517358 | ||||||
| 184 | return; executed 384 times by 2 tests: return;Executed by:
| 384 | ||||||
| 185 | ScopedProperty desc(scope); | - | ||||||
| 186 | PropertyAttributes attrs(Attr_Data); | - | ||||||
| 187 | attrs.setConfigurable(deletable); | - | ||||||
| 188 | if (!activation->defineOwnProperty(id, desc, attrs))
| 4-517187 | ||||||
| 189 | scope.engine->throwTypeError(); executed 4 times by 1 test: scope.engine->throwTypeError();Executed by:
| 4 | ||||||
| 190 | } executed 517200 times by 21 tests: end of blockExecuted by:
| 517200 | ||||||
| 191 | - | |||||||
| 192 | bool ExecutionContext::deleteProperty(String *name) | - | ||||||
| 193 | { | - | ||||||
| 194 | PropertyKey id = name->toPropertyKey(); | - | ||||||
| 195 | - | |||||||
| 196 | Heap::ExecutionContext *ctx = d(); | - | ||||||
| 197 | for (; ctx; ctx = ctx->outer) {
| 10-144 | ||||||
| 198 | switch (ctx->type) { | - | ||||||
| 199 | case Heap::ExecutionContext::Type_BlockContext: never executed: case Heap::ExecutionContext::Type_BlockContext: | 0 | ||||||
| 200 | case Heap::ExecutionContext::Type_CallContext: { executed 8 times by 1 test: case Heap::ExecutionContext::Type_CallContext:Executed by:
| 8 | ||||||
| 201 | Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx); | - | ||||||
| 202 | uint index = c->internalClass->find(id); | - | ||||||
| 203 | if (index < UINT_MAX)
| 4 | ||||||
| 204 | // ### throw in strict mode? | - | ||||||
| 205 | return false; executed 4 times by 1 test: return false;Executed by:
| 4 | ||||||
| 206 | Q_FALLTHROUGH(); | - | ||||||
| 207 | } | - | ||||||
| 208 | case Heap::ExecutionContext::Type_WithContext: code before this statement executed 4 times by 1 test: case Heap::ExecutionContext::Type_WithContext:Executed by:
executed 75 times by 1 test: case Heap::ExecutionContext::Type_WithContext:Executed by:
| 4-75 | ||||||
| 209 | case Heap::ExecutionContext::Type_GlobalContext: { executed 61 times by 2 tests: case Heap::ExecutionContext::Type_GlobalContext:Executed by:
| 61 | ||||||
| 210 | if (ctx->activation) {
| 0-141 | ||||||
| 211 | Scope scope(this); | - | ||||||
| 212 | ScopedObject object(scope, ctx->activation); | - | ||||||
| 213 | if (object && object->hasProperty(name->toPropertyKey()))
| 12-129 | ||||||
| 214 | return object->deleteProperty(name->toPropertyKey()); executed 128 times by 2 tests: return object->deleteProperty(name->toPropertyKey());Executed by:
| 128 | ||||||
| 215 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||
| 216 | break; executed 12 times by 1 test: break;Executed by:
| 12 | ||||||
| 217 | } | - | ||||||
| 218 | case Heap::ExecutionContext::Type_QmlContext: never executed: case Heap::ExecutionContext::Type_QmlContext: | 0 | ||||||
| 219 | // can't delete properties on qml objects | - | ||||||
| 220 | break; never executed: break; | 0 | ||||||
| 221 | } | - | ||||||
| 222 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||
| 223 | - | |||||||
| 224 | return !engine()->currentStackFrame->v4Function->isStrict(); executed 10 times by 1 test: return !engine()->currentStackFrame->v4Function->isStrict();Executed by:
| 10 | ||||||
| 225 | } | - | ||||||
| 226 | - | |||||||
| 227 | ExecutionContext::Error ExecutionContext::setProperty(String *name, const Value &value) | - | ||||||
| 228 | { | - | ||||||
| 229 | PropertyKey id = name->toPropertyKey(); | - | ||||||
| 230 | - | |||||||
| 231 | QV4::ExecutionEngine *v4 = engine(); | - | ||||||
| 232 | Heap::ExecutionContext *ctx = d(); | - | ||||||
| 233 | - | |||||||
| 234 | for (; ctx; ctx = ctx->outer) {
| 788-77414331 | ||||||
| 235 | switch (ctx->type) { | - | ||||||
| 236 | case Heap::ExecutionContext::Type_WithContext: { executed 1531 times by 2 tests: case Heap::ExecutionContext::Type_WithContext:Executed by:
| 1531 | ||||||
| 237 | Scope scope(v4); | - | ||||||
| 238 | ScopedObject w(scope, ctx->activation); | - | ||||||
| 239 | if (w->hasProperty(name->toPropertyKey())) {
| 320-1209 | ||||||
| 240 | if (!w->put(name, value))
| 2-318 | ||||||
| 241 | return TypeError; executed 2 times by 1 test: return TypeError;Executed by:
| 2 | ||||||
| 242 | return NoError; executed 318 times by 2 tests: return NoError;Executed by:
| 318 | ||||||
| 243 | } | - | ||||||
| 244 | break; executed 1207 times by 2 tests: break;Executed by:
| 1207 | ||||||
| 245 | } | - | ||||||
| 246 | case Heap::ExecutionContext::Type_BlockContext: executed 4415313 times by 13 tests: case Heap::ExecutionContext::Type_BlockContext:Executed by:
| 4415313 | ||||||
| 247 | case Heap::ExecutionContext::Type_CallContext: { executed 1618 times by 8 tests: case Heap::ExecutionContext::Type_CallContext:Executed by:
| 1618 | ||||||
| 248 | Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx); | - | ||||||
| 249 | uint index = c->internalClass->find(id); | - | ||||||
| 250 | if (index < UINT_MAX) {
| 30452-4361107 | ||||||
| 251 | static_cast<Heap::CallContext *>(c)->locals.set(v4, index, value); | - | ||||||
| 252 | return NoError; executed 4373543 times by 13 tests: return NoError;Executed by:
| 4373543 | ||||||
| 253 | } | - | ||||||
| 254 | } | - | ||||||
| 255 | Q_FALLTHROUGH(); | - | ||||||
| 256 | case Heap::ExecutionContext::Type_GlobalContext: code before this statement executed 30443 times by 9 tests: case Heap::ExecutionContext::Type_GlobalContext:Executed by:
executed 73171035 times by 7 tests: case Heap::ExecutionContext::Type_GlobalContext:Executed by:
| 30443-73171035 | ||||||
| 257 | if (ctx->activation) {
| 30227-73043228 | ||||||
| 258 | uint member = ctx->activation->internalClass->find(id); | - | ||||||
| 259 | if (member < UINT_MAX) {
| 870-73174503 | ||||||
| 260 | Scope scope(v4); | - | ||||||
| 261 | ScopedObject a(scope, ctx->activation); | - | ||||||
| 262 | if (!a->putValue(member, value))
| 240-72948698 | ||||||
| 263 | return TypeError; executed 240 times by 1 test: return TypeError;Executed by:
| 240 | ||||||
| 264 | return NoError; executed 72956395 times by 7 tests: return NoError;Executed by:
| 72956395 | ||||||
| 265 | } | - | ||||||
| 266 | } executed 870 times by 3 tests: end of blockExecuted by:
| 870 | ||||||
| 267 | break; executed 31118 times by 11 tests: break;Executed by:
| 31118 | ||||||
| 268 | case Heap::ExecutionContext::Type_QmlContext: { executed 42756 times by 36 tests: case Heap::ExecutionContext::Type_QmlContext:Executed by:
| 42756 | ||||||
| 269 | Scope scope(v4); | - | ||||||
| 270 | ScopedObject activation(scope, ctx->activation); | - | ||||||
| 271 | if (!activation->put(name, value))
| 14-42742 | ||||||
| 272 | return TypeError; executed 14 times by 3 tests: return TypeError;Executed by:
| 14 | ||||||
| 273 | return NoError; executed 42742 times by 35 tests: return NoError;Executed by:
| 42742 | ||||||
| 274 | } | - | ||||||
| 275 | } | - | ||||||
| 276 | - | |||||||
| 277 | } executed 32337 times by 11 tests: end of blockExecuted by:
| 32337 | ||||||
| 278 | - | |||||||
| 279 | return RangeError; executed 787 times by 3 tests: return RangeError;Executed by:
| 787 | ||||||
| 280 | } | - | ||||||
| 281 | - | |||||||
| 282 | ReturnedValue ExecutionContext::getProperty(String *name) | - | ||||||
| 283 | { | - | ||||||
| 284 | PropertyKey id = name->toPropertyKey(); | - | ||||||
| 285 | - | |||||||
| 286 | Heap::ExecutionContext *ctx = d(); | - | ||||||
| 287 | for (; ctx; ctx = ctx->outer) {
| 532-5539835 | ||||||
| 288 | switch (ctx->type) { | - | ||||||
| 289 | case Heap::ExecutionContext::Type_BlockContext: executed 1160 times by 8 tests: case Heap::ExecutionContext::Type_BlockContext:Executed by:
| 1160 | ||||||
| 290 | case Heap::ExecutionContext::Type_CallContext: { executed 7349 times by 22 tests: case Heap::ExecutionContext::Type_CallContext:Executed by:
| 7349 | ||||||
| 291 | Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx); | - | ||||||
| 292 | - | |||||||
| 293 | uint index = c->internalClass->find(id); | - | ||||||
| 294 | if (index < UINT_MAX)
| 2500-6012 | ||||||
| 295 | return c->locals[index].asReturnedValue(); executed 2499 times by 6 tests: return c->locals[index].asReturnedValue();Executed by:
| 2499 | ||||||
| 296 | Q_FALLTHROUGH(); | - | ||||||
| 297 | } | - | ||||||
| 298 | case Heap::ExecutionContext::Type_WithContext: code before this statement executed 6012 times by 22 tests: case Heap::ExecutionContext::Type_WithContext:Executed by:
executed 7588 times by 22 tests: case Heap::ExecutionContext::Type_WithContext:Executed by:
| 6012-7588 | ||||||
| 299 | case Heap::ExecutionContext::Type_GlobalContext: executed 3149933 times by 21 tests: case Heap::ExecutionContext::Type_GlobalContext:Executed by:
| 3149933 | ||||||
| 300 | case Heap::ExecutionContext::Type_QmlContext: { executed 2379820 times by 84 tests: case Heap::ExecutionContext::Type_QmlContext:Executed by:
| 2379820 | ||||||
| 301 | if (ctx->activation) {
| 5876-5531473 | ||||||
| 302 | Scope scope(this); | - | ||||||
| 303 | ScopedObject activation(scope, ctx->activation); | - | ||||||
| 304 | bool hasProperty = false; | - | ||||||
| 305 | ReturnedValue v = activation->get(id, nullptr, &hasProperty); | - | ||||||
| 306 | if (hasProperty)
| 1518-5529962 | ||||||
| 307 | return v; executed 5529964 times by 89 tests: return v;Executed by:
| 5529964 | ||||||
| 308 | } executed 1518 times by 16 tests: end of blockExecuted by:
| 1518 | ||||||
| 309 | break; executed 7393 times by 28 tests: break;Executed by:
| 7393 | ||||||
| 310 | } | - | ||||||
| 311 | } | - | ||||||
| 312 | } executed 7394 times by 28 tests: end of blockExecuted by:
| 7394 | ||||||
| 313 | return engine()->throwReferenceError(*name); executed 532 times by 14 tests: return engine()->throwReferenceError(*name);Executed by:
| 532 | ||||||
| 314 | } | - | ||||||
| 315 | - | |||||||
| 316 | ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base) | - | ||||||
| 317 | { | - | ||||||
| 318 | base->setM(nullptr); | - | ||||||
| 319 | PropertyKey id = name->toPropertyKey(); | - | ||||||
| 320 | - | |||||||
| 321 | Heap::ExecutionContext *ctx = d(); | - | ||||||
| 322 | for (; ctx; ctx = ctx->outer) {
| 20-1640850 | ||||||
| 323 | switch (ctx->type) { | - | ||||||
| 324 | case Heap::ExecutionContext::Type_BlockContext: executed 224 times by 2 tests: case Heap::ExecutionContext::Type_BlockContext:Executed by:
| 224 | ||||||
| 325 | case Heap::ExecutionContext::Type_CallContext: { executed 5475 times by 12 tests: case Heap::ExecutionContext::Type_CallContext:Executed by:
| 5475 | ||||||
| 326 | Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx); | - | ||||||
| 327 | - | |||||||
| 328 | uint index = c->internalClass->find(id); | - | ||||||
| 329 | if (index < UINT_MAX)
| 2-5696 | ||||||
| 330 | return c->locals[index].asReturnedValue(); executed 2 times by 1 test: return c->locals[index].asReturnedValue();Executed by:
| 2 | ||||||
| 331 | Q_FALLTHROUGH(); | - | ||||||
| 332 | } | - | ||||||
| 333 | case Heap::ExecutionContext::Type_GlobalContext: { code before this statement executed 5697 times by 12 tests: case Heap::ExecutionContext::Type_GlobalContext:Executed by:
executed 1582175 times by 8 tests: case Heap::ExecutionContext::Type_GlobalContext:Executed by:
| 5697-1582175 | ||||||
| 334 | if (ctx->activation) {
| 5294-1582539 | ||||||
| 335 | Scope scope(this); | - | ||||||
| 336 | ScopedObject activation(scope, ctx->activation); | - | ||||||
| 337 | bool hasProperty = false; | - | ||||||
| 338 | ReturnedValue v = activation->get(name, &hasProperty); | - | ||||||
| 339 | if (hasProperty)
| 28-1582391 | ||||||
| 340 | return v; executed 1582183 times by 5 tests: return v;Executed by:
| 1582183 | ||||||
| 341 | } executed 28 times by 6 tests: end of blockExecuted by:
| 28 | ||||||
| 342 | break; executed 5317 times by 13 tests: break;Executed by:
| 5317 | ||||||
| 343 | } | - | ||||||
| 344 | case Heap::ExecutionContext::Type_WithContext: executed 444 times by 2 tests: case Heap::ExecutionContext::Type_WithContext:Executed by:
| 444 | ||||||
| 345 | case Heap::ExecutionContext::Type_QmlContext: { executed 52216 times by 39 tests: case Heap::ExecutionContext::Type_QmlContext:Executed by:
| 52216 | ||||||
| 346 | Scope scope(this); | - | ||||||
| 347 | ScopedObject o(scope, ctx->activation); | - | ||||||
| 348 | bool hasProperty = false; | - | ||||||
| 349 | ReturnedValue v = o->get(id, nullptr, &hasProperty); | - | ||||||
| 350 | if (hasProperty) {
| 2099-50562 | ||||||
| 351 | base->setM(o->d()); | - | ||||||
| 352 | return v; executed 50562 times by 40 tests: return v;Executed by:
| 50562 | ||||||
| 353 | } | - | ||||||
| 354 | break; executed 2099 times by 6 tests: break;Executed by:
| 2099 | ||||||
| 355 | } | - | ||||||
| 356 | } | - | ||||||
| 357 | } executed 7417 times by 13 tests: end of blockExecuted by:
| 7417 | ||||||
| 358 | return engine()->throwReferenceError(*name); executed 20 times by 6 tests: return engine()->throwReferenceError(*name);Executed by:
| 20 | ||||||
| 359 | } | - | ||||||
| 360 | - | |||||||
| 361 | void Heap::CallContext::setArg(uint index, Value v) | - | ||||||
| 362 | { | - | ||||||
| 363 | locals.set(internalClass->engine, locals.size + index, v); | - | ||||||
| 364 | } executed 67 times by 1 test: end of blockExecuted by:
| 67 | ||||||
| Source code | Switch to Preprocessed file |