Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4reflect.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||
3 | ** Copyright (C) 2018 The Qt Company Ltd. | - | ||||||||||||||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||
6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||||||||||||||||||||
7 | ** | - | ||||||||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
16 | ** | - | ||||||||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||
24 | ** | - | ||||||||||||||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||
35 | ** | - | ||||||||||||||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
37 | ** | - | ||||||||||||||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | #include "qv4reflect_p.h" | - | ||||||||||||||||||||||||
41 | #include "qv4symbol_p.h" | - | ||||||||||||||||||||||||
42 | #include "qv4runtimeapi_p.h" | - | ||||||||||||||||||||||||
43 | #include "qv4objectproto_p.h" | - | ||||||||||||||||||||||||
44 | #include "qv4propertykey_p.h" | - | ||||||||||||||||||||||||
45 | - | |||||||||||||||||||||||||
46 | using namespace QV4; | - | ||||||||||||||||||||||||
47 | - | |||||||||||||||||||||||||
48 | DEFINE_OBJECT_VTABLE(Reflect); | - | ||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | void Heap::Reflect::init() | - | ||||||||||||||||||||||||
51 | { | - | ||||||||||||||||||||||||
52 | Object::init(); | - | ||||||||||||||||||||||||
53 | Scope scope(internalClass->engine); | - | ||||||||||||||||||||||||
54 | ScopedObject r(scope, this); | - | ||||||||||||||||||||||||
55 | - | |||||||||||||||||||||||||
56 | r->defineDefaultProperty(QStringLiteral("apply"), QV4::Reflect::method_apply, 3); executed 97863 times by 153 tests: return qstring_literal_temp; Executed by:
| 97863 | ||||||||||||||||||||||||
57 | r->defineDefaultProperty(QStringLiteral("construct"), QV4::Reflect::method_construct, 2); executed 98489 times by 153 tests: return qstring_literal_temp; Executed by:
| 98489 | ||||||||||||||||||||||||
58 | r->defineDefaultProperty(QStringLiteral("defineProperty"), QV4::Reflect::method_defineProperty, 3); executed 98386 times by 153 tests: return qstring_literal_temp; Executed by:
| 98386 | ||||||||||||||||||||||||
59 | r->defineDefaultProperty(QStringLiteral("deleteProperty"), QV4::Reflect::method_deleteProperty, 2); executed 98460 times by 153 tests: return qstring_literal_temp; Executed by:
| 98460 | ||||||||||||||||||||||||
60 | r->defineDefaultProperty(QStringLiteral("get"), QV4::Reflect::method_get, 2); executed 98628 times by 153 tests: return qstring_literal_temp; Executed by:
| 98628 | ||||||||||||||||||||||||
61 | r->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptor"), QV4::Reflect::method_getOwnPropertyDescriptor, 2); executed 98454 times by 153 tests: return qstring_literal_temp; Executed by:
| 98454 | ||||||||||||||||||||||||
62 | r->defineDefaultProperty(QStringLiteral("getPrototypeOf"), QV4::Reflect::method_getPrototypeOf, 1); executed 98677 times by 153 tests: return qstring_literal_temp; Executed by:
| 98677 | ||||||||||||||||||||||||
63 | r->defineDefaultProperty(QStringLiteral("has"), QV4::Reflect::method_has, 2); executed 98814 times by 153 tests: return qstring_literal_temp; Executed by:
| 98814 | ||||||||||||||||||||||||
64 | r->defineDefaultProperty(QStringLiteral("isExtensible"), QV4::Reflect::method_isExtensible, 1); executed 98760 times by 153 tests: return qstring_literal_temp; Executed by:
| 98760 | ||||||||||||||||||||||||
65 | r->defineDefaultProperty(QStringLiteral("ownKeys"), QV4::Reflect::method_ownKeys, 1); executed 98529 times by 153 tests: return qstring_literal_temp; Executed by:
| 98529 | ||||||||||||||||||||||||
66 | r->defineDefaultProperty(QStringLiteral("preventExtensions"), QV4::Reflect::method_preventExtensions, 1); executed 98612 times by 153 tests: return qstring_literal_temp; Executed by:
| 98612 | ||||||||||||||||||||||||
67 | r->defineDefaultProperty(QStringLiteral("set"), QV4::Reflect::method_set, 3); executed 98838 times by 153 tests: return qstring_literal_temp; Executed by:
| 98838 | ||||||||||||||||||||||||
68 | r->defineDefaultProperty(QStringLiteral("setPrototypeOf"), QV4::Reflect::method_setPrototypeOf, 2); executed 98611 times by 153 tests: return qstring_literal_temp; Executed by:
| 98611 | ||||||||||||||||||||||||
69 | } executed 99044 times by 153 tests: end of block Executed by:
| 99044 | ||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||
71 | struct CallArgs { | - | ||||||||||||||||||||||||
72 | Value *argv; | - | ||||||||||||||||||||||||
73 | int argc; | - | ||||||||||||||||||||||||
74 | }; | - | ||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||
76 | static CallArgs createListFromArrayLike(Scope &scope, const Object *o) | - | ||||||||||||||||||||||||
77 | { | - | ||||||||||||||||||||||||
78 | int len = o->getLength(); | - | ||||||||||||||||||||||||
79 | Value *arguments = scope.alloc(len); | - | ||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | for (int i = 0; i < len; ++i) {
| 242-304 | ||||||||||||||||||||||||
82 | arguments[i] = o->get(i); | - | ||||||||||||||||||||||||
83 | if (scope.hasException())
| 0-243 | ||||||||||||||||||||||||
84 | return { nullptr, 0 }; never executed: return { nullptr, 0 }; | 0 | ||||||||||||||||||||||||
85 | } executed 243 times by 1 test: end of block Executed by:
| 243 | ||||||||||||||||||||||||
86 | return { arguments, len }; executed 304 times by 1 test: return { arguments, len }; Executed by:
| 304 | ||||||||||||||||||||||||
87 | } | - | ||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||
89 | ReturnedValue Reflect::method_apply(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
90 | { | - | ||||||||||||||||||||||||
91 | Scope scope(f); | - | ||||||||||||||||||||||||
92 | if (argc < 3 || !argv[0].isFunctionObject() || !argv[2].isObject())
| 0-32 | ||||||||||||||||||||||||
93 | return scope.engine->throwTypeError(); executed 16 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 16 | ||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||
95 | const Object *o = static_cast<const Object *>(argv + 2); | - | ||||||||||||||||||||||||
96 | CallArgs arguments = createListFromArrayLike(scope, o); | - | ||||||||||||||||||||||||
97 | if (scope.hasException())
| 4-12 | ||||||||||||||||||||||||
98 | return Encode::undefined(); executed 4 times by 1 test: return Encode::undefined(); Executed by:
| 4 | ||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | return static_cast<const FunctionObject &>(argv[0]).call(&argv[1], arguments.argv, arguments.argc); executed 12 times by 1 test: return static_cast<const FunctionObject &>(argv[0]).call(&argv[1], arguments.argv, arguments.argc); Executed by:
| 12 | ||||||||||||||||||||||||
101 | } | - | ||||||||||||||||||||||||
102 | - | |||||||||||||||||||||||||
103 | ReturnedValue Reflect::method_construct(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
104 | { | - | ||||||||||||||||||||||||
105 | Scope scope(f); | - | ||||||||||||||||||||||||
106 | if (argc < 2 || !argv[0].isFunctionObject() || !argv[1].isObject())
| 0-320 | ||||||||||||||||||||||||
107 | return scope.engine->throwTypeError(); executed 32 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 32 | ||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||
109 | const Object *o = static_cast<const Object *>(argv + 1); | - | ||||||||||||||||||||||||
110 | CallArgs arguments = createListFromArrayLike(scope, o); | - | ||||||||||||||||||||||||
111 | if (scope.hasException())
| 4-284 | ||||||||||||||||||||||||
112 | return Encode::undefined(); executed 4 times by 1 test: return Encode::undefined(); Executed by:
| 4 | ||||||||||||||||||||||||
113 | - | |||||||||||||||||||||||||
114 | return static_cast<const FunctionObject &>(argv[0]).callAsConstructor(arguments.argv, arguments.argc); executed 284 times by 1 test: return static_cast<const FunctionObject &>(argv[0]).callAsConstructor(arguments.argv, arguments.argc); Executed by:
| 284 | ||||||||||||||||||||||||
115 | } | - | ||||||||||||||||||||||||
116 | - | |||||||||||||||||||||||||
117 | ReturnedValue Reflect::method_defineProperty(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
118 | { | - | ||||||||||||||||||||||||
119 | Scope scope(f); | - | ||||||||||||||||||||||||
120 | if (!argc || !argv[0].isObject())
| 0-1079 | ||||||||||||||||||||||||
121 | return scope.engine->throwTypeError(); executed 20 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 20 | ||||||||||||||||||||||||
122 | - | |||||||||||||||||||||||||
123 | ScopedObject O(scope, argv[0]); | - | ||||||||||||||||||||||||
124 | ScopedPropertyKey name(scope, (argc > 1 ? argv[1] : Primitive::undefinedValue()).toPropertyKey(scope.engine)); | - | ||||||||||||||||||||||||
125 | if (scope.engine->hasException)
| 4-1055 | ||||||||||||||||||||||||
126 | return QV4::Encode::undefined(); executed 4 times by 1 test: return QV4::Encode::undefined(); Executed by:
| 4 | ||||||||||||||||||||||||
127 | - | |||||||||||||||||||||||||
128 | ScopedValue attributes(scope, argc > 2 ? argv[2] : Primitive::undefinedValue()); | - | ||||||||||||||||||||||||
129 | ScopedProperty pd(scope); | - | ||||||||||||||||||||||||
130 | PropertyAttributes attrs; | - | ||||||||||||||||||||||||
131 | ObjectPrototype::toPropertyDescriptor(scope.engine, attributes, pd, &attrs); | - | ||||||||||||||||||||||||
132 | if (scope.engine->hasException)
| 4-1051 | ||||||||||||||||||||||||
133 | return QV4::Encode::undefined(); executed 4 times by 1 test: return QV4::Encode::undefined(); Executed by:
| 4 | ||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||
135 | bool result = O->defineOwnProperty(name, pd, attrs); | - | ||||||||||||||||||||||||
136 | - | |||||||||||||||||||||||||
137 | return Encode(result); executed 1052 times by 1 test: return Encode(result); Executed by:
| 1052 | ||||||||||||||||||||||||
138 | } | - | ||||||||||||||||||||||||
139 | - | |||||||||||||||||||||||||
140 | ReturnedValue Reflect::method_deleteProperty(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
141 | { | - | ||||||||||||||||||||||||
142 | ExecutionEngine *e = f->engine(); | - | ||||||||||||||||||||||||
143 | if (!argc || !argv[0].isObject())
| 0-64 | ||||||||||||||||||||||||
144 | return e->throwTypeError(); executed 20 times by 1 test: return e->throwTypeError(); Executed by:
| 20 | ||||||||||||||||||||||||
145 | - | |||||||||||||||||||||||||
146 | bool result = Runtime::method_deleteProperty(e, argv[0], argc > 1 ? argv[1] : Primitive::undefinedValue()); | - | ||||||||||||||||||||||||
147 | return Encode(result); executed 44 times by 1 test: return Encode(result); Executed by:
| 44 | ||||||||||||||||||||||||
148 | } | - | ||||||||||||||||||||||||
149 | - | |||||||||||||||||||||||||
150 | ReturnedValue Reflect::method_get(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
151 | { | - | ||||||||||||||||||||||||
152 | Scope scope(f); | - | ||||||||||||||||||||||||
153 | if (!argc || !argv[0].isObject())
| 0-68 | ||||||||||||||||||||||||
154 | return scope.engine->throwTypeError(); executed 20 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 20 | ||||||||||||||||||||||||
155 | - | |||||||||||||||||||||||||
156 | ScopedObject o(scope, static_cast<const Object *>(argv)); | - | ||||||||||||||||||||||||
157 | Value undef = Primitive::undefinedValue(); | - | ||||||||||||||||||||||||
158 | const Value *index = argc > 1 ? &argv[1] : &undef;
| 0-48 | ||||||||||||||||||||||||
159 | ScopedPropertyKey name(scope, index->toPropertyKey(scope.engine)); | - | ||||||||||||||||||||||||
160 | if (scope.hasException())
| 4-44 | ||||||||||||||||||||||||
161 | return Encode::undefined(); executed 4 times by 1 test: return Encode::undefined(); Executed by:
| 4 | ||||||||||||||||||||||||
162 | ScopedValue receiver(scope, argc > 2 ? argv[2] : *o); | - | ||||||||||||||||||||||||
163 | - | |||||||||||||||||||||||||
164 | return Encode(o->get(name, receiver)); executed 44 times by 1 test: return Encode(o->get(name, receiver)); Executed by:
| 44 | ||||||||||||||||||||||||
165 | } | - | ||||||||||||||||||||||||
166 | - | |||||||||||||||||||||||||
167 | ReturnedValue Reflect::method_getOwnPropertyDescriptor(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
168 | { | - | ||||||||||||||||||||||||
169 | if (!argc || !argv[0].isObject())
| 0-148 | ||||||||||||||||||||||||
170 | return f->engine()->throwTypeError(); executed 20 times by 1 test: return f->engine()->throwTypeError(); Executed by:
| 20 | ||||||||||||||||||||||||
171 | - | |||||||||||||||||||||||||
172 | return ObjectPrototype::method_getOwnPropertyDescriptor(f, thisObject, argv, argc); executed 128 times by 1 test: return ObjectPrototype::method_getOwnPropertyDescriptor(f, thisObject, argv, argc); Executed by:
| 128 | ||||||||||||||||||||||||
173 | } | - | ||||||||||||||||||||||||
174 | - | |||||||||||||||||||||||||
175 | ReturnedValue Reflect::method_getPrototypeOf(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
176 | { | - | ||||||||||||||||||||||||
177 | if (!argc || !argv[0].isObject())
| 0-36 | ||||||||||||||||||||||||
178 | return f->engine()->throwTypeError(); executed 20 times by 1 test: return f->engine()->throwTypeError(); Executed by:
| 20 | ||||||||||||||||||||||||
179 | - | |||||||||||||||||||||||||
180 | const Object *o = static_cast<const Object *>(argv); | - | ||||||||||||||||||||||||
181 | Heap::Object *p = o->getPrototypeOf(); | - | ||||||||||||||||||||||||
182 | return (p ? p->asReturnedValue() : Encode::null()); executed 16 times by 1 test: return (p ? p->asReturnedValue() : Encode::null()); Executed by:
| 16 | ||||||||||||||||||||||||
183 | } | - | ||||||||||||||||||||||||
184 | - | |||||||||||||||||||||||||
185 | ReturnedValue Reflect::method_has(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
186 | { | - | ||||||||||||||||||||||||
187 | Scope scope(f); | - | ||||||||||||||||||||||||
188 | if (!argc || !argv[0].isObject())
| 0-1067 | ||||||||||||||||||||||||
189 | return scope.engine->throwTypeError(); executed 20 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 20 | ||||||||||||||||||||||||
190 | - | |||||||||||||||||||||||||
191 | ScopedObject o(scope, static_cast<const Object *>(argv)); | - | ||||||||||||||||||||||||
192 | Value undef = Primitive::undefinedValue(); | - | ||||||||||||||||||||||||
193 | const Value *index = argc > 1 ? &argv[1] : &undef;
| 0-1047 | ||||||||||||||||||||||||
194 | - | |||||||||||||||||||||||||
195 | ScopedPropertyKey name(scope, index->toPropertyKey(scope.engine)); | - | ||||||||||||||||||||||||
196 | if (scope.engine->hasException)
| 4-1044 | ||||||||||||||||||||||||
197 | return false; executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||||||||||||||
198 | - | |||||||||||||||||||||||||
199 | bool hasProperty = false; | - | ||||||||||||||||||||||||
200 | (void) o->get(name, nullptr, &hasProperty); | - | ||||||||||||||||||||||||
201 | return Encode(hasProperty); executed 1044 times by 1 test: return Encode(hasProperty); Executed by:
| 1044 | ||||||||||||||||||||||||
202 | } | - | ||||||||||||||||||||||||
203 | - | |||||||||||||||||||||||||
204 | ReturnedValue Reflect::method_isExtensible(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
205 | { | - | ||||||||||||||||||||||||
206 | if (!argc || !argv[0].isObject())
| 0-52 | ||||||||||||||||||||||||
207 | return f->engine()->throwTypeError(); executed 40 times by 1 test: return f->engine()->throwTypeError(); Executed by:
| 40 | ||||||||||||||||||||||||
208 | - | |||||||||||||||||||||||||
209 | const Object *o = static_cast<const Object *>(argv); | - | ||||||||||||||||||||||||
210 | return Encode(o->isExtensible()); executed 12 times by 1 test: return Encode(o->isExtensible()); Executed by:
| 12 | ||||||||||||||||||||||||
211 | } | - | ||||||||||||||||||||||||
212 | - | |||||||||||||||||||||||||
213 | - | |||||||||||||||||||||||||
214 | ReturnedValue Reflect::method_ownKeys(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||||||||||||||
215 | { | - | ||||||||||||||||||||||||
216 | if (!argc || !argv[0].isObject())
| 0-72 | ||||||||||||||||||||||||
217 | return f->engine()->throwTypeError(); executed 20 times by 1 test: return f->engine()->throwTypeError(); Executed by:
| 20 | ||||||||||||||||||||||||
218 | - | |||||||||||||||||||||||||
219 | return ObjectPrototype::method_getOwnPropertyNames(f, thisObject, argv, argc); executed 52 times by 1 test: return ObjectPrototype::method_getOwnPropertyNames(f, thisObject, argv, argc); Executed by:
| 52 | ||||||||||||||||||||||||
220 | } | - | ||||||||||||||||||||||||
221 | - | |||||||||||||||||||||||||
222 | ReturnedValue Reflect::method_preventExtensions(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
223 | { | - | ||||||||||||||||||||||||
224 | Scope scope(f); | - | ||||||||||||||||||||||||
225 | if (!argc || !argv[0].isObject())
| 0-44 | ||||||||||||||||||||||||
226 | return scope.engine->throwTypeError(); never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||||||||||||||
227 | - | |||||||||||||||||||||||||
228 | ScopedObject o(scope, static_cast<const Object *>(argv)); | - | ||||||||||||||||||||||||
229 | return Encode(o->preventExtensions()); executed 44 times by 1 test: return Encode(o->preventExtensions()); Executed by:
| 44 | ||||||||||||||||||||||||
230 | } | - | ||||||||||||||||||||||||
231 | - | |||||||||||||||||||||||||
232 | ReturnedValue Reflect::method_set(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
233 | { | - | ||||||||||||||||||||||||
234 | Scope scope(f); | - | ||||||||||||||||||||||||
235 | if (!argc || !argv[0].isObject())
| 0-855 | ||||||||||||||||||||||||
236 | return scope.engine->throwTypeError(); executed 20 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 20 | ||||||||||||||||||||||||
237 | - | |||||||||||||||||||||||||
238 | ScopedObject o(scope, static_cast<const Object *>(argv)); | - | ||||||||||||||||||||||||
239 | Value undef = Primitive::undefinedValue(); | - | ||||||||||||||||||||||||
240 | const Value *index = argc > 1 ? &argv[1] : &undef;
| 0-835 | ||||||||||||||||||||||||
241 | const Value &val = argc > 2 ? argv[2] : undef;
| 4-831 | ||||||||||||||||||||||||
242 | ScopedValue receiver(scope, argc >3 ? argv[3] : argv[0]); | - | ||||||||||||||||||||||||
243 | - | |||||||||||||||||||||||||
244 | ScopedPropertyKey propertyKey(scope, index->toPropertyKey(scope.engine)); | - | ||||||||||||||||||||||||
245 | if (scope.engine->hasException)
| 4-831 | ||||||||||||||||||||||||
246 | return false; executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||||||||||||||
247 | bool result = o->put(propertyKey, val, receiver); | - | ||||||||||||||||||||||||
248 | return Encode(result); executed 832 times by 1 test: return Encode(result); Executed by:
| 832 | ||||||||||||||||||||||||
249 | } | - | ||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||
251 | ReturnedValue Reflect::method_setPrototypeOf(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||||||||||||||
252 | { | - | ||||||||||||||||||||||||
253 | if (argc < 2 || !argv[0].isObject() || (!argv[1].isNull() && !argv[1].isObject()))
| 0-180 | ||||||||||||||||||||||||
254 | return f->engine()->throwTypeError(); executed 40 times by 1 test: return f->engine()->throwTypeError(); Executed by:
| 40 | ||||||||||||||||||||||||
255 | - | |||||||||||||||||||||||||
256 | Scope scope(f); | - | ||||||||||||||||||||||||
257 | ScopedObject o(scope, static_cast<const Object *>(argv)); | - | ||||||||||||||||||||||||
258 | const Object *proto = argv[1].isNull() ? nullptr : static_cast<const Object *>(argv + 1);
| 16-124 | ||||||||||||||||||||||||
259 | return Encode(o->setPrototypeOf(proto)); executed 140 times by 1 test: return Encode(o->setPrototypeOf(proto)); Executed by:
| 140 | ||||||||||||||||||||||||
260 | } | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |