| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4property_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 QV4PROPERTYDESCRIPTOR_H | - | ||||||||||||
| 40 | #define QV4PROPERTYDESCRIPTOR_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 "qv4value_p.h" | - | ||||||||||||
| 55 | - | |||||||||||||
| 56 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | namespace QV4 { | - | ||||||||||||
| 59 | - | |||||||||||||
| 60 | struct FunctionObject; | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | struct Property { | - | ||||||||||||
| 63 | Value value; | - | ||||||||||||
| 64 | Value set; | - | ||||||||||||
| 65 | - | |||||||||||||
| 66 | // Section 8.10 | - | ||||||||||||
| 67 | inline void fullyPopulated(PropertyAttributes *attrs) { | - | ||||||||||||
| 68 | if (!attrs->hasType()) {
| 2543-546165 | ||||||||||||
| 69 | value = Primitive::undefinedValue(); | - | ||||||||||||
| 70 | } executed 2539 times by 1 test: end of blockExecuted by:
| 2539 | ||||||||||||
| 71 | if (attrs->type() == PropertyAttributes::Accessor) {
| 11019-537832 | ||||||||||||
| 72 | attrs->clearWritable(); | - | ||||||||||||
| 73 | if (value.isEmpty())
| 2040-8975 | ||||||||||||
| 74 | value = Primitive::undefinedValue(); executed 2041 times by 2 tests: value = Primitive::undefinedValue();Executed by:
| 2041 | ||||||||||||
| 75 | if (set.isEmpty())
| 3534-7500 | ||||||||||||
| 76 | set = Primitive::undefinedValue(); executed 7501 times by 3 tests: set = Primitive::undefinedValue();Executed by:
| 7501 | ||||||||||||
| 77 | } executed 11021 times by 3 tests: end of blockExecuted by:
| 11021 | ||||||||||||
| 78 | attrs->resolve(); | - | ||||||||||||
| 79 | } executed 548287 times by 21 tests: end of blockExecuted by:
| 548287 | ||||||||||||
| 80 | - | |||||||||||||
| 81 | inline bool isSubset(const PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const; | - | ||||||||||||
| 82 | inline void merge(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs); | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | inline Heap::FunctionObject *getter() const { return reinterpret_cast<Heap::FunctionObject *>(value.heapObject()); } executed 8106 times by 1 test: return reinterpret_cast<Heap::FunctionObject *>(value.heapObject());Executed by:
| 8106 | ||||||||||||
| 85 | inline Heap::FunctionObject *setter() const { return reinterpret_cast<Heap::FunctionObject *>(set.heapObject()); } executed 7383 times by 1 test: return reinterpret_cast<Heap::FunctionObject *>(set.heapObject());Executed by:
| 7383 | ||||||||||||
| 86 | inline void setGetter(FunctionObject *g) { value = reinterpret_cast<Managed *>(g); } executed 3774682 times by 154 tests: end of blockExecuted by:
| 3774682 | ||||||||||||
| 87 | inline void setSetter(FunctionObject *s) { set = (s ? reinterpret_cast<Managed *>(s) : nullptr); } executed 3776268 times by 154 tests: end of blockExecuted by:
| 123935-3776268 | ||||||||||||
| 88 | - | |||||||||||||
| 89 | void copy(const Property *other, PropertyAttributes attrs) { | - | ||||||||||||
| 90 | value = other->value; | - | ||||||||||||
| 91 | if (attrs.isAccessor())
| 11273-537595 | ||||||||||||
| 92 | set = other->set; executed 11267 times by 3 tests: set = other->set;Executed by:
| 11267 | ||||||||||||
| 93 | } executed 548793 times by 22 tests: end of blockExecuted by:
| 548793 | ||||||||||||
| 94 | - | |||||||||||||
| 95 | explicit Property() { value = Encode::undefined(); set = Value::fromHeapObject(nullptr); } executed 2097 times by 5 tests: end of blockExecuted by:
| 2097 | ||||||||||||
| 96 | Property(Heap::FunctionObject *getter, Heap::FunctionObject *setter) { | - | ||||||||||||
| 97 | value.setM(reinterpret_cast<Heap::Base *>(getter)); | - | ||||||||||||
| 98 | set.setM(reinterpret_cast<Heap::Base *>(setter)); | - | ||||||||||||
| 99 | } never executed: end of block | 0 | ||||||||||||
| 100 | private: | - | ||||||||||||
| 101 | Q_DISABLE_COPY(Property) | - | ||||||||||||
| 102 | }; | - | ||||||||||||
| 103 | - | |||||||||||||
| 104 | inline bool Property::isSubset(const PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const | - | ||||||||||||
| 105 | { | - | ||||||||||||
| 106 | if (attrs.type() != PropertyAttributes::Generic && attrs.type() != otherAttrs.type())
| 1084-4560 | ||||||||||||
| 107 | return false; executed 1199 times by 2 tests: return false;Executed by:
| 1199 | ||||||||||||
| 108 | if (attrs.hasEnumerable() && attrs.isEnumerable() != otherAttrs.isEnumerable())
| 489-2745 | ||||||||||||
| 109 | return false; executed 489 times by 1 test: return false;Executed by:
| 489 | ||||||||||||
| 110 | if (attrs.hasConfigurable() && attrs.isConfigurable() != otherAttrs.isConfigurable())
| 620-2120 | ||||||||||||
| 111 | return false; executed 620 times by 1 test: return false;Executed by:
| 620 | ||||||||||||
| 112 | if (attrs.hasWritable() && attrs.isWritable() != otherAttrs.isWritable())
| 122-2416 | ||||||||||||
| 113 | return false; executed 793 times by 1 test: return false;Executed by:
| 793 | ||||||||||||
| 114 | if (attrs.type() == PropertyAttributes::Data && !value.sameValue(other->value))
| 204-1389 | ||||||||||||
| 115 | return false; executed 940 times by 1 test: return false;Executed by:
| 940 | ||||||||||||
| 116 | if (attrs.type() == PropertyAttributes::Accessor) {
| 268-1328 | ||||||||||||
| 117 | if (value.heapObject() != other->value.heapObject())
| 244-1091 | ||||||||||||
| 118 | return false; executed 1090 times by 3 tests: return false;Executed by:
| 1090 | ||||||||||||
| 119 | if (set.heapObject() != other->set.heapObject())
| 60-184 | ||||||||||||
| 120 | return false; executed 184 times by 1 test: return false;Executed by:
| 184 | ||||||||||||
| 121 | } executed 60 times by 1 test: end of blockExecuted by:
| 60 | ||||||||||||
| 122 | return true; executed 328 times by 1 test: return true;Executed by:
| 328 | ||||||||||||
| 123 | } | - | ||||||||||||
| 124 | - | |||||||||||||
| 125 | inline void Property::merge(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) | - | ||||||||||||
| 126 | { | - | ||||||||||||
| 127 | if (otherAttrs.hasEnumerable())
| 1613-1942 | ||||||||||||
| 128 | attrs.setEnumerable(otherAttrs.isEnumerable()); executed 1613 times by 3 tests: attrs.setEnumerable(otherAttrs.isEnumerable());Executed by:
| 1613 | ||||||||||||
| 129 | if (otherAttrs.hasConfigurable())
| 1365-2195 | ||||||||||||
| 130 | attrs.setConfigurable(otherAttrs.isConfigurable()); executed 2194 times by 3 tests: attrs.setConfigurable(otherAttrs.isConfigurable());Executed by:
| 2194 | ||||||||||||
| 131 | if (otherAttrs.hasWritable())
| 811-2753 | ||||||||||||
| 132 | attrs.setWritable(otherAttrs.isWritable()); executed 811 times by 1 test: attrs.setWritable(otherAttrs.isWritable());Executed by:
| 811 | ||||||||||||
| 133 | if (otherAttrs.type() == PropertyAttributes::Accessor) {
| 1569-1993 | ||||||||||||
| 134 | attrs.setType(PropertyAttributes::Accessor); | - | ||||||||||||
| 135 | if (!other->value.isEmpty())
| 551-1441 | ||||||||||||
| 136 | value = other->value; executed 1441 times by 2 tests: value = other->value;Executed by:
| 1441 | ||||||||||||
| 137 | if (!other->set.isEmpty())
| 688-1312 | ||||||||||||
| 138 | set = other->set; executed 688 times by 3 tests: set = other->set;Executed by:
| 688 | ||||||||||||
| 139 | } else if (otherAttrs.type() == PropertyAttributes::Data){ executed 2000 times by 3 tests: end of blockExecuted by:
| 537-2000 | ||||||||||||
| 140 | attrs.setType(PropertyAttributes::Data); | - | ||||||||||||
| 141 | value = other->value; | - | ||||||||||||
| 142 | } executed 1035 times by 1 test: end of blockExecuted by:
| 1035 | ||||||||||||
| 143 | } executed 3570 times by 3 tests: end of blockExecuted by:
| 3570 | ||||||||||||
| 144 | - | |||||||||||||
| 145 | struct PropertyIndex { | - | ||||||||||||
| 146 | Heap::Base *base; | - | ||||||||||||
| 147 | Value *slot; | - | ||||||||||||
| 148 | - | |||||||||||||
| 149 | void set(EngineBase *e, Value newVal) { | - | ||||||||||||
| 150 | WriteBarrier::write(e, base, slot->data_ptr(), newVal.asReturnedValue()); | - | ||||||||||||
| 151 | } executed 31771 times by 30 tests: end of blockExecuted by:
| 31771 | ||||||||||||
| 152 | const Value *operator->() const { return slot; } executed 40305 times by 11 tests: return slot;Executed by:
| 40305 | ||||||||||||
| 153 | const Value &operator*() const { return *slot; } executed 207025 times by 55 tests: return *slot;Executed by:
| 207025 | ||||||||||||
| 154 | bool isNull() const { return !slot; } executed 3296479 times by 153 tests: return !slot;Executed by:
| 3296479 | ||||||||||||
| 155 | }; | - | ||||||||||||
| 156 | - | |||||||||||||
| 157 | - | |||||||||||||
| 158 | } | - | ||||||||||||
| 159 | - | |||||||||||||
| 160 | Q_DECLARE_TYPEINFO(QV4::Property, Q_MOVABLE_TYPE); never executed: return "QV4::Property"; | 0 | ||||||||||||
| 161 | - | |||||||||||||
| 162 | QT_END_NAMESPACE | - | ||||||||||||
| 163 | - | |||||||||||||
| 164 | #endif | - | ||||||||||||
| Source code | Switch to Preprocessed file |