| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4objectproto.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||||||||
| 3 | ** Copyright (C) 2017 Crimson AS <info@crimson.no> | - | ||||||||||||||||||||||||
| 4 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||
| 5 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
| 6 | ** | - | ||||||||||||||||||||||||
| 7 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||||||||||||||||||||
| 8 | ** | - | ||||||||||||||||||||||||
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||
| 10 | ** Commercial License Usage | - | ||||||||||||||||||||||||
| 11 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
| 12 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
| 13 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
| 14 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
| 15 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
| 16 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
| 17 | ** | - | ||||||||||||||||||||||||
| 18 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
| 19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
| 20 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||
| 21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||
| 22 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||
| 23 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||
| 24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||
| 25 | ** | - | ||||||||||||||||||||||||
| 26 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||
| 27 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||
| 28 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||
| 29 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||
| 30 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||
| 31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||
| 32 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||
| 33 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||
| 34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||
| 35 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||
| 36 | ** | - | ||||||||||||||||||||||||
| 37 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
| 38 | ** | - | ||||||||||||||||||||||||
| 39 | ****************************************************************************/ | - | ||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | #include "qv4objectproto_p.h" | - | ||||||||||||||||||||||||
| 43 | #include "qv4argumentsobject_p.h" | - | ||||||||||||||||||||||||
| 44 | #include <private/qv4mm_p.h> | - | ||||||||||||||||||||||||
| 45 | #include "qv4scopedvalue_p.h" | - | ||||||||||||||||||||||||
| 46 | #include "qv4runtime_p.h" | - | ||||||||||||||||||||||||
| 47 | #include "qv4objectiterator_p.h" | - | ||||||||||||||||||||||||
| 48 | #include "qv4string_p.h" | - | ||||||||||||||||||||||||
| 49 | #include "qv4jscall_p.h" | - | ||||||||||||||||||||||||
| 50 | #include "qv4symbol_p.h" | - | ||||||||||||||||||||||||
| 51 | #include "qv4propertykey_p.h" | - | ||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | #include <QtCore/QDateTime> | - | ||||||||||||||||||||||||
| 54 | #include <QtCore/QStringList> | - | ||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | using namespace QV4; | - | ||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||
| 59 | DEFINE_OBJECT_VTABLE(ObjectCtor); | - | ||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||
| 61 | void Heap::ObjectCtor::init(QV4::ExecutionContext *scope) | - | ||||||||||||||||||||||||
| 62 | { | - | ||||||||||||||||||||||||
| 63 | Heap::FunctionObject::init(scope, QStringLiteral("Object")); executed 98774 times by 153 tests: return qstring_literal_temp;Executed by:
| 98774 | ||||||||||||||||||||||||
| 64 | } executed 98895 times by 153 tests: end of blockExecuted by:
| 98895 | ||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||
| 66 | ReturnedValue ObjectCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget) | - | ||||||||||||||||||||||||
| 67 | { | - | ||||||||||||||||||||||||
| 68 | ExecutionEngine *v4 = f->engine(); | - | ||||||||||||||||||||||||
| 69 | const ObjectCtor *nt = static_cast<const ObjectCtor *>(newTarget); | - | ||||||||||||||||||||||||
| 70 | if (!argc || argv[0].isUndefined() || argv[0].isNull()) {
| 16-1931 | ||||||||||||||||||||||||
| 71 | Scope scope(v4); | - | ||||||||||||||||||||||||
| 72 | ScopedObject obj(scope, scope.engine->newObject()); | - | ||||||||||||||||||||||||
| 73 | ScopedObject proto(scope, nt->get(scope.engine->id_prototype())); | - | ||||||||||||||||||||||||
| 74 | if (!!proto)
| 0-1976 | ||||||||||||||||||||||||
| 75 | obj->setPrototypeOf(proto); executed 1975 times by 10 tests: obj->setPrototypeOf(proto);Executed by:
| 1975 | ||||||||||||||||||||||||
| 76 | return obj.asReturnedValue(); executed 1980 times by 10 tests: return obj.asReturnedValue();Executed by:
| 1980 | ||||||||||||||||||||||||
| 77 | } else { | - | ||||||||||||||||||||||||
| 78 | return argv[0].toObject(v4)->asReturnedValue(); executed 250 times by 2 tests: return argv[0].toObject(v4)->asReturnedValue();Executed by:
| 250 | ||||||||||||||||||||||||
| 79 | } | - | ||||||||||||||||||||||||
| 80 | } | - | ||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | ReturnedValue ObjectCtor::virtualCall(const FunctionObject *m, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 83 | { | - | ||||||||||||||||||||||||
| 84 | ExecutionEngine *v4 = m->engine(); | - | ||||||||||||||||||||||||
| 85 | if (!argc || argv[0].isUndefined() || argv[0].isNull()) {
| 8-483 | ||||||||||||||||||||||||
| 86 | return v4->newObject()->asReturnedValue(); executed 36 times by 3 tests: return v4->newObject()->asReturnedValue();Executed by:
| 36 | ||||||||||||||||||||||||
| 87 | } else { | - | ||||||||||||||||||||||||
| 88 | return argv[0].toObject(v4)->asReturnedValue(); executed 463 times by 1 test: return argv[0].toObject(v4)->asReturnedValue();Executed by:
| 463 | ||||||||||||||||||||||||
| 89 | } | - | ||||||||||||||||||||||||
| 90 | } | - | ||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor) | - | ||||||||||||||||||||||||
| 93 | { | - | ||||||||||||||||||||||||
| 94 | Scope scope(v4); | - | ||||||||||||||||||||||||
| 95 | ScopedObject o(scope, this); | - | ||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||
| 97 | ctor->defineReadonlyProperty(v4->id_prototype(), o); | - | ||||||||||||||||||||||||
| 98 | ctor->defineReadonlyConfigurableProperty(v4->id_length(), Primitive::fromInt32(1)); | - | ||||||||||||||||||||||||
| 99 | ctor->defineDefaultProperty(QStringLiteral("getPrototypeOf"), method_getPrototypeOf, 1); executed 98420 times by 153 tests: return qstring_literal_temp;Executed by:
| 98420 | ||||||||||||||||||||||||
| 100 | ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptor"), method_getOwnPropertyDescriptor, 2); executed 98975 times by 153 tests: return qstring_literal_temp;Executed by:
| 98975 | ||||||||||||||||||||||||
| 101 | ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyNames"), method_getOwnPropertyNames, 1); executed 99071 times by 153 tests: return qstring_literal_temp;Executed by:
| 99071 | ||||||||||||||||||||||||
| 102 | ctor->defineDefaultProperty(QStringLiteral("getOwnPropertySymbols"), method_getOwnPropertySymbols, 1); executed 99078 times by 153 tests: return qstring_literal_temp;Executed by:
| 99078 | ||||||||||||||||||||||||
| 103 | ctor->defineDefaultProperty(QStringLiteral("assign"), method_assign, 2); executed 99054 times by 153 tests: return qstring_literal_temp;Executed by:
| 99054 | ||||||||||||||||||||||||
| 104 | ctor->defineDefaultProperty(QStringLiteral("create"), method_create, 2); executed 99021 times by 153 tests: return qstring_literal_temp;Executed by:
| 99021 | ||||||||||||||||||||||||
| 105 | ctor->defineDefaultProperty(QStringLiteral("defineProperty"), method_defineProperty, 3); executed 98845 times by 153 tests: return qstring_literal_temp;Executed by:
| 98845 | ||||||||||||||||||||||||
| 106 | ctor->defineDefaultProperty(QStringLiteral("defineProperties"), method_defineProperties, 2); executed 99044 times by 153 tests: return qstring_literal_temp;Executed by:
| 99044 | ||||||||||||||||||||||||
| 107 | ctor->defineDefaultProperty(QStringLiteral("seal"), method_seal, 1); executed 99040 times by 153 tests: return qstring_literal_temp;Executed by:
| 99040 | ||||||||||||||||||||||||
| 108 | ctor->defineDefaultProperty(QStringLiteral("freeze"), method_freeze, 1); executed 99087 times by 153 tests: return qstring_literal_temp;Executed by:
| 99087 | ||||||||||||||||||||||||
| 109 | ctor->defineDefaultProperty(QStringLiteral("preventExtensions"), method_preventExtensions, 1); executed 99104 times by 153 tests: return qstring_literal_temp;Executed by:
| 99104 | ||||||||||||||||||||||||
| 110 | ctor->defineDefaultProperty(QStringLiteral("is"), method_is, 2); executed 99111 times by 153 tests: return qstring_literal_temp;Executed by:
| 99111 | ||||||||||||||||||||||||
| 111 | ctor->defineDefaultProperty(QStringLiteral("isSealed"), method_isSealed, 1); executed 99120 times by 153 tests: return qstring_literal_temp;Executed by:
| 99120 | ||||||||||||||||||||||||
| 112 | ctor->defineDefaultProperty(QStringLiteral("isFrozen"), method_isFrozen, 1); executed 99101 times by 153 tests: return qstring_literal_temp;Executed by:
| 99101 | ||||||||||||||||||||||||
| 113 | ctor->defineDefaultProperty(QStringLiteral("isExtensible"), method_isExtensible, 1); executed 98908 times by 153 tests: return qstring_literal_temp;Executed by:
| 98908 | ||||||||||||||||||||||||
| 114 | ctor->defineDefaultProperty(QStringLiteral("keys"), method_keys, 1); executed 99121 times by 153 tests: return qstring_literal_temp;Executed by:
| 99121 | ||||||||||||||||||||||||
| 115 | ctor->defineDefaultProperty(QStringLiteral("setPrototypeOf"), method_setPrototypeOf, 2); executed 99106 times by 153 tests: return qstring_literal_temp;Executed by:
| 99106 | ||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | defineDefaultProperty(QStringLiteral("constructor"), (o = ctor)); executed 98899 times by 153 tests: return qstring_literal_temp;Executed by:
| 98899 | ||||||||||||||||||||||||
| 118 | defineDefaultProperty(v4->id_toString(), method_toString, 0); | - | ||||||||||||||||||||||||
| 119 | defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0); executed 99038 times by 153 tests: return qstring_literal_temp;Executed by:
| 99038 | ||||||||||||||||||||||||
| 120 | defineDefaultProperty(v4->id_valueOf(), method_valueOf, 0); | - | ||||||||||||||||||||||||
| 121 | defineDefaultProperty(QStringLiteral("hasOwnProperty"), method_hasOwnProperty, 1); executed 99020 times by 153 tests: return qstring_literal_temp;Executed by:
| 99020 | ||||||||||||||||||||||||
| 122 | defineDefaultProperty(QStringLiteral("isPrototypeOf"), method_isPrototypeOf, 1); executed 99080 times by 153 tests: return qstring_literal_temp;Executed by:
| 99080 | ||||||||||||||||||||||||
| 123 | defineDefaultProperty(QStringLiteral("propertyIsEnumerable"), method_propertyIsEnumerable, 1); executed 99057 times by 153 tests: return qstring_literal_temp;Executed by:
| 99057 | ||||||||||||||||||||||||
| 124 | defineDefaultProperty(QStringLiteral("__defineGetter__"), method_defineGetter, 2); executed 98847 times by 153 tests: return qstring_literal_temp;Executed by:
| 98847 | ||||||||||||||||||||||||
| 125 | defineDefaultProperty(QStringLiteral("__defineSetter__"), method_defineSetter, 2); executed 99032 times by 153 tests: return qstring_literal_temp;Executed by:
| 99032 | ||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | defineAccessorProperty(v4->id___proto__(), method_get_proto, method_set_proto); | - | ||||||||||||||||||||||||
| 128 | } executed 98848 times by 153 tests: end of blockExecuted by:
| 98848 | ||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||
| 130 | ReturnedValue ObjectPrototype::method_getPrototypeOf(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 131 | { | - | ||||||||||||||||||||||||
| 132 | Scope scope(b); | - | ||||||||||||||||||||||||
| 133 | if (argc < 1)
| 4-7771 | ||||||||||||||||||||||||
| 134 | return scope.engine->throwTypeError(); executed 4 times by 1 test: return scope.engine->throwTypeError();Executed by:
| 4 | ||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | ScopedObject o(scope, argv[0].toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 137 | if (scope.engine->hasException)
| 12-7756 | ||||||||||||||||||||||||
| 138 | return QV4::Encode::undefined(); executed 12 times by 1 test: return QV4::Encode::undefined();Executed by:
| 12 | ||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | ScopedObject p(scope, o->getPrototypeOf()); | - | ||||||||||||||||||||||||
| 141 | return (!!p ? p->asReturnedValue() : Encode::null()); executed 7756 times by 2 tests: return (!!p ? p->asReturnedValue() : Encode::null());Executed by:
| 7756 | ||||||||||||||||||||||||
| 142 | } | - | ||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||
| 144 | ReturnedValue ObjectPrototype::method_is(const FunctionObject *, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 145 | { | - | ||||||||||||||||||||||||
| 146 | if (!argc)
| 4-340 | ||||||||||||||||||||||||
| 147 | return Encode(true); executed 4 times by 1 test: return Encode(true);Executed by:
| 4 | ||||||||||||||||||||||||
| 148 | if (argc == 1)
| 12-328 | ||||||||||||||||||||||||
| 149 | return Encode((argv[0].isUndefined() ? true : false)); executed 12 times by 1 test: return Encode((argv[0].isUndefined() ? true : false));Executed by:
| 12 | ||||||||||||||||||||||||
| 150 | return Encode(argv[0].sameValue(argv[1])); executed 328 times by 1 test: return Encode(argv[0].sameValue(argv[1]));Executed by:
| 328 | ||||||||||||||||||||||||
| 151 | } | - | ||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||
| 153 | ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 154 | { | - | ||||||||||||||||||||||||
| 155 | Scope scope(b); | - | ||||||||||||||||||||||||
| 156 | if (argc < 1)
| 0-25145 | ||||||||||||||||||||||||
| 157 | return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||
| 159 | ScopedObject O(scope, argv[0].toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 160 | if (scope.engine->hasException)
| 16-25078 | ||||||||||||||||||||||||
| 161 | return QV4::Encode::undefined(); executed 16 times by 1 test: return QV4::Encode::undefined();Executed by:
| 16 | ||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||
| 163 | if (ArgumentsObject::isNonStrictArgumentsObject(O))
| 771-24367 | ||||||||||||||||||||||||
| 164 | static_cast<ArgumentsObject *>(O.getPointer())->fullyCreate(); executed 769 times by 1 test: static_cast<ArgumentsObject *>(O.getPointer())->fullyCreate();Executed by:
| 769 | ||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | ScopedValue v(scope, argc > 1 ? argv[1] : Primitive::undefinedValue()); | - | ||||||||||||||||||||||||
| 167 | ScopedPropertyKey name(scope, v->toPropertyKey(scope.engine)); | - | ||||||||||||||||||||||||
| 168 | if (scope.engine->hasException)
| 8-25160 | ||||||||||||||||||||||||
| 169 | return QV4::Encode::undefined(); executed 8 times by 1 test: return QV4::Encode::undefined();Executed by:
| 8 | ||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | ScopedProperty desc(scope); | - | ||||||||||||||||||||||||
| 172 | PropertyAttributes attrs = O->getOwnProperty(name, desc); | - | ||||||||||||||||||||||||
| 173 | return fromPropertyDescriptor(scope.engine, desc, attrs); executed 25131 times by 1 test: return fromPropertyDescriptor(scope.engine, desc, attrs);Executed by:
| 25131 | ||||||||||||||||||||||||
| 174 | } | - | ||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||
| 176 | ReturnedValue ObjectPrototype::method_getOwnPropertyNames(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 177 | { | - | ||||||||||||||||||||||||
| 178 | Scope scope(b); | - | ||||||||||||||||||||||||
| 179 | if (argc < 1)
| 0-268 | ||||||||||||||||||||||||
| 180 | return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||
| 182 | ScopedObject O(scope, argv[0].toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 183 | if (scope.engine->hasException)
| 8-260 | ||||||||||||||||||||||||
| 184 | return QV4::Encode::undefined(); executed 8 times by 1 test: return QV4::Encode::undefined();Executed by:
| 8 | ||||||||||||||||||||||||
| 185 | - | |||||||||||||||||||||||||
| 186 | return Encode(getOwnPropertyNames(scope.engine, argv[0])); executed 261 times by 2 tests: return Encode(getOwnPropertyNames(scope.engine, argv[0]));Executed by:
| 261 | ||||||||||||||||||||||||
| 187 | } | - | ||||||||||||||||||||||||
| 188 | - | |||||||||||||||||||||||||
| 189 | ReturnedValue ObjectPrototype::method_getOwnPropertySymbols(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 190 | { | - | ||||||||||||||||||||||||
| 191 | Scope scope(f); | - | ||||||||||||||||||||||||
| 192 | if (!argc)
| 0-24 | ||||||||||||||||||||||||
| 193 | return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||
| 195 | ScopedObject O(scope, argv[0].toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 196 | if (!O)
| 0-24 | ||||||||||||||||||||||||
| 197 | return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||||||||||||||
| 198 | Heap::InternalClass *ic = O->d()->internalClass; | - | ||||||||||||||||||||||||
| 199 | ScopedValue n(scope); | - | ||||||||||||||||||||||||
| 200 | ScopedArrayObject array(scope, scope.engine->newArrayObject()); | - | ||||||||||||||||||||||||
| 201 | for (uint i = 0; i < ic->size; ++i) {
| 24-60 | ||||||||||||||||||||||||
| 202 | PropertyKey id = ic->nameMap.at(i); | - | ||||||||||||||||||||||||
| 203 | n = id.asStringOrSymbol(); | - | ||||||||||||||||||||||||
| 204 | if (!n || !n->isSymbol())
| 0-60 | ||||||||||||||||||||||||
| 205 | continue; executed 28 times by 1 test: continue;Executed by:
| 28 | ||||||||||||||||||||||||
| 206 | array->push_back(n); | - | ||||||||||||||||||||||||
| 207 | } executed 32 times by 1 test: end of blockExecuted by:
| 32 | ||||||||||||||||||||||||
| 208 | return array->asReturnedValue(); executed 24 times by 1 test: return array->asReturnedValue();Executed by:
| 24 | ||||||||||||||||||||||||
| 209 | } | - | ||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | // 19.1.2.1 | - | ||||||||||||||||||||||||
| 212 | ReturnedValue ObjectPrototype::method_assign(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 213 | { | - | ||||||||||||||||||||||||
| 214 | Scope scope(b); | - | ||||||||||||||||||||||||
| 215 | if (argc < 1)
| 0-84 | ||||||||||||||||||||||||
| 216 | return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||
| 218 | ScopedObject to(scope, argv[0].toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 219 | if (scope.engine->hasException)
| 8-76 | ||||||||||||||||||||||||
| 220 | return QV4::Encode::undefined(); executed 8 times by 1 test: return QV4::Encode::undefined();Executed by:
| 8 | ||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | if (argc == 1)
| 4-72 | ||||||||||||||||||||||||
| 223 | return to.asReturnedValue(); executed 4 times by 1 test: return to.asReturnedValue();Executed by:
| 4 | ||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||
| 225 | for (int i = 1, ei = argc; i < ei; ++i) {
| 56-120 | ||||||||||||||||||||||||
| 226 | if (argv[i].isUndefined() || argv[i].isNull())
| 8-112 | ||||||||||||||||||||||||
| 227 | continue; executed 16 times by 1 test: continue;Executed by:
| 16 | ||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||
| 229 | ScopedObject from(scope, argv[i].toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 230 | if (scope.engine->hasException)
| 0-104 | ||||||||||||||||||||||||
| 231 | return QV4::Encode::undefined(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||||||||
| 232 | QV4::ScopedArrayObject keys(scope, QV4::ObjectPrototype::getOwnPropertyNames(scope.engine, from)); | - | ||||||||||||||||||||||||
| 233 | quint32 length = keys->getLength(); | - | ||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||
| 235 | ScopedString nextKey(scope); | - | ||||||||||||||||||||||||
| 236 | ScopedValue propValue(scope); | - | ||||||||||||||||||||||||
| 237 | for (quint32 i = 0; i < length; ++i) {
| 88-144 | ||||||||||||||||||||||||
| 238 | nextKey = Value::fromReturnedValue(keys->get(i)).toString(scope.engine); | - | ||||||||||||||||||||||||
| 239 | - | |||||||||||||||||||||||||
| 240 | ScopedProperty prop(scope); | - | ||||||||||||||||||||||||
| 241 | PropertyAttributes attrs = from->getOwnProperty(nextKey->toPropertyKey(), prop); | - | ||||||||||||||||||||||||
| 242 | - | |||||||||||||||||||||||||
| 243 | if (attrs == PropertyFlag::Attr_Invalid)
| 0-144 | ||||||||||||||||||||||||
| 244 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 245 | - | |||||||||||||||||||||||||
| 246 | if (!attrs.isEnumerable())
| 24-120 | ||||||||||||||||||||||||
| 247 | continue; executed 24 times by 1 test: continue;Executed by:
| 24 | ||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||
| 249 | propValue = from->get(nextKey); | - | ||||||||||||||||||||||||
| 250 | to->set(nextKey, propValue, Object::DoThrowOnRejection); | - | ||||||||||||||||||||||||
| 251 | if (scope.engine->hasException)
| 16-104 | ||||||||||||||||||||||||
| 252 | return QV4::Encode::undefined(); executed 16 times by 1 test: return QV4::Encode::undefined();Executed by:
| 16 | ||||||||||||||||||||||||
| 253 | } executed 104 times by 1 test: end of blockExecuted by:
| 104 | ||||||||||||||||||||||||
| 254 | } executed 88 times by 1 test: end of blockExecuted by:
| 88 | ||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 | return to.asReturnedValue(); executed 56 times by 1 test: return to.asReturnedValue();Executed by:
| 56 | ||||||||||||||||||||||||
| 257 | } | - | ||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||
| 259 | ReturnedValue ObjectPrototype::method_create(const FunctionObject *builtin, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 260 | { | - | ||||||||||||||||||||||||
| 261 | Scope scope(builtin); | - | ||||||||||||||||||||||||
| 262 | if (!argc || (!argv[0].isObject() && !argv[0].isNull()))
| 0-1587 | ||||||||||||||||||||||||
| 263 | return scope.engine->throwTypeError(); executed 16 times by 1 test: return scope.engine->throwTypeError();Executed by:
| 16 | ||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||
| 265 | ScopedObject O(scope, argv[0]); | - | ||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||
| 267 | ScopedObject newObject(scope, scope.engine->newObject()); | - | ||||||||||||||||||||||||
| 268 | newObject->setPrototypeOf(O); | - | ||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||
| 271 | if (argc > 1 && !argv[1].isUndefined()) {
| 4-1215 | ||||||||||||||||||||||||
| 272 | Value *arguments = scope.alloc(argc); | - | ||||||||||||||||||||||||
| 273 | arguments[0] = newObject; | - | ||||||||||||||||||||||||
| 274 | memcpy(arguments + 1, argv + 1, (argc - 1)*sizeof(Value)); | - | ||||||||||||||||||||||||
| 275 | return method_defineProperties(builtin, thisObject, arguments, argc); executed 1206 times by 1 test: return method_defineProperties(builtin, thisObject, arguments, argc);Executed by:
| 1206 | ||||||||||||||||||||||||
| 276 | } | - | ||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||
| 278 | return newObject.asReturnedValue(); executed 370 times by 2 tests: return newObject.asReturnedValue();Executed by:
| 370 | ||||||||||||||||||||||||
| 279 | } | - | ||||||||||||||||||||||||
| 280 | - | |||||||||||||||||||||||||
| 281 | ReturnedValue ObjectPrototype::method_defineProperty(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 282 | { | - | ||||||||||||||||||||||||
| 283 | Scope scope(b); | - | ||||||||||||||||||||||||
| 284 | if (!argc || !argv[0].isObject())
| 0-16110 | ||||||||||||||||||||||||
| 285 | return scope.engine->throwTypeError(); executed 20 times by 1 test: return scope.engine->throwTypeError();Executed by:
| 20 | ||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | ScopedObject O(scope, argv[0]); | - | ||||||||||||||||||||||||
| 288 | ScopedPropertyKey name(scope, (argc > 1 ? argv[1] : Primitive::undefinedValue()).toPropertyKey(scope.engine)); | - | ||||||||||||||||||||||||
| 289 | if (scope.engine->hasException)
| 4-16112 | ||||||||||||||||||||||||
| 290 | return QV4::Encode::undefined(); executed 4 times by 1 test: return QV4::Encode::undefined();Executed by:
| 4 | ||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||
| 292 | ScopedValue attributes(scope, argc > 2 ? argv[2] : Primitive::undefinedValue()); | - | ||||||||||||||||||||||||
| 293 | ScopedProperty pd(scope); | - | ||||||||||||||||||||||||
| 294 | PropertyAttributes attrs; | - | ||||||||||||||||||||||||
| 295 | toPropertyDescriptor(scope.engine, attributes, pd, &attrs); | - | ||||||||||||||||||||||||
| 296 | if (scope.engine->hasException)
| 76-16080 | ||||||||||||||||||||||||
| 297 | return QV4::Encode::undefined(); executed 76 times by 1 test: return QV4::Encode::undefined();Executed by:
| 76 | ||||||||||||||||||||||||
| 298 | - | |||||||||||||||||||||||||
| 299 | if (!O->defineOwnProperty(name, pd, attrs))
| 989-15073 | ||||||||||||||||||||||||
| 300 | THROW_TYPE_ERROR(); executed 989 times by 1 test: return scope.engine->throwTypeError();Executed by:
| 989 | ||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||
| 302 | return O.asReturnedValue(); executed 15058 times by 3 tests: return O.asReturnedValue();Executed by:
| 15058 | ||||||||||||||||||||||||
| 303 | } | - | ||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||
| 305 | ReturnedValue ObjectPrototype::method_defineProperties(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 306 | { | - | ||||||||||||||||||||||||
| 307 | Scope scope(b); | - | ||||||||||||||||||||||||
| 308 | if (argc < 2 || !argv[0].isObject())
| 0-3680 | ||||||||||||||||||||||||
| 309 | return scope.engine->throwTypeError(); executed 20 times by 1 test: return scope.engine->throwTypeError();Executed by:
| 20 | ||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||
| 311 | ScopedObject O(scope, argv[0]); | - | ||||||||||||||||||||||||
| 312 | - | |||||||||||||||||||||||||
| 313 | ScopedObject o(scope, argv[1].toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 314 | if (scope.engine->hasException)
| 12-3644 | ||||||||||||||||||||||||
| 315 | return QV4::Encode::undefined(); executed 12 times by 1 test: return QV4::Encode::undefined();Executed by:
| 12 | ||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||
| 317 | ScopedValue val(scope); | - | ||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||
| 319 | ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly); | - | ||||||||||||||||||||||||
| 320 | ScopedStringOrSymbol name(scope); | - | ||||||||||||||||||||||||
| 321 | ScopedProperty pd(scope); | - | ||||||||||||||||||||||||
| 322 | ScopedProperty n(scope); | - | ||||||||||||||||||||||||
| 323 | while (1) { | - | ||||||||||||||||||||||||
| 324 | uint index; | - | ||||||||||||||||||||||||
| 325 | PropertyAttributes attrs; | - | ||||||||||||||||||||||||
| 326 | it.next(name.getRef(), &index, pd, &attrs); | - | ||||||||||||||||||||||||
| 327 | if (attrs.isEmpty())
| 2952-3688 | ||||||||||||||||||||||||
| 328 | break; executed 2953 times by 1 test: break;Executed by:
| 2953 | ||||||||||||||||||||||||
| 329 | PropertyAttributes nattrs; | - | ||||||||||||||||||||||||
| 330 | val = o->getValue(pd->value, attrs); | - | ||||||||||||||||||||||||
| 331 | toPropertyDescriptor(scope.engine, val, n, &nattrs); | - | ||||||||||||||||||||||||
| 332 | if (scope.engine->hasException)
| 169-3528 | ||||||||||||||||||||||||
| 333 | return QV4::Encode::undefined(); executed 167 times by 1 test: return QV4::Encode::undefined();Executed by:
| 167 | ||||||||||||||||||||||||
| 334 | bool ok; | - | ||||||||||||||||||||||||
| 335 | if (name)
| 466-3055 | ||||||||||||||||||||||||
| 336 | ok = O->defineOwnProperty(name->toPropertyKey(), n, nattrs); executed 3054 times by 1 test: ok = O->defineOwnProperty(name->toPropertyKey(), n, nattrs);Executed by:
| 3054 | ||||||||||||||||||||||||
| 337 | else | - | ||||||||||||||||||||||||
| 338 | ok = O->defineOwnProperty(PropertyKey::fromArrayIndex(index), n, nattrs); executed 466 times by 1 test: ok = O->defineOwnProperty(PropertyKey::fromArrayIndex(index), n, nattrs);Executed by:
| 466 | ||||||||||||||||||||||||
| 339 | if (!ok)
| 531-2992 | ||||||||||||||||||||||||
| 340 | THROW_TYPE_ERROR(); executed 531 times by 1 test: return scope.engine->throwTypeError();Executed by:
| 531 | ||||||||||||||||||||||||
| 341 | } executed 2993 times by 1 test: end of blockExecuted by:
| 2993 | ||||||||||||||||||||||||
| 342 | - | |||||||||||||||||||||||||
| 343 | return O.asReturnedValue(); executed 2939 times by 1 test: return O.asReturnedValue();Executed by:
| 2939 | ||||||||||||||||||||||||
| 344 | } | - | ||||||||||||||||||||||||
| 345 | - | |||||||||||||||||||||||||
| 346 | ReturnedValue ObjectPrototype::method_seal(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 347 | { | - | ||||||||||||||||||||||||
| 348 | const Value a = argc ? argv[0] : Primitive::undefinedValue();
| 0-173 | ||||||||||||||||||||||||
| 349 | if (!a.isObject())
| 20-154 | ||||||||||||||||||||||||
| 350 | // 19.1.2.17, 1 | - | ||||||||||||||||||||||||
| 351 | return a.asReturnedValue(); executed 20 times by 1 test: return a.asReturnedValue();Executed by:
| 20 | ||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||
| 353 | Scope scope(b); | - | ||||||||||||||||||||||||
| 354 | ScopedObject o(scope, a); | - | ||||||||||||||||||||||||
| 355 | o->setInternalClass(o->internalClass()->sealed()); | - | ||||||||||||||||||||||||
| 356 | - | |||||||||||||||||||||||||
| 357 | if (o->arrayData()) {
| 8-148 | ||||||||||||||||||||||||
| 358 | ArrayData::ensureAttributes(o); | - | ||||||||||||||||||||||||
| 359 | for (uint i = 0; i < o->d()->arrayData->values.alloc; ++i) {
| 8-64 | ||||||||||||||||||||||||
| 360 | if (!o->arrayData()->isEmpty(i))
| 8-56 | ||||||||||||||||||||||||
| 361 | o->d()->arrayData->attrs[i].setConfigurable(false); executed 8 times by 1 test: o->d()->arrayData->attrs[i].setConfigurable(false);Executed by:
| 8 | ||||||||||||||||||||||||
| 362 | } executed 64 times by 1 test: end of blockExecuted by:
| 64 | ||||||||||||||||||||||||
| 363 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | return o.asReturnedValue(); executed 155 times by 1 test: return o.asReturnedValue();Executed by:
| 155 | ||||||||||||||||||||||||
| 366 | } | - | ||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||
| 368 | ReturnedValue ObjectPrototype::method_freeze(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 369 | { | - | ||||||||||||||||||||||||
| 370 | const Value a = argc ? argv[0] : Primitive::undefinedValue();
| 0-236 | ||||||||||||||||||||||||
| 371 | if (!a.isObject())
| 24-212 | ||||||||||||||||||||||||
| 372 | // 19.1.2.5, 1 | - | ||||||||||||||||||||||||
| 373 | return a.asReturnedValue(); executed 24 times by 1 test: return a.asReturnedValue();Executed by:
| 24 | ||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||
| 375 | Scope scope(b); | - | ||||||||||||||||||||||||
| 376 | ScopedObject o(scope, a); | - | ||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||
| 378 | if (ArgumentsObject::isNonStrictArgumentsObject(o))
| 6-206 | ||||||||||||||||||||||||
| 379 | static_cast<ArgumentsObject *>(o.getPointer())->fullyCreate(); executed 6 times by 1 test: static_cast<ArgumentsObject *>(o.getPointer())->fullyCreate();Executed by:
| 6 | ||||||||||||||||||||||||
| 380 | - | |||||||||||||||||||||||||
| 381 | o->setInternalClass(o->internalClass()->frozen()); | - | ||||||||||||||||||||||||
| 382 | - | |||||||||||||||||||||||||
| 383 | if (o->arrayData()) {
| 36-176 | ||||||||||||||||||||||||
| 384 | ArrayData::ensureAttributes(o); | - | ||||||||||||||||||||||||
| 385 | for (uint i = 0; i < o->arrayData()->values.alloc; ++i) {
| 36-4352 | ||||||||||||||||||||||||
| 386 | if (!o->arrayData()->isEmpty(i))
| 72-4280 | ||||||||||||||||||||||||
| 387 | o->arrayData()->attrs[i].setConfigurable(false); executed 72 times by 1 test: o->arrayData()->attrs[i].setConfigurable(false);Executed by:
| 72 | ||||||||||||||||||||||||
| 388 | if (o->arrayData()->attrs[i].isData())
| 264-4088 | ||||||||||||||||||||||||
| 389 | o->arrayData()->attrs[i].setWritable(false); executed 4088 times by 1 test: o->arrayData()->attrs[i].setWritable(false);Executed by:
| 4088 | ||||||||||||||||||||||||
| 390 | } executed 4352 times by 1 test: end of blockExecuted by:
| 4352 | ||||||||||||||||||||||||
| 391 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||||||||||||||||||||
| 392 | return o.asReturnedValue(); executed 212 times by 2 tests: return o.asReturnedValue();Executed by:
| 212 | ||||||||||||||||||||||||
| 393 | } | - | ||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | ReturnedValue ObjectPrototype::method_preventExtensions(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 396 | { | - | ||||||||||||||||||||||||
| 397 | Scope scope(b); | - | ||||||||||||||||||||||||
| 398 | if (!argc)
| 0-863 | ||||||||||||||||||||||||
| 399 | return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 400 | - | |||||||||||||||||||||||||
| 401 | ScopedObject o(scope, argv[0].toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 402 | if (!o)
| 8-856 | ||||||||||||||||||||||||
| 403 | return argv[0].asReturnedValue(); executed 8 times by 1 test: return argv[0].asReturnedValue();Executed by:
| 8 | ||||||||||||||||||||||||
| 404 | - | |||||||||||||||||||||||||
| 405 | o->preventExtensions(); | - | ||||||||||||||||||||||||
| 406 | return o.asReturnedValue(); executed 855 times by 1 test: return o.asReturnedValue();Executed by:
| 855 | ||||||||||||||||||||||||
| 407 | } | - | ||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||
| 409 | ReturnedValue ObjectPrototype::method_isSealed(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 410 | { | - | ||||||||||||||||||||||||
| 411 | Scope scope(b); | - | ||||||||||||||||||||||||
| 412 | if (!argc)
| 0-163 | ||||||||||||||||||||||||
| 413 | return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 414 | - | |||||||||||||||||||||||||
| 415 | ScopedObject o(scope, argv[0].toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 416 | if (!o)
| 0-162 | ||||||||||||||||||||||||
| 417 | return Encode(true); never executed: return Encode(true); | 0 | ||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||
| 419 | if (o->isExtensible())
| 48-116 | ||||||||||||||||||||||||
| 420 | return Encode(false); executed 115 times by 1 test: return Encode(false);Executed by:
| 115 | ||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | if (o->internalClass() != o->internalClass()->sealed())
| 0-48 | ||||||||||||||||||||||||
| 423 | return Encode(false); never executed: return Encode(false); | 0 | ||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||
| 425 | if (!o->arrayData() || !o->arrayData()->length())
| 2-42 | ||||||||||||||||||||||||
| 426 | return Encode(true); executed 44 times by 1 test: return Encode(true);Executed by:
| 44 | ||||||||||||||||||||||||
| 427 | - | |||||||||||||||||||||||||
| 428 | Q_ASSERT(o->arrayData() && o->arrayData()->length()); | - | ||||||||||||||||||||||||
| 429 | if (!o->arrayData()->attrs)
| 0-4 | ||||||||||||||||||||||||
| 430 | return Encode(false); never executed: return Encode(false); | 0 | ||||||||||||||||||||||||
| 431 | - | |||||||||||||||||||||||||
| 432 | for (uint i = 0; i < o->arrayData()->values.alloc; ++i) {
| 4-32 | ||||||||||||||||||||||||
| 433 | if (!o->arrayData()->isEmpty(i))
| 8-24 | ||||||||||||||||||||||||
| 434 | if (o->arrayData()->attributes(i).isConfigurable())
| 0-8 | ||||||||||||||||||||||||
| 435 | return Encode(false); never executed: return Encode(false); | 0 | ||||||||||||||||||||||||
| 436 | } executed 32 times by 1 test: end of blockExecuted by:
| 32 | ||||||||||||||||||||||||
| 437 | - | |||||||||||||||||||||||||
| 438 | return Encode(true); executed 4 times by 1 test: return Encode(true);Executed by:
| 4 | ||||||||||||||||||||||||
| 439 | } | - | ||||||||||||||||||||||||
| 440 | - | |||||||||||||||||||||||||
| 441 | ReturnedValue ObjectPrototype::method_isFrozen(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 442 | { | - | ||||||||||||||||||||||||
| 443 | Scope scope(b); | - | ||||||||||||||||||||||||
| 444 | if (!argc)
| 0-272 | ||||||||||||||||||||||||
| 445 | return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 446 | - | |||||||||||||||||||||||||
| 447 | ScopedObject o(scope, argv[0].toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 448 | if (!o)
| 8-263 | ||||||||||||||||||||||||
| 449 | return Encode(true); executed 8 times by 1 test: return Encode(true);Executed by:
| 8 | ||||||||||||||||||||||||
| 450 | - | |||||||||||||||||||||||||
| 451 | if (o->isExtensible())
| 127-136 | ||||||||||||||||||||||||
| 452 | return Encode(false); executed 127 times by 1 test: return Encode(false);Executed by:
| 127 | ||||||||||||||||||||||||
| 453 | - | |||||||||||||||||||||||||
| 454 | if (o->internalClass() != o->internalClass()->frozen())
| 60-76 | ||||||||||||||||||||||||
| 455 | return Encode(false); executed 60 times by 1 test: return Encode(false);Executed by:
| 60 | ||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||
| 457 | if (!o->arrayData() || !o->arrayData()->length())
| 4-56 | ||||||||||||||||||||||||
| 458 | return Encode(true); executed 60 times by 1 test: return Encode(true);Executed by:
| 60 | ||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||
| 460 | Q_ASSERT(o->arrayData() && o->arrayData()->length()); | - | ||||||||||||||||||||||||
| 461 | if (!o->arrayData()->attrs)
| 0-16 | ||||||||||||||||||||||||
| 462 | return Encode(false); never executed: return Encode(false); | 0 | ||||||||||||||||||||||||
| 463 | - | |||||||||||||||||||||||||
| 464 | for (uint i = 0; i < o->arrayData()->values.alloc; ++i) {
| 16-4192 | ||||||||||||||||||||||||
| 465 | if (!o->arrayData()->isEmpty(i))
| 40-4152 | ||||||||||||||||||||||||
| 466 | if (o->arrayData()->attributes(i).isConfigurable() || o->arrayData()->attributes(i).isWritable())
| 0-40 | ||||||||||||||||||||||||
| 467 | return Encode(false); never executed: return Encode(false); | 0 | ||||||||||||||||||||||||
| 468 | } executed 4192 times by 1 test: end of blockExecuted by:
| 4192 | ||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||
| 470 | return Encode(true); executed 16 times by 1 test: return Encode(true);Executed by:
| 16 | ||||||||||||||||||||||||
| 471 | } | - | ||||||||||||||||||||||||
| 472 | - | |||||||||||||||||||||||||
| 473 | ReturnedValue ObjectPrototype::method_isExtensible(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 474 | { | - | ||||||||||||||||||||||||
| 475 | Scope scope(b); | - | ||||||||||||||||||||||||
| 476 | if (!argc)
| 0-844 | ||||||||||||||||||||||||
| 477 | return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||
| 479 | ScopedObject o(scope, argv[0].toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 480 | if (!o)
| 8-837 | ||||||||||||||||||||||||
| 481 | return Encode(false); executed 8 times by 1 test: return Encode(false);Executed by:
| 8 | ||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||
| 483 | return Encode((bool)o->isExtensible()); executed 835 times by 1 test: return Encode((bool)o->isExtensible());Executed by:
| 835 | ||||||||||||||||||||||||
| 484 | } | - | ||||||||||||||||||||||||
| 485 | - | |||||||||||||||||||||||||
| 486 | ReturnedValue ObjectPrototype::method_keys(const FunctionObject *b, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 487 | { | - | ||||||||||||||||||||||||
| 488 | Scope scope(b); | - | ||||||||||||||||||||||||
| 489 | if (!argc)
| 0-378 | ||||||||||||||||||||||||
| 490 | return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||
| 492 | ScopedObject o(scope, argv[0].toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 493 | if (scope.engine->hasException)
| 8-371 | ||||||||||||||||||||||||
| 494 | return QV4::Encode::undefined(); executed 6 times by 1 test: return QV4::Encode::undefined();Executed by:
| 6 | ||||||||||||||||||||||||
| 495 | - | |||||||||||||||||||||||||
| 496 | ScopedArrayObject a(scope, scope.engine->newArrayObject()); | - | ||||||||||||||||||||||||
| 497 | - | |||||||||||||||||||||||||
| 498 | ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly); | - | ||||||||||||||||||||||||
| 499 | ScopedValue name(scope); | - | ||||||||||||||||||||||||
| 500 | while (1) { | - | ||||||||||||||||||||||||
| 501 | name = it.nextPropertyNameAsString(); | - | ||||||||||||||||||||||||
| 502 | if (name->isNull())
| 372-636 | ||||||||||||||||||||||||
| 503 | break; executed 372 times by 1 test: break;Executed by:
| 372 | ||||||||||||||||||||||||
| 504 | a->push_back(name); | - | ||||||||||||||||||||||||
| 505 | } executed 633 times by 1 test: end of blockExecuted by:
| 633 | ||||||||||||||||||||||||
| 506 | - | |||||||||||||||||||||||||
| 507 | return a.asReturnedValue(); executed 372 times by 1 test: return a.asReturnedValue();Executed by:
| 372 | ||||||||||||||||||||||||
| 508 | } | - | ||||||||||||||||||||||||
| 509 | - | |||||||||||||||||||||||||
| 510 | ReturnedValue ObjectPrototype::method_setPrototypeOf(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 511 | { | - | ||||||||||||||||||||||||
| 512 | Scope scope(f->engine()); | - | ||||||||||||||||||||||||
| 513 | if (argc < 2 || argv[0].isNullOrUndefined() || !(argv[1].isObject() || argv[1].isNull()))
| 0-264 | ||||||||||||||||||||||||
| 514 | return scope.engine->throwTypeError(); executed 32 times by 1 test: return scope.engine->throwTypeError();Executed by:
| 32 | ||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||
| 516 | if (!argv[0].isObject())
| 16-228 | ||||||||||||||||||||||||
| 517 | return argv[0].asReturnedValue(); executed 16 times by 1 test: return argv[0].asReturnedValue();Executed by:
| 16 | ||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||
| 519 | ScopedObject o(scope, argv[0]); | - | ||||||||||||||||||||||||
| 520 | const Object *p = argv[1].isNull() ? nullptr : static_cast<const Object *>(argv + 1);
| 20-208 | ||||||||||||||||||||||||
| 521 | bool ok = o->setPrototypeOf(p); | - | ||||||||||||||||||||||||
| 522 | if (!ok)
| 48-180 | ||||||||||||||||||||||||
| 523 | return scope.engine->throwTypeError(QStringLiteral("Could not change prototype.")); executed 48 times by 1 test: return scope.engine->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Could not change prototype.")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Could not change prototype." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));Executed by:
executed 48 times by 1 test: return qstring_literal_temp;Executed by:
| 48 | ||||||||||||||||||||||||
| 524 | return o->asReturnedValue(); executed 180 times by 1 test: return o->asReturnedValue();Executed by:
| 180 | ||||||||||||||||||||||||
| 525 | } | - | ||||||||||||||||||||||||
| 526 | - | |||||||||||||||||||||||||
| 527 | ReturnedValue ObjectPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||||||||
| 528 | { | - | ||||||||||||||||||||||||
| 529 | ExecutionEngine *v4 = b->engine(); | - | ||||||||||||||||||||||||
| 530 | QString string; | - | ||||||||||||||||||||||||
| 531 | if (thisObject->isUndefined()) {
| 12-4722 | ||||||||||||||||||||||||
| 532 | string = QStringLiteral("[object Undefined]"); | - | ||||||||||||||||||||||||
| 533 | } else if (thisObject->isNull()) { executed 12 times by 1 test: end of blockExecuted by:
| 4-4727 | ||||||||||||||||||||||||
| 534 | string = QStringLiteral("[object Null]"); | - | ||||||||||||||||||||||||
| 535 | } else { executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 536 | const Object *o = thisObject->as<Object>(); | - | ||||||||||||||||||||||||
| 537 | if (!o) {
| 36-4679 | ||||||||||||||||||||||||
| 538 | // primitive, get the proper prototype | - | ||||||||||||||||||||||||
| 539 | if (thisObject->isBoolean())
| 12-24 | ||||||||||||||||||||||||
| 540 | o = v4->booleanPrototype(); executed 12 times by 1 test: o = v4->booleanPrototype();Executed by:
| 12 | ||||||||||||||||||||||||
| 541 | else if (thisObject->isNumber())
| 12 | ||||||||||||||||||||||||
| 542 | o = v4->numberPrototype(); executed 12 times by 1 test: o = v4->numberPrototype();Executed by:
| 12 | ||||||||||||||||||||||||
| 543 | else if (thisObject->isString())
| 0-12 | ||||||||||||||||||||||||
| 544 | o = v4->stringPrototype(); executed 12 times by 1 test: o = v4->stringPrototype();Executed by:
| 12 | ||||||||||||||||||||||||
| 545 | else if (thisObject->isSymbol())
| 0 | ||||||||||||||||||||||||
| 546 | o = v4->symbolPrototype(); never executed: o = v4->symbolPrototype(); | 0 | ||||||||||||||||||||||||
| 547 | Q_ASSERT(o); | - | ||||||||||||||||||||||||
| 548 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||||||||||||||||||||
| 549 | QString name = o->className(); | - | ||||||||||||||||||||||||
| 550 | Scope scope(v4); | - | ||||||||||||||||||||||||
| 551 | ScopedString toStringTag(scope, o->get(v4->symbol_toStringTag())); | - | ||||||||||||||||||||||||
| 552 | if (toStringTag)
| 1836-2871 | ||||||||||||||||||||||||
| 553 | name = toStringTag->toQString(); executed 1837 times by 1 test: name = toStringTag->toQString();Executed by:
| 1837 | ||||||||||||||||||||||||
| 554 | string = QStringLiteral("[object %1]").arg(name); | - | ||||||||||||||||||||||||
| 555 | } executed 4709 times by 5 tests: end of blockExecuted by:
| 4709 | ||||||||||||||||||||||||
| 556 | return Encode(v4->newString(string)); executed 4747 times by 5 tests: return Encode(v4->newString(string));Executed by:
| 4747 | ||||||||||||||||||||||||
| 557 | } | - | ||||||||||||||||||||||||
| 558 | - | |||||||||||||||||||||||||
| 559 | ReturnedValue ObjectPrototype::method_toLocaleString(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 560 | { | - | ||||||||||||||||||||||||
| 561 | Scope scope(b); | - | ||||||||||||||||||||||||
| 562 | ScopedObject o(scope, thisObject->toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 563 | if (!o)
| 20-144 | ||||||||||||||||||||||||
| 564 | RETURN_UNDEFINED(); executed 20 times by 1 test: return QV4::Encode::undefined();Executed by:
| 20 | ||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||
| 566 | ScopedFunctionObject f(scope, o->get(scope.engine->id_toString())); | - | ||||||||||||||||||||||||
| 567 | if (!f)
| 0-144 | ||||||||||||||||||||||||
| 568 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 569 | - | |||||||||||||||||||||||||
| 570 | return f->call(thisObject, argv, argc); executed 144 times by 1 test: return f->call(thisObject, argv, argc);Executed by:
| 144 | ||||||||||||||||||||||||
| 571 | } | - | ||||||||||||||||||||||||
| 572 | - | |||||||||||||||||||||||||
| 573 | ReturnedValue ObjectPrototype::method_valueOf(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||||||||
| 574 | { | - | ||||||||||||||||||||||||
| 575 | return Encode(thisObject->toObject(b->engine())); executed 4505 times by 6 tests: return Encode(thisObject->toObject(b->engine()));Executed by:
| 4505 | ||||||||||||||||||||||||
| 576 | } | - | ||||||||||||||||||||||||
| 577 | - | |||||||||||||||||||||||||
| 578 | ReturnedValue ObjectPrototype::method_hasOwnProperty(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 579 | { | - | ||||||||||||||||||||||||
| 580 | Scope scope(b); | - | ||||||||||||||||||||||||
| 581 | ScopedPropertyKey P(scope, (argc ? argv[0] : Primitive::undefinedValue()).toPropertyKey(scope.engine)); | - | ||||||||||||||||||||||||
| 582 | if (scope.engine->hasException)
| 0-26800 | ||||||||||||||||||||||||
| 583 | return QV4::Encode::undefined(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||||||||
| 584 | ScopedObject O(scope, thisObject->toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 585 | if (scope.engine->hasException)
| 8-26861 | ||||||||||||||||||||||||
| 586 | return QV4::Encode::undefined(); executed 8 times by 1 test: return QV4::Encode::undefined();Executed by:
| 8 | ||||||||||||||||||||||||
| 587 | bool r = O->getOwnProperty(P) != Attr_Invalid; | - | ||||||||||||||||||||||||
| 588 | return Encode(r); executed 26890 times by 5 tests: return Encode(r);Executed by:
| 26890 | ||||||||||||||||||||||||
| 589 | } | - | ||||||||||||||||||||||||
| 590 | - | |||||||||||||||||||||||||
| 591 | ReturnedValue ObjectPrototype::method_isPrototypeOf(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 592 | { | - | ||||||||||||||||||||||||
| 593 | Scope scope(b); | - | ||||||||||||||||||||||||
| 594 | if (!argc || !argv[0].isObject())
| 0-546 | ||||||||||||||||||||||||
| 595 | return Encode(false); never executed: return Encode(false); | 0 | ||||||||||||||||||||||||
| 596 | - | |||||||||||||||||||||||||
| 597 | ScopedObject V(scope, argv[0]); | - | ||||||||||||||||||||||||
| 598 | ScopedObject O(scope, thisObject->toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 599 | if (scope.engine->hasException)
| 8-539 | ||||||||||||||||||||||||
| 600 | return QV4::Encode::undefined(); executed 8 times by 1 test: return QV4::Encode::undefined();Executed by:
| 8 | ||||||||||||||||||||||||
| 601 | ScopedObject proto(scope, V->getPrototypeOf()); | - | ||||||||||||||||||||||||
| 602 | while (proto) {
| 12-568 | ||||||||||||||||||||||||
| 603 | if (O->d() == proto->d())
| 40-528 | ||||||||||||||||||||||||
| 604 | return Encode(true); executed 527 times by 1 test: return Encode(true);Executed by:
| 527 | ||||||||||||||||||||||||
| 605 | proto = proto->getPrototypeOf(); | - | ||||||||||||||||||||||||
| 606 | } executed 40 times by 1 test: end of blockExecuted by:
| 40 | ||||||||||||||||||||||||
| 607 | return Encode(false); executed 12 times by 1 test: return Encode(false);Executed by:
| 12 | ||||||||||||||||||||||||
| 608 | } | - | ||||||||||||||||||||||||
| 609 | - | |||||||||||||||||||||||||
| 610 | ReturnedValue ObjectPrototype::method_propertyIsEnumerable(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 611 | { | - | ||||||||||||||||||||||||
| 612 | Scope scope(b); | - | ||||||||||||||||||||||||
| 613 | ScopedPropertyKey p(scope, (argc ? argv[0] : Primitive::undefinedValue()).toPropertyKey(scope.engine)); | - | ||||||||||||||||||||||||
| 614 | if (scope.engine->hasException)
| 0-1661 | ||||||||||||||||||||||||
| 615 | return QV4::Encode::undefined(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||||||||
| 616 | - | |||||||||||||||||||||||||
| 617 | ScopedObject o(scope, thisObject->toObject(scope.engine)); | - | ||||||||||||||||||||||||
| 618 | if (scope.engine->hasException)
| 8-1657 | ||||||||||||||||||||||||
| 619 | return QV4::Encode::undefined(); executed 8 times by 1 test: return QV4::Encode::undefined();Executed by:
| 8 | ||||||||||||||||||||||||
| 620 | PropertyAttributes attrs = o->getOwnProperty(p); | - | ||||||||||||||||||||||||
| 621 | return Encode(attrs.isEnumerable()); executed 1659 times by 1 test: return Encode(attrs.isEnumerable());Executed by:
| 1659 | ||||||||||||||||||||||||
| 622 | } | - | ||||||||||||||||||||||||
| 623 | - | |||||||||||||||||||||||||
| 624 | ReturnedValue ObjectPrototype::method_defineGetter(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 625 | { | - | ||||||||||||||||||||||||
| 626 | Scope scope(b); | - | ||||||||||||||||||||||||
| 627 | if (argc < 2)
| 0-8 | ||||||||||||||||||||||||
| 628 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 629 | - | |||||||||||||||||||||||||
| 630 | ScopedFunctionObject f(scope, argv[1]); | - | ||||||||||||||||||||||||
| 631 | if (!f)
| 0-8 | ||||||||||||||||||||||||
| 632 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 633 | - | |||||||||||||||||||||||||
| 634 | ScopedString prop(scope, argv[0], ScopedString::Convert); | - | ||||||||||||||||||||||||
| 635 | if (scope.engine->hasException)
| 0-8 | ||||||||||||||||||||||||
| 636 | return QV4::Encode::undefined(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||||||||
| 637 | - | |||||||||||||||||||||||||
| 638 | ScopedObject o(scope, thisObject); | - | ||||||||||||||||||||||||
| 639 | if (!o) {
| 2-6 | ||||||||||||||||||||||||
| 640 | if (!thisObject->isUndefined())
| 0-2 | ||||||||||||||||||||||||
| 641 | RETURN_UNDEFINED(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||||||||
| 642 | o = scope.engine->globalObject; | - | ||||||||||||||||||||||||
| 643 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 644 | - | |||||||||||||||||||||||||
| 645 | ScopedProperty pd(scope); | - | ||||||||||||||||||||||||
| 646 | pd->value = f; | - | ||||||||||||||||||||||||
| 647 | pd->set = Primitive::emptyValue(); | - | ||||||||||||||||||||||||
| 648 | bool ok = o->defineOwnProperty(prop->toPropertyKey(), pd, Attr_Accessor); | - | ||||||||||||||||||||||||
| 649 | if (!ok)
| 0-8 | ||||||||||||||||||||||||
| 650 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 651 | RETURN_UNDEFINED(); executed 8 times by 2 tests: return QV4::Encode::undefined();Executed by:
| 8 | ||||||||||||||||||||||||
| 652 | } | - | ||||||||||||||||||||||||
| 653 | - | |||||||||||||||||||||||||
| 654 | ReturnedValue ObjectPrototype::method_defineSetter(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 655 | { | - | ||||||||||||||||||||||||
| 656 | Scope scope(b); | - | ||||||||||||||||||||||||
| 657 | if (argc < 2)
| 0-8 | ||||||||||||||||||||||||
| 658 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 659 | - | |||||||||||||||||||||||||
| 660 | ScopedFunctionObject f(scope, argv[1]); | - | ||||||||||||||||||||||||
| 661 | if (!f)
| 0-8 | ||||||||||||||||||||||||
| 662 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 663 | - | |||||||||||||||||||||||||
| 664 | ScopedString prop(scope, argv[0], ScopedString::Convert); | - | ||||||||||||||||||||||||
| 665 | if (scope.engine->hasException)
| 0-8 | ||||||||||||||||||||||||
| 666 | return QV4::Encode::undefined(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||||||||
| 667 | - | |||||||||||||||||||||||||
| 668 | ScopedObject o(scope, thisObject); | - | ||||||||||||||||||||||||
| 669 | if (!o) {
| 2-6 | ||||||||||||||||||||||||
| 670 | if (!thisObject->isUndefined())
| 0-2 | ||||||||||||||||||||||||
| 671 | RETURN_UNDEFINED(); never executed: return QV4::Encode::undefined(); | 0 | ||||||||||||||||||||||||
| 672 | o = scope.engine->globalObject; | - | ||||||||||||||||||||||||
| 673 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 674 | - | |||||||||||||||||||||||||
| 675 | ScopedProperty pd(scope); | - | ||||||||||||||||||||||||
| 676 | pd->value = Primitive::emptyValue(); | - | ||||||||||||||||||||||||
| 677 | pd->set = f; | - | ||||||||||||||||||||||||
| 678 | bool ok = o->defineOwnProperty(prop->toPropertyKey(), pd, Attr_Accessor); | - | ||||||||||||||||||||||||
| 679 | if (!ok)
| 0-8 | ||||||||||||||||||||||||
| 680 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 681 | RETURN_UNDEFINED(); executed 8 times by 2 tests: return QV4::Encode::undefined();Executed by:
| 8 | ||||||||||||||||||||||||
| 682 | } | - | ||||||||||||||||||||||||
| 683 | - | |||||||||||||||||||||||||
| 684 | ReturnedValue ObjectPrototype::method_get_proto(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||||||||||||||
| 685 | { | - | ||||||||||||||||||||||||
| 686 | Scope scope(b); | - | ||||||||||||||||||||||||
| 687 | ScopedObject o(scope, thisObject->as<Object>()); | - | ||||||||||||||||||||||||
| 688 | if (!o)
| 0-2 | ||||||||||||||||||||||||
| 689 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 690 | - | |||||||||||||||||||||||||
| 691 | return Encode(o->getPrototypeOf()); executed 2 times by 1 test: return Encode(o->getPrototypeOf());Executed by:
| 2 | ||||||||||||||||||||||||
| 692 | } | - | ||||||||||||||||||||||||
| 693 | - | |||||||||||||||||||||||||
| 694 | ReturnedValue ObjectPrototype::method_set_proto(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
| 695 | { | - | ||||||||||||||||||||||||
| 696 | Scope scope(b); | - | ||||||||||||||||||||||||
| 697 | ScopedObject o(scope, thisObject); | - | ||||||||||||||||||||||||
| 698 | if (!o || !argc || (!argv[0].isObject() && !argv[0].isNull()))
| 0-46 | ||||||||||||||||||||||||
| 699 | THROW_TYPE_ERROR(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||
| 701 | const Object *p = argv[0].isNull() ? nullptr : static_cast<const Object *>(argv);
| 0-46 | ||||||||||||||||||||||||
| 702 | bool ok = o->setPrototypeOf(p); | - | ||||||||||||||||||||||||
| 703 | if (!ok)
| 6-40 | ||||||||||||||||||||||||
| 704 | return scope.engine->throwTypeError(QStringLiteral("Could not change prototype.")); executed 6 times by 2 tests: return scope.engine->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Could not change prototype.")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Could not change prototype." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));Executed by:
executed 6 times by 2 tests: return qstring_literal_temp;Executed by:
| 6 | ||||||||||||||||||||||||
| 705 | return Encode::undefined(); executed 40 times by 3 tests: return Encode::undefined();Executed by:
| 40 | ||||||||||||||||||||||||
| 706 | RETURN_UNDEFINED(); dead code: return QV4::Encode::undefined(); | - | ||||||||||||||||||||||||
| 707 | } | - | ||||||||||||||||||||||||
| 708 | - | |||||||||||||||||||||||||
| 709 | void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value &v, Property *desc, PropertyAttributes *attrs) | - | ||||||||||||||||||||||||
| 710 | { | - | ||||||||||||||||||||||||
| 711 | Scope scope(engine); | - | ||||||||||||||||||||||||
| 712 | ScopedObject o(scope, v); | - | ||||||||||||||||||||||||
| 713 | if (!o) {
| 74-20786 | ||||||||||||||||||||||||
| 714 | engine->throwTypeError(); | - | ||||||||||||||||||||||||
| 715 | return; executed 75 times by 1 test: return;Executed by:
| 75 | ||||||||||||||||||||||||
| 716 | } | - | ||||||||||||||||||||||||
| 717 | - | |||||||||||||||||||||||||
| 718 | attrs->clear(); | - | ||||||||||||||||||||||||
| 719 | desc->value = Primitive::emptyValue(); | - | ||||||||||||||||||||||||
| 720 | desc->set = Primitive::emptyValue(); | - | ||||||||||||||||||||||||
| 721 | ScopedValue tmp(scope); | - | ||||||||||||||||||||||||
| 722 | - | |||||||||||||||||||||||||
| 723 | if (o->hasProperty(engine->id_enumerable()->toPropertyKey()))
| 4506-16350 | ||||||||||||||||||||||||
| 724 | attrs->setEnumerable((tmp = o->get(engine->id_enumerable()))->toBoolean()); executed 4490 times by 2 tests: attrs->setEnumerable((tmp = o->get(engine->id_enumerable()))->toBoolean());Executed by:
| 4490 | ||||||||||||||||||||||||
| 725 | - | |||||||||||||||||||||||||
| 726 | if (o->hasProperty(engine->id_configurable()->toPropertyKey()))
| 9280-11586 | ||||||||||||||||||||||||
| 727 | attrs->setConfigurable((tmp = o->get(engine->id_configurable()))->toBoolean()); executed 9255 times by 1 test: attrs->setConfigurable((tmp = o->get(engine->id_configurable()))->toBoolean());Executed by:
| 9255 | ||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||
| 729 | if (o->hasProperty(engine->id_get()->toPropertyKey())) {
| 9628-11248 | ||||||||||||||||||||||||
| 730 | ScopedValue get(scope, o->get(engine->id_get())); | - | ||||||||||||||||||||||||
| 731 | FunctionObject *f = get->as<FunctionObject>(); | - | ||||||||||||||||||||||||
| 732 | if (f || get->isUndefined()) {
| 59-9067 | ||||||||||||||||||||||||
| 733 | desc->value = get; | - | ||||||||||||||||||||||||
| 734 | } else { executed 9520 times by 2 tests: end of blockExecuted by:
| 9520 | ||||||||||||||||||||||||
| 735 | engine->throwTypeError(); | - | ||||||||||||||||||||||||
| 736 | return; executed 59 times by 1 test: return;Executed by:
| 59 | ||||||||||||||||||||||||
| 737 | } | - | ||||||||||||||||||||||||
| 738 | attrs->setType(PropertyAttributes::Accessor); | - | ||||||||||||||||||||||||
| 739 | } executed 9528 times by 2 tests: end of blockExecuted by:
| 9528 | ||||||||||||||||||||||||
| 740 | - | |||||||||||||||||||||||||
| 741 | if (o->hasProperty(engine->id_set()->toPropertyKey())) {
| 3604-17196 | ||||||||||||||||||||||||
| 742 | ScopedValue set(scope, o->get(engine->id_set())); | - | ||||||||||||||||||||||||
| 743 | FunctionObject *f = set->as<FunctionObject>(); | - | ||||||||||||||||||||||||
| 744 | if (f || set->isUndefined()) {
| 64-3040 | ||||||||||||||||||||||||
| 745 | desc->set = set; | - | ||||||||||||||||||||||||
| 746 | } else { executed 3522 times by 1 test: end of blockExecuted by:
| 3522 | ||||||||||||||||||||||||
| 747 | engine->throwTypeError(); | - | ||||||||||||||||||||||||
| 748 | return; executed 64 times by 1 test: return;Executed by:
| 64 | ||||||||||||||||||||||||
| 749 | } | - | ||||||||||||||||||||||||
| 750 | attrs->setType(PropertyAttributes::Accessor); | - | ||||||||||||||||||||||||
| 751 | } executed 3528 times by 1 test: end of blockExecuted by:
| 3528 | ||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||
| 753 | if (o->hasProperty(engine->id_writable()->toPropertyKey())) {
| 2998-17749 | ||||||||||||||||||||||||
| 754 | if (attrs->isAccessor()) {
| 24-2974 | ||||||||||||||||||||||||
| 755 | engine->throwTypeError(); | - | ||||||||||||||||||||||||
| 756 | return; executed 23 times by 1 test: return;Executed by:
| 23 | ||||||||||||||||||||||||
| 757 | } | - | ||||||||||||||||||||||||
| 758 | attrs->setWritable((tmp = o->get(engine->id_writable()))->toBoolean()); | - | ||||||||||||||||||||||||
| 759 | // writable forces it to be a data descriptor | - | ||||||||||||||||||||||||
| 760 | desc->value = Primitive::undefinedValue(); | - | ||||||||||||||||||||||||
| 761 | } executed 2962 times by 1 test: end of blockExecuted by:
| 2962 | ||||||||||||||||||||||||
| 762 | - | |||||||||||||||||||||||||
| 763 | if (o->hasProperty(engine->id_value()->toPropertyKey())) {
| 5760-14963 | ||||||||||||||||||||||||
| 764 | if (attrs->isAccessor()) {
| 24-5721 | ||||||||||||||||||||||||
| 765 | engine->throwTypeError(); | - | ||||||||||||||||||||||||
| 766 | return; executed 24 times by 1 test: return;Executed by:
| 24 | ||||||||||||||||||||||||
| 767 | } | - | ||||||||||||||||||||||||
| 768 | desc->value = o->get(engine->id_value()); | - | ||||||||||||||||||||||||
| 769 | attrs->setType(PropertyAttributes::Data); | - | ||||||||||||||||||||||||
| 770 | } executed 5725 times by 2 tests: end of blockExecuted by:
| 5725 | ||||||||||||||||||||||||
| 771 | - | |||||||||||||||||||||||||
| 772 | if (attrs->isGeneric())
| 2651-18012 | ||||||||||||||||||||||||
| 773 | desc->value = Primitive::emptyValue(); executed 2649 times by 1 test: desc->value = Primitive::emptyValue();Executed by:
| 2649 | ||||||||||||||||||||||||
| 774 | } executed 20629 times by 3 tests: end of blockExecuted by:
| 20629 | ||||||||||||||||||||||||
| 775 | - | |||||||||||||||||||||||||
| 776 | - | |||||||||||||||||||||||||
| 777 | ReturnedValue ObjectPrototype::fromPropertyDescriptor(ExecutionEngine *engine, const Property *desc, PropertyAttributes attrs) | - | ||||||||||||||||||||||||
| 778 | { | - | ||||||||||||||||||||||||
| 779 | if (attrs.isEmpty())
| 1253-23840 | ||||||||||||||||||||||||
| 780 | return Encode::undefined(); executed 1253 times by 1 test: return Encode::undefined();Executed by:
| 1253 | ||||||||||||||||||||||||
| 781 | - | |||||||||||||||||||||||||
| 782 | Scope scope(engine); | - | ||||||||||||||||||||||||
| 783 | // Let obj be the result of creating a new object as if by the expression new Object() where Object | - | ||||||||||||||||||||||||
| 784 | // is the standard built-in constructor with that name. | - | ||||||||||||||||||||||||
| 785 | ScopedObject o(scope, engine->newObject()); | - | ||||||||||||||||||||||||
| 786 | ScopedString s(scope); | - | ||||||||||||||||||||||||
| 787 | ScopedValue v(scope); | - | ||||||||||||||||||||||||
| 788 | - | |||||||||||||||||||||||||
| 789 | if (attrs.isData()) {
| 4550-19307 | ||||||||||||||||||||||||
| 790 | s = engine->newString(QStringLiteral("value")); executed 19293 times by 1 test: return qstring_literal_temp;Executed by:
| 19293 | ||||||||||||||||||||||||
| 791 | o->put(s, desc->value); | - | ||||||||||||||||||||||||
| 792 | v = Primitive::fromBoolean(attrs.isWritable()); | - | ||||||||||||||||||||||||
| 793 | s = engine->newString(QStringLiteral("writable")); executed 19312 times by 1 test: return qstring_literal_temp;Executed by:
| 19312 | ||||||||||||||||||||||||
| 794 | o->put(s, v); | - | ||||||||||||||||||||||||
| 795 | } else { executed 19343 times by 1 test: end of blockExecuted by:
| 19343 | ||||||||||||||||||||||||
| 796 | v = desc->getter() ? desc->getter()->asReturnedValue() : Encode::undefined();
| 1146-3407 | ||||||||||||||||||||||||
| 797 | s = engine->newString(QStringLiteral("get")); executed 4552 times by 1 test: return qstring_literal_temp;Executed by:
| 4552 | ||||||||||||||||||||||||
| 798 | o->put(s, v); | - | ||||||||||||||||||||||||
| 799 | v = desc->setter() ? desc->setter()->asReturnedValue() : Encode::undefined();
| 1801-2764 | ||||||||||||||||||||||||
| 800 | s = engine->newString(QStringLiteral("set")); executed 4570 times by 1 test: return qstring_literal_temp;Executed by:
| 4570 | ||||||||||||||||||||||||
| 801 | o->put(s, v); | - | ||||||||||||||||||||||||
| 802 | } executed 4575 times by 1 test: end of blockExecuted by:
| 4575 | ||||||||||||||||||||||||
| 803 | v = Primitive::fromBoolean(attrs.isEnumerable()); | - | ||||||||||||||||||||||||
| 804 | s = engine->newString(QStringLiteral("enumerable")); executed 23891 times by 1 test: return qstring_literal_temp;Executed by:
| 23891 | ||||||||||||||||||||||||
| 805 | o->put(s, v); | - | ||||||||||||||||||||||||
| 806 | v = Primitive::fromBoolean(attrs.isConfigurable()); | - | ||||||||||||||||||||||||
| 807 | s = engine->newString(QStringLiteral("configurable")); executed 23890 times by 1 test: return qstring_literal_temp;Executed by:
| 23890 | ||||||||||||||||||||||||
| 808 | o->put(s, v); | - | ||||||||||||||||||||||||
| 809 | - | |||||||||||||||||||||||||
| 810 | return o.asReturnedValue(); executed 23961 times by 1 test: return o.asReturnedValue();Executed by:
| 23961 | ||||||||||||||||||||||||
| 811 | } | - | ||||||||||||||||||||||||
| 812 | - | |||||||||||||||||||||||||
| 813 | // es6: GetOwnPropertyKeys | - | ||||||||||||||||||||||||
| 814 | Heap::ArrayObject *ObjectPrototype::getOwnPropertyNames(ExecutionEngine *v4, const Value &o) | - | ||||||||||||||||||||||||
| 815 | { | - | ||||||||||||||||||||||||
| 816 | Scope scope(v4); | - | ||||||||||||||||||||||||
| 817 | ScopedArrayObject array(scope, v4->newArrayObject()); | - | ||||||||||||||||||||||||
| 818 | ScopedObject O(scope, o.toObject(v4)); | - | ||||||||||||||||||||||||
| 819 | if (O) {
| 0-2237 | ||||||||||||||||||||||||
| 820 | ObjectIterator it(scope, O, ObjectIterator::NoFlags); | - | ||||||||||||||||||||||||
| 821 | ScopedValue name(scope); | - | ||||||||||||||||||||||||
| 822 | while (1) { | - | ||||||||||||||||||||||||
| 823 | name = it.nextPropertyNameAsString(); | - | ||||||||||||||||||||||||
| 824 | if (name->isNull())
| 2236-4776 | ||||||||||||||||||||||||
| 825 | break; executed 2235 times by 6 tests: break;Executed by:
| 2235 | ||||||||||||||||||||||||
| 826 | array->push_back(name); | - | ||||||||||||||||||||||||
| 827 | } executed 4775 times by 6 tests: end of blockExecuted by:
| 4775 | ||||||||||||||||||||||||
| 828 | } executed 2235 times by 6 tests: end of blockExecuted by:
| 2235 | ||||||||||||||||||||||||
| 829 | return array->d(); executed 2235 times by 6 tests: return array->d();Executed by:
| 2235 | ||||||||||||||||||||||||
| 830 | } | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |