| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4context_p.h |
| 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 | #ifndef QMLJS_ENVIRONMENT_H | - | ||||||||||||
| 40 | #define QMLJS_ENVIRONMENT_H | - | ||||||||||||
| 41 | - | |||||||||||||
| 42 | // | - | ||||||||||||
| 43 | // W A R N I N G | - | ||||||||||||
| 44 | // ------------- | - | ||||||||||||
| 45 | // | - | ||||||||||||
| 46 | // This file is not part of the Qt API. It exists purely as an | - | ||||||||||||
| 47 | // implementation detail. This header file may change from version to | - | ||||||||||||
| 48 | // version without notice, or even be removed. | - | ||||||||||||
| 49 | // | - | ||||||||||||
| 50 | // We mean it. | - | ||||||||||||
| 51 | // | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | #include "qv4global_p.h" | - | ||||||||||||
| 54 | #include "qv4managed_p.h" | - | ||||||||||||
| 55 | - | |||||||||||||
| 56 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | namespace QV4 { | - | ||||||||||||
| 59 | - | |||||||||||||
| 60 | - | |||||||||||||
| 61 | namespace Heap { | - | ||||||||||||
| 62 | - | |||||||||||||
| 63 | #define ExecutionContextMembers(class, Member) \ | - | ||||||||||||
| 64 | Member(class, Pointer, ExecutionContext *, outer) \ | - | ||||||||||||
| 65 | Member(class, Pointer, Object *, activation) | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | DECLARE_HEAP_OBJECT(ExecutionContext, Base) { | - | ||||||||||||
| 68 | DECLARE_MARKOBJECTS(ExecutionContext); executed 89894 times by 27 tests: end of blockExecuted by:
executed 81038 times by 22 tests: o->outer.heapObject()->mark(stack);Executed by:
executed 89874 times by 27 tests: o->activation.heapObject()->mark(stack);Executed by:
| 20-89894 | ||||||||||||
| 69 | - | |||||||||||||
| 70 | enum ContextType { | - | ||||||||||||
| 71 | Type_GlobalContext = 0x1, | - | ||||||||||||
| 72 | Type_WithContext = 0x2, | - | ||||||||||||
| 73 | Type_QmlContext = 0x3, | - | ||||||||||||
| 74 | Type_BlockContext = 0x4, | - | ||||||||||||
| 75 | Type_CallContext = 0x5 | - | ||||||||||||
| 76 | }; | - | ||||||||||||
| 77 | - | |||||||||||||
| 78 | void init(ContextType t) | - | ||||||||||||
| 79 | { | - | ||||||||||||
| 80 | Base::init(); | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | type = t; | - | ||||||||||||
| 83 | } executed 6062128 times by 154 tests: end of blockExecuted by:
| 6062128 | ||||||||||||
| 84 | - | |||||||||||||
| 85 | const VTable *vtable() const { | - | ||||||||||||
| 86 | return internalClass->vtable; executed 1559567 times by 130 tests: return internalClass->vtable;Executed by:
| 1559567 | ||||||||||||
| 87 | } | - | ||||||||||||
| 88 | - | |||||||||||||
| 89 | quint32 type : 8; | - | ||||||||||||
| 90 | quint32 nArgs : 24; | - | ||||||||||||
| 91 | #if QT_POINTER_SIZE == 8 | - | ||||||||||||
| 92 | quint8 padding_[4]; | - | ||||||||||||
| 93 | #endif | - | ||||||||||||
| 94 | }; | - | ||||||||||||
| 95 | Q_STATIC_ASSERT(std::is_trivial< ExecutionContext >::value); | - | ||||||||||||
| 96 | Q_STATIC_ASSERT(sizeof(ExecutionContext) == sizeof(Base) + sizeof(ExecutionContextData) + QT_POINTER_SIZE); | - | ||||||||||||
| 97 | - | |||||||||||||
| 98 | Q_STATIC_ASSERT(std::is_standard_layout<ExecutionContextData>::value); | - | ||||||||||||
| 99 | Q_STATIC_ASSERT(offsetof(ExecutionContextData, outer) == 0); | - | ||||||||||||
| 100 | Q_STATIC_ASSERT(offsetof(ExecutionContextData, activation) == offsetof(ExecutionContextData, outer) + QT_POINTER_SIZE); | - | ||||||||||||
| 101 | - | |||||||||||||
| 102 | #define CallContextMembers(class, Member) \ | - | ||||||||||||
| 103 | Member(class, Pointer, FunctionObject *, function) \ | - | ||||||||||||
| 104 | Member(class, ValueArray, ValueArray, locals) | - | ||||||||||||
| 105 | - | |||||||||||||
| 106 | DECLARE_HEAP_OBJECT(CallContext, ExecutionContext) { | - | ||||||||||||
| 107 | DECLARE_MARKOBJECTS(CallContext); executed 20 times by 2 tests: end of blockExecuted by:
executed 4 times by 1 test: o->function.heapObject()->mark(stack);Executed by:
| 4-20 | ||||||||||||
| 108 | - | |||||||||||||
| 109 | void init() | - | ||||||||||||
| 110 | { | - | ||||||||||||
| 111 | ExecutionContext::init(Type_CallContext); | - | ||||||||||||
| 112 | } executed 4410185 times by 29 tests: end of blockExecuted by:
| 4410185 | ||||||||||||
| 113 | - | |||||||||||||
| 114 | int argc() const { | - | ||||||||||||
| 115 | return static_cast<int>(nArgs); executed 6590 times by 11 tests: return static_cast<int>(nArgs);Executed by:
| 6590 | ||||||||||||
| 116 | } | - | ||||||||||||
| 117 | const Value *args() const { | - | ||||||||||||
| 118 | return locals.data() + locals.size; executed 1963 times by 4 tests: return locals.data() + locals.size;Executed by:
| 1963 | ||||||||||||
| 119 | } | - | ||||||||||||
| 120 | void setArg(uint index, Value v); | - | ||||||||||||
| 121 | }; | - | ||||||||||||
| 122 | Q_STATIC_ASSERT(std::is_trivial< CallContext >::value); | - | ||||||||||||
| 123 | Q_STATIC_ASSERT(std::is_standard_layout<CallContextData>::value); | - | ||||||||||||
| 124 | Q_STATIC_ASSERT(offsetof(CallContextData, function) == 0); | - | ||||||||||||
| 125 | //### The following size check fails on Win8. With the ValueArray at the end of the | - | ||||||||||||
| 126 | // CallContextMembers, it doesn't look very useful. | - | ||||||||||||
| 127 | //#if defined(Q_PROCESSOR_ARM_32) && !defined(Q_OS_IOS) | - | ||||||||||||
| 128 | //Q_STATIC_ASSERT(sizeof(CallContext) == sizeof(ExecutionContext) + sizeof(CallContextData) + QT_POINTER_SIZE); | - | ||||||||||||
| 129 | //#else | - | ||||||||||||
| 130 | //Q_STATIC_ASSERT(sizeof(CallContext) == sizeof(ExecutionContext) + sizeof(CallContextData)); | - | ||||||||||||
| 131 | //#endif | - | ||||||||||||
| 132 | - | |||||||||||||
| 133 | - | |||||||||||||
| 134 | } | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | struct Q_QML_EXPORT ExecutionContext : public Managed | - | ||||||||||||
| 137 | { | - | ||||||||||||
| 138 | enum { | - | ||||||||||||
| 139 | IsExecutionContext = true | - | ||||||||||||
| 140 | }; | - | ||||||||||||
| 141 | - | |||||||||||||
| 142 | V4_MANAGED(ExecutionContext, Managed) never executed: end of blocknever executed: end of blockexecuted 198971 times by 154 tests: return &static_vtbl;Executed by:
executed 146347902 times by 154 tests: return static_cast<QV4::Heap::ExecutionContext *>(m());Executed by:
executed 146379841 times by 154 tests: return dptr;Executed by:
| 0-146379841 | ||||||||||||
| 143 | Q_MANAGED_TYPE(ExecutionContext) | - | ||||||||||||
| 144 | V4_INTERNALCLASS(ExecutionContext) executed 99511 times by 154 tests: return e->internalClasses(QV4::EngineBase::Class_ExecutionContext);Executed by:
| 99511 | ||||||||||||
| 145 | - | |||||||||||||
| 146 | static Heap::CallContext *newBlockContext(QV4::CppStackFrame *frame, int blockIndex); | - | ||||||||||||
| 147 | static Heap::CallContext *cloneBlockContext(Heap::CallContext *context); | - | ||||||||||||
| 148 | static Heap::CallContext *newCallContext(QV4::CppStackFrame *frame); | - | ||||||||||||
| 149 | Heap::ExecutionContext *newWithContext(Heap::Object *with); | - | ||||||||||||
| 150 | static Heap::ExecutionContext *newCatchContext(CppStackFrame *frame, int blockIndex, Heap::String *exceptionVarName); | - | ||||||||||||
| 151 | - | |||||||||||||
| 152 | void createMutableBinding(String *name, bool deletable); | - | ||||||||||||
| 153 | - | |||||||||||||
| 154 | enum Error { | - | ||||||||||||
| 155 | NoError, | - | ||||||||||||
| 156 | TypeError, | - | ||||||||||||
| 157 | RangeError | - | ||||||||||||
| 158 | }; | - | ||||||||||||
| 159 | - | |||||||||||||
| 160 | Error setProperty(String *name, const Value &value); | - | ||||||||||||
| 161 | - | |||||||||||||
| 162 | ReturnedValue getProperty(String *name); | - | ||||||||||||
| 163 | ReturnedValue getPropertyAndBase(String *name, Value *base); | - | ||||||||||||
| 164 | bool deleteProperty(String *name); | - | ||||||||||||
| 165 | - | |||||||||||||
| 166 | inline CallContext *asCallContext(); | - | ||||||||||||
| 167 | inline const CallContext *asCallContext() const; | - | ||||||||||||
| 168 | - | |||||||||||||
| 169 | protected: | - | ||||||||||||
| 170 | // vtable method required for compilation | - | ||||||||||||
| 171 | static bool virtualDeleteProperty(Managed *, PropertyKey) { | - | ||||||||||||
| 172 | Q_UNREACHABLE(); | - | ||||||||||||
| 173 | } never executed: end of block | 0 | ||||||||||||
| 174 | }; | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 | struct Q_QML_EXPORT CallContext : public ExecutionContext | - | ||||||||||||
| 177 | { | - | ||||||||||||
| 178 | V4_MANAGED(CallContext, ExecutionContext) never executed: end of blocknever executed: end of blockexecuted 4504952 times by 154 tests: return &static_vtbl;Executed by:
executed 13557 times by 12 tests: return static_cast<QV4::Heap::CallContext *>(m());Executed by:
executed 13562 times by 12 tests: return dptr;Executed by:
| 0-4504952 | ||||||||||||
| 179 | V4_INTERNALCLASS(CallContext) never executed: return e->internalClasses(QV4::EngineBase::Class_CallContext); | 0 | ||||||||||||
| 180 | - | |||||||||||||
| 181 | int argc() const { | - | ||||||||||||
| 182 | return d()->argc(); executed 4496 times by 11 tests: return d()->argc();Executed by:
| 4496 | ||||||||||||
| 183 | } | - | ||||||||||||
| 184 | const Value *args() const { | - | ||||||||||||
| 185 | return d()->args(); never executed: return d()->args(); | 0 | ||||||||||||
| 186 | } | - | ||||||||||||
| 187 | }; | - | ||||||||||||
| 188 | - | |||||||||||||
| 189 | inline CallContext *ExecutionContext::asCallContext() | - | ||||||||||||
| 190 | { | - | ||||||||||||
| 191 | return d()->type == Heap::ExecutionContext::Type_CallContext ? static_cast<CallContext *>(this) : nullptr; executed 232 times by 1 test: return d()->type == Heap::ExecutionContext::Type_CallContext ? static_cast<CallContext *>(this) : nullptr;Executed by:
| 232 | ||||||||||||
| 192 | } | - | ||||||||||||
| 193 | - | |||||||||||||
| 194 | inline const CallContext *ExecutionContext::asCallContext() const | - | ||||||||||||
| 195 | { | - | ||||||||||||
| 196 | return d()->type == Heap::ExecutionContext::Type_CallContext ? static_cast<const CallContext *>(this) : nullptr; never executed: return d()->type == Heap::ExecutionContext::Type_CallContext ? static_cast<const CallContext *>(this) : nullptr; | 0 | ||||||||||||
| 197 | } | - | ||||||||||||
| 198 | - | |||||||||||||
| 199 | } // namespace QV4 | - | ||||||||||||
| 200 | - | |||||||||||||
| 201 | QT_END_NAMESPACE | - | ||||||||||||
| 202 | - | |||||||||||||
| 203 | #endif | - | ||||||||||||
| Source code | Switch to Preprocessed file |