Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4functionobject.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | using namespace QV4; | - | ||||||||||||
9 | - | |||||||||||||
10 | - | |||||||||||||
11 | const QV4::VTable FunctionObject::static_vtbl = { (std::is_same<FunctionObject::SuperClass, Object>::value) ? nullptr : &FunctionObject::SuperClass::static_vtbl, (sizeof(FunctionObject::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(FunctionObject::Data) + (FunctionObject::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(FunctionObject::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), FunctionObject::IsExecutionContext, FunctionObject::IsString, FunctionObject::IsObject, FunctionObject::IsFunctionObject, FunctionObject::IsErrorObject, FunctionObject::IsArrayData, FunctionObject::IsStringOrSymbol, FunctionObject::MyType, { 0, 0, 0, 0 }, "FunctionObject", FunctionObject::virtualDestroy, FunctionObject::Data::markObjects, FunctionObject::virtualIsEqualTo, FunctionObject::virtualGet, FunctionObject::virtualPut, FunctionObject::virtualDeleteProperty, FunctionObject::virtualHasProperty, FunctionObject::virtualGetOwnProperty, FunctionObject::virtualDefineOwnProperty, FunctionObject::virtualIsExtensible, FunctionObject::virtualPreventExtensions, FunctionObject::virtualGetPrototypeOf, FunctionObject::virtualSetPrototypeOf, FunctionObject::virtualGetLength, FunctionObject::virtualAdvanceIterator, FunctionObject::virtualInstanceOf, FunctionObject::virtualCall, FunctionObject::virtualCallAsConstructor, }; | - | ||||||||||||
12 | - | |||||||||||||
13 | void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name, | - | ||||||||||||
14 | ReturnedValue (*code)(const QV4::FunctionObject *, const Value *thisObject, const Value *argv, int argc)) | - | ||||||||||||
15 | { | - | ||||||||||||
16 | jsCall = code; | - | ||||||||||||
17 | jsConstruct = QV4::FunctionObject::virtualCallAsConstructor; | - | ||||||||||||
18 | - | |||||||||||||
19 | Object::init(); | - | ||||||||||||
20 | this->scope.set(scope->engine(), scope->d()); | - | ||||||||||||
21 | Scope s(scope->engine()); | - | ||||||||||||
22 | ScopedFunctionObject f(s, this); | - | ||||||||||||
23 | if (name
| 99063-34321871 | ||||||||||||
24 | f->setName(name); executed 34317055 times by 153 tests: f->setName(name); Executed by:
| 34317055 | ||||||||||||
25 | } executed 34351957 times by 153 tests: end of block Executed by:
| 34351957 | ||||||||||||
26 | - | |||||||||||||
27 | void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name, bool createProto) | - | ||||||||||||
28 | { | - | ||||||||||||
29 | jsCall = vtable()->call; | - | ||||||||||||
30 | jsConstruct = vtable()->callAsConstructor; | - | ||||||||||||
31 | - | |||||||||||||
32 | Object::init(); | - | ||||||||||||
33 | this->scope.set(scope->engine(), scope->d()); | - | ||||||||||||
34 | Scope s(scope->engine()); | - | ||||||||||||
35 | ScopedFunctionObject f(s, this); | - | ||||||||||||
36 | if (name
| 180222-3180157 | ||||||||||||
37 | f->setName(name); executed 3178928 times by 153 tests: f->setName(name); Executed by:
| 3178928 | ||||||||||||
38 | - | |||||||||||||
39 | if (createProto
| 0-3359402 | ||||||||||||
40 | f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_Prototype, Heap::FunctionObject::Index_ProtoConstructor); never executed: f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_Prototype, Heap::FunctionObject::Index_ProtoConstructor); | 0 | ||||||||||||
41 | } executed 3358433 times by 153 tests: end of block Executed by:
| 3358433 | ||||||||||||
42 | - | |||||||||||||
43 | - | |||||||||||||
44 | - | |||||||||||||
45 | void Heap::FunctionObject::init(QV4::ExecutionContext *scope, Function *function, bool createProto) | - | ||||||||||||
46 | { | - | ||||||||||||
47 | jsCall = vtable()->call; | - | ||||||||||||
48 | jsConstruct = vtable()->callAsConstructor; | - | ||||||||||||
49 | - | |||||||||||||
50 | Object::init(); | - | ||||||||||||
51 | setFunction(function); | - | ||||||||||||
52 | this->scope.set(scope->engine(), scope->d()); | - | ||||||||||||
53 | Scope s(scope->engine()); | - | ||||||||||||
54 | ScopedString name(s, function->name()); | - | ||||||||||||
55 | ScopedFunctionObject f(s, this); | - | ||||||||||||
56 | if (name
| 0-90 | ||||||||||||
57 | f->setName(name); executed 90 times by 8 tests: f->setName(name); Executed by:
| 90 | ||||||||||||
58 | - | |||||||||||||
59 | if (createProto
| 0-90 | ||||||||||||
60 | f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_Prototype, Heap::FunctionObject::Index_ProtoConstructor); never executed: f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_Prototype, Heap::FunctionObject::Index_ProtoConstructor); | 0 | ||||||||||||
61 | } executed 90 times by 8 tests: end of block Executed by:
| 90 | ||||||||||||
62 | - | |||||||||||||
63 | void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const QString &name, bool createProto) | - | ||||||||||||
64 | { | - | ||||||||||||
65 | Scope valueScope(scope); | - | ||||||||||||
66 | ScopedString s(valueScope, valueScope.engine->newString(name)); | - | ||||||||||||
67 | init(scope, s, createProto); | - | ||||||||||||
68 | } executed 3083351 times by 153 tests: end of block Executed by:
| 3083351 | ||||||||||||
69 | - | |||||||||||||
70 | void Heap::FunctionObject::init() | - | ||||||||||||
71 | { | - | ||||||||||||
72 | jsCall = vtable()->call; | - | ||||||||||||
73 | jsConstruct = vtable()->callAsConstructor; | - | ||||||||||||
74 | - | |||||||||||||
75 | Object::init(); | - | ||||||||||||
76 | this->scope.set(internalClass->engine, internalClass->engine->rootContext()->d()); | - | ||||||||||||
77 | ((internalClass && internalClass->find(internalClass->engine->id_prototype()->propertyKey()) == Index_Prototype) ? static_cast<void>(0) : qt_assert("internalClass && internalClass->find(internalClass->engine->id_prototype()->propertyKey()) == Index_Prototype", __FILE__, 137)); | - | ||||||||||||
78 | setProperty(internalClass->engine, Index_Prototype, Primitive::undefinedValue()); | - | ||||||||||||
79 | } executed 1621011 times by 153 tests: end of block Executed by:
| 1621011 | ||||||||||||
80 | - | |||||||||||||
81 | void Heap::FunctionObject::setFunction(Function *f) | - | ||||||||||||
82 | { | - | ||||||||||||
83 | if (f
| 44-1522818 | ||||||||||||
84 | function = f; | - | ||||||||||||
85 | function->compilationUnit->addref(); | - | ||||||||||||
86 | } executed 1524066 times by 62 tests: end of block Executed by:
| 1524066 | ||||||||||||
87 | } executed 1524161 times by 62 tests: end of block Executed by:
| 1524161 | ||||||||||||
88 | void Heap::FunctionObject::destroy() | - | ||||||||||||
89 | { | - | ||||||||||||
90 | if (function
| 1525791-37877975 | ||||||||||||
91 | function->compilationUnit->release(); executed 1525800 times by 62 tests: function->compilationUnit->release(); Executed by:
| 1525800 | ||||||||||||
92 | Object::destroy(); | - | ||||||||||||
93 | } executed 39395632 times by 153 tests: end of block Executed by:
| 39395632 | ||||||||||||
94 | - | |||||||||||||
95 | void FunctionObject::createDefaultPrototypeProperty(uint protoSlot, uint protoConstructorSlot) | - | ||||||||||||
96 | { | - | ||||||||||||
97 | Scope s(this); | - | ||||||||||||
98 | - | |||||||||||||
99 | ((internalClass() && internalClass()->find(s.engine->id_prototype()->propertyKey()) == protoSlot) ? static_cast<void>(0) : qt_assert("internalClass() && internalClass()->find(s.engine->id_prototype()->propertyKey()) == protoSlot", __FILE__, 159)); | - | ||||||||||||
100 | ((s.engine->internalClasses(EngineBase::Class_ObjectProto)->find(s.engine->id_constructor()->propertyKey()) == protoConstructorSlot) ? static_cast<void>(0) : qt_assert("s.engine->internalClasses(EngineBase::Class_ObjectProto)->find(s.engine->id_constructor()->propertyKey()) == protoConstructorSlot", __FILE__, 160)); | - | ||||||||||||
101 | - | |||||||||||||
102 | ScopedObject proto(s, s.engine->newObject(s.engine->internalClasses(EngineBase::Class_ObjectProto))); | - | ||||||||||||
103 | proto->setProperty(protoConstructorSlot, d()); | - | ||||||||||||
104 | setProperty(protoSlot, proto); | - | ||||||||||||
105 | } executed 1523507 times by 62 tests: end of block Executed by:
| 1523507 | ||||||||||||
106 | - | |||||||||||||
107 | ReturnedValue FunctionObject::name() const | - | ||||||||||||
108 | { | - | ||||||||||||
109 | return executed 891471 times by 153 tests: get(scope()->internalClass->engine->id_name());return get(scope()->internalClass->engine->id_name()); Executed by:
executed 891471 times by 153 tests: return get(scope()->internalClass->engine->id_name()); Executed by:
| 891471 | ||||||||||||
110 | } | - | ||||||||||||
111 | - | |||||||||||||
112 | ReturnedValue FunctionObject::virtualCallAsConstructor(const FunctionObject *f, const Value *, int, const Value *) | - | ||||||||||||
113 | { | - | ||||||||||||
114 | return executed 302 times by 1 test: f->engine()->throwTypeError();return f->engine()->throwTypeError(); Executed by:
executed 302 times by 1 test: return f->engine()->throwTypeError(); Executed by:
| 302 | ||||||||||||
115 | } | - | ||||||||||||
116 | - | |||||||||||||
117 | ReturnedValue FunctionObject::virtualCall(const FunctionObject *, const Value *, const Value *, int) | - | ||||||||||||
118 | { | - | ||||||||||||
119 | return executed 16 times by 1 test: Encode::undefined();return Encode::undefined(); Executed by:
executed 16 times by 1 test: return Encode::undefined(); Executed by:
| 16 | ||||||||||||
120 | } | - | ||||||||||||
121 | - | |||||||||||||
122 | Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function) | - | ||||||||||||
123 | { | - | ||||||||||||
124 | return executed 1508812 times by 62 tests: scope->engine()->memoryManager->allocate<ScriptFunction>(scope, function);return scope->engine()->memoryManager->allocate<ScriptFunction>(scope, function); Executed by:
executed 1508812 times by 62 tests: return scope->engine()->memoryManager->allocate<ScriptFunction>(scope, function); Executed by:
| 1508812 | ||||||||||||
125 | } | - | ||||||||||||
126 | - | |||||||||||||
127 | Heap::FunctionObject *FunctionObject::createConstructorFunction(ExecutionContext *scope, Function *function, bool isDerivedConstructor) | - | ||||||||||||
128 | { | - | ||||||||||||
129 | if (!function
| 660-8353 | ||||||||||||
130 | Heap::DefaultClassConstructorFunction *c = scope->engine()->memoryManager->allocate<DefaultClassConstructorFunction>(scope); | - | ||||||||||||
131 | c->isDerivedConstructor = isDerivedConstructor; | - | ||||||||||||
132 | return executed 8358 times by 1 test: c;return c; Executed by:
executed 8358 times by 1 test: return c; Executed by:
| 8358 | ||||||||||||
133 | } | - | ||||||||||||
134 | Heap::ConstructorFunction *c = scope->engine()->memoryManager->allocate<ConstructorFunction>(scope, function); | - | ||||||||||||
135 | c->isDerivedConstructor = isDerivedConstructor; | - | ||||||||||||
136 | return executed 660 times by 1 test: c;return c; Executed by:
executed 660 times by 1 test: return c; Executed by:
| 660 | ||||||||||||
137 | } | - | ||||||||||||
138 | - | |||||||||||||
139 | Heap::FunctionObject *FunctionObject::createMemberFunction(ExecutionContext *scope, Function *function) | - | ||||||||||||
140 | { | - | ||||||||||||
141 | return executed 4735 times by 1 test: scope->engine()->memoryManager->allocate<MemberFunction>(scope, function);return scope->engine()->memoryManager->allocate<MemberFunction>(scope, function); Executed by:
executed 4735 times by 1 test: return scope->engine()->memoryManager->allocate<MemberFunction>(scope, function); Executed by:
| 4735 | ||||||||||||
142 | } | - | ||||||||||||
143 | - | |||||||||||||
144 | Heap::FunctionObject *FunctionObject::createBuiltinFunction(ExecutionEngine *engine, StringOrSymbol *nameOrSymbol, VTable::Call code, int argumentCount) | - | ||||||||||||
145 | { | - | ||||||||||||
146 | Scope scope(engine); | - | ||||||||||||
147 | ScopedString name(scope, nameOrSymbol); | - | ||||||||||||
148 | if (!name
| 494366-33854654 | ||||||||||||
149 | name = engine->newString(QChar::fromLatin1('[') + nameOrSymbol->toQString().midRef(1) + QChar::fromLatin1(']')); executed 493746 times by 153 tests: name = engine->newString(QChar::fromLatin1('[') + nameOrSymbol->toQString().midRef(1) + QChar::fromLatin1(']')); Executed by:
| 493746 | ||||||||||||
150 | - | |||||||||||||
151 | ScopedFunctionObject function(scope, engine->memoryManager->allocate<FunctionObject>(engine->rootContext(), name, code)); | - | ||||||||||||
152 | function->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(argumentCount)); | - | ||||||||||||
153 | return executed 34288646 times by 153 tests: function->d();return function->d(); Executed by:
executed 34288646 times by 153 tests: return function->d(); Executed by:
| 34288646 | ||||||||||||
154 | } | - | ||||||||||||
155 | - | |||||||||||||
156 | bool FunctionObject::isBinding() const | - | ||||||||||||
157 | { | - | ||||||||||||
158 | return executed 742 times by 13 tests: d()->vtable() == QQmlBindingFunction::staticVTable();return d()->vtable() == QQmlBindingFunction::staticVTable(); Executed by:
executed 742 times by 13 tests: return d()->vtable() == QQmlBindingFunction::staticVTable(); Executed by:
| 742 | ||||||||||||
159 | } | - | ||||||||||||
160 | - | |||||||||||||
161 | bool FunctionObject::isBoundFunction() const | - | ||||||||||||
162 | { | - | ||||||||||||
163 | return executed 4289625 times by 17 tests: d()->vtable() == BoundFunction::staticVTable();return d()->vtable() == BoundFunction::staticVTable(); Executed by:
executed 4289625 times by 17 tests: return d()->vtable() == BoundFunction::staticVTable(); Executed by:
| 4289625 | ||||||||||||
164 | } | - | ||||||||||||
165 | - | |||||||||||||
166 | QQmlSourceLocation FunctionObject::sourceLocation() const | - | ||||||||||||
167 | { | - | ||||||||||||
168 | return never executed: d()->function->sourceLocation();return d()->function->sourceLocation(); never executed: return d()->function->sourceLocation(); | 0 | ||||||||||||
169 | } | - | ||||||||||||
170 | - | |||||||||||||
171 | const QV4::VTable FunctionCtor::static_vtbl = { (std::is_same<FunctionCtor::SuperClass, Object>::value) ? nullptr : &FunctionCtor::SuperClass::static_vtbl, (sizeof(FunctionCtor::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(FunctionCtor::Data) + (FunctionCtor::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(FunctionCtor::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), FunctionCtor::IsExecutionContext, FunctionCtor::IsString, FunctionCtor::IsObject, FunctionCtor::IsFunctionObject, FunctionCtor::IsErrorObject, FunctionCtor::IsArrayData, FunctionCtor::IsStringOrSymbol, FunctionCtor::MyType, { 0, 0, 0, 0 }, "FunctionCtor", FunctionCtor::virtualDestroy, FunctionCtor::Data::markObjects, FunctionCtor::virtualIsEqualTo, FunctionCtor::virtualGet, FunctionCtor::virtualPut, FunctionCtor::virtualDeleteProperty, FunctionCtor::virtualHasProperty, FunctionCtor::virtualGetOwnProperty, FunctionCtor::virtualDefineOwnProperty, FunctionCtor::virtualIsExtensible, FunctionCtor::virtualPreventExtensions, FunctionCtor::virtualGetPrototypeOf, FunctionCtor::virtualSetPrototypeOf, FunctionCtor::virtualGetLength, FunctionCtor::virtualAdvanceIterator, FunctionCtor::virtualInstanceOf, FunctionCtor::virtualCall, FunctionCtor::virtualCallAsConstructor, }; | - | ||||||||||||
172 | - | |||||||||||||
173 | void Heap::FunctionCtor::init(QV4::ExecutionContext *scope) | - | ||||||||||||
174 | { | - | ||||||||||||
175 | Heap::FunctionObject::init(scope, ([]() noexcept -> QString { enum { Size = sizeof(u"" "Function")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Function" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98685 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98685 times by 153 tests: }()));return qstring_literal_temp; Executed by:
| 98685 | ||||||||||||
176 | } executed 98961 times by 153 tests: end of block Executed by:
| 98961 | ||||||||||||
177 | - | |||||||||||||
178 | - | |||||||||||||
179 | QQmlRefPointer<CompiledData::CompilationUnit> FunctionCtor::parse(ExecutionEngine *engine, const Value *argv, int argc, Type t) | - | ||||||||||||
180 | { | - | ||||||||||||
181 | QString arguments; | - | ||||||||||||
182 | QString body; | - | ||||||||||||
183 | if (argc > 0
| 180-818 | ||||||||||||
184 | for (int i = 0, ei = argc - 1; i < ei
| 548-820 | ||||||||||||
185 | if (i
| 174-374 | ||||||||||||
186 | arguments += QLatin1String(", "); executed 176 times by 1 test: arguments += QLatin1String(", "); Executed by:
| 176 | ||||||||||||
187 | arguments += argv[i].toQString(); | - | ||||||||||||
188 | } executed 547 times by 2 tests: end of block Executed by:
| 547 | ||||||||||||
189 | body = argv[argc - 1].toQString(); | - | ||||||||||||
190 | } executed 825 times by 2 tests: end of block Executed by:
| 825 | ||||||||||||
191 | if (engine->hasException
| 12-993 | ||||||||||||
192 | return executed 12 times by 1 test: nullptr;return nullptr; Executed by:
executed 12 times by 1 test: return nullptr; Executed by:
| 12 | ||||||||||||
193 | - | |||||||||||||
194 | QString function = (t == Type_Function
| 120-867 | ||||||||||||
195 | - | |||||||||||||
196 | QQmlJS::Engine ee; | - | ||||||||||||
197 | QQmlJS::Lexer lexer(&ee); | - | ||||||||||||
198 | lexer.setCode(function, 1, false); | - | ||||||||||||
199 | QQmlJS::Parser parser(&ee); | - | ||||||||||||
200 | - | |||||||||||||
201 | const bool parsed = parser.parseExpression(); | - | ||||||||||||
202 | - | |||||||||||||
203 | if (!parsed
| 36-952 | ||||||||||||
204 | engine->throwSyntaxError(QLatin1String("Parse error")); | - | ||||||||||||
205 | return executed 36 times by 1 test: nullptr;return nullptr; Executed by:
executed 36 times by 1 test: return nullptr; Executed by:
| 36 | ||||||||||||
206 | } | - | ||||||||||||
207 | - | |||||||||||||
208 | QQmlJS::AST::FunctionExpression *fe = QQmlJS::AST::cast<QQmlJS::AST::FunctionExpression *>(parser.rootNode()); | - | ||||||||||||
209 | if (!fe
| 0-951 | ||||||||||||
210 | engine->throwSyntaxError(QLatin1String("Parse error")); | - | ||||||||||||
211 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||
212 | } | - | ||||||||||||
213 | - | |||||||||||||
214 | Compiler::Module module(engine->debugger() != nullptr); | - | ||||||||||||
215 | - | |||||||||||||
216 | Compiler::JSUnitGenerator jsGenerator(&module); | - | ||||||||||||
217 | RuntimeCodegen cg(engine, &jsGenerator, false); | - | ||||||||||||
218 | cg.generateFromFunctionExpression(QString(), function, fe, &module); | - | ||||||||||||
219 | - | |||||||||||||
220 | if (engine->hasException
| 16-935 | ||||||||||||
221 | return executed 16 times by 1 test: nullptr;return nullptr; Executed by:
executed 16 times by 1 test: return nullptr; Executed by:
| 16 | ||||||||||||
222 | - | |||||||||||||
223 | return executed 934 times by 2 tests: cg.generateCompilationUnit();return cg.generateCompilationUnit(); Executed by:
executed 934 times by 2 tests: return cg.generateCompilationUnit(); Executed by:
| 934 | ||||||||||||
224 | } | - | ||||||||||||
225 | - | |||||||||||||
226 | ReturnedValue FunctionCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *) | - | ||||||||||||
227 | { | - | ||||||||||||
228 | ExecutionEngine *engine = f->engine(); | - | ||||||||||||
229 | - | |||||||||||||
230 | QQmlRefPointer<CompiledData::CompilationUnit> compilationUnit = parse(engine, argv, argc, Type_Function); | - | ||||||||||||
231 | if (engine->hasException
| 56-823 | ||||||||||||
232 | return executed 56 times by 1 test: Encode::undefined();return Encode::undefined(); Executed by:
executed 56 times by 1 test: return Encode::undefined(); Executed by:
| 56 | ||||||||||||
233 | - | |||||||||||||
234 | Function *vmf = compilationUnit->linkToEngine(engine); | - | ||||||||||||
235 | ExecutionContext *global = engine->scriptContext(); | - | ||||||||||||
236 | return executed 821 times by 2 tests: Encode(FunctionObject::createScriptFunction(global, vmf));return Encode(FunctionObject::createScriptFunction(global, vmf)); Executed by:
executed 821 times by 2 tests: return Encode(FunctionObject::createScriptFunction(global, vmf)); Executed by:
| 821 | ||||||||||||
237 | } | - | ||||||||||||
238 | - | |||||||||||||
239 | - | |||||||||||||
240 | ReturnedValue FunctionCtor::virtualCall(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||
241 | { | - | ||||||||||||
242 | return executed 516 times by 1 test: virtualCallAsConstructor(f, argv, argc, f);return virtualCallAsConstructor(f, argv, argc, f); Executed by:
executed 516 times by 1 test: return virtualCallAsConstructor(f, argv, argc, f); Executed by:
| 516 | ||||||||||||
243 | } | - | ||||||||||||
244 | - | |||||||||||||
245 | const QV4::VTable FunctionPrototype::static_vtbl = { (std::is_same<FunctionPrototype::SuperClass, Object>::value) ? nullptr : &FunctionPrototype::SuperClass::static_vtbl, (sizeof(FunctionPrototype::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(FunctionPrototype::Data) + (FunctionPrototype::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(FunctionPrototype::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), FunctionPrototype::IsExecutionContext, FunctionPrototype::IsString, FunctionPrototype::IsObject, FunctionPrototype::IsFunctionObject, FunctionPrototype::IsErrorObject, FunctionPrototype::IsArrayData, FunctionPrototype::IsStringOrSymbol, FunctionPrototype::MyType, { 0, 0, 0, 0 }, "FunctionPrototype", FunctionPrototype::virtualDestroy, FunctionPrototype::Data::markObjects, FunctionPrototype::virtualIsEqualTo, FunctionPrototype::virtualGet, FunctionPrototype::virtualPut, FunctionPrototype::virtualDeleteProperty, FunctionPrototype::virtualHasProperty, FunctionPrototype::virtualGetOwnProperty, FunctionPrototype::virtualDefineOwnProperty, FunctionPrototype::virtualIsExtensible, FunctionPrototype::virtualPreventExtensions, FunctionPrototype::virtualGetPrototypeOf, FunctionPrototype::virtualSetPrototypeOf, FunctionPrototype::virtualGetLength, FunctionPrototype::virtualAdvanceIterator, FunctionPrototype::virtualInstanceOf, FunctionPrototype::virtualCall, FunctionPrototype::virtualCallAsConstructor, }; | - | ||||||||||||
246 | - | |||||||||||||
247 | void Heap::FunctionPrototype::init() | - | ||||||||||||
248 | { | - | ||||||||||||
249 | Heap::FunctionObject::init(); | - | ||||||||||||
250 | } executed 98817 times by 153 tests: end of block Executed by:
| 98817 | ||||||||||||
251 | - | |||||||||||||
252 | void FunctionPrototype::init(ExecutionEngine *engine, Object *ctor) | - | ||||||||||||
253 | { | - | ||||||||||||
254 | Scope scope(engine); | - | ||||||||||||
255 | ScopedObject o(scope); | - | ||||||||||||
256 | - | |||||||||||||
257 | ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1)); | - | ||||||||||||
258 | ctor->defineReadonlyProperty(engine->id_prototype(), (o = this)); | - | ||||||||||||
259 | - | |||||||||||||
260 | defineReadonlyConfigurableProperty(engine->id_name(), *engine->id_empty()); | - | ||||||||||||
261 | defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(0)); | - | ||||||||||||
262 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "constructor")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "constructor" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98860 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 98860 times by 153 tests: }()), (o = ctor));return qstring_literal_temp; Executed by:
| 98860 | ||||||||||||
263 | defineDefaultProperty(engine->id_toString(), method_toString, 0); | - | ||||||||||||
264 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "apply")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "apply" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99069 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 99069 times by 153 tests: }()), method_apply, 2);return qstring_literal_temp; Executed by:
| 99069 | ||||||||||||
265 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "call")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "call" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99094 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 99094 times by 153 tests: }()), method_call, 1);return qstring_literal_temp; Executed by:
| 99094 | ||||||||||||
266 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "bind")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "bind" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99066 times by 153 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 99066 times by 153 tests: }()), method_bind, 1);return qstring_literal_temp; Executed by:
| 99066 | ||||||||||||
267 | defineDefaultProperty(engine->symbol_hasInstance(), method_hasInstance, 1, Attr_ReadOnly); | - | ||||||||||||
268 | } executed 99035 times by 153 tests: end of block Executed by:
| 99035 | ||||||||||||
269 | - | |||||||||||||
270 | ReturnedValue FunctionPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||
271 | { | - | ||||||||||||
272 | ExecutionEngine *v4 = b->engine(); | - | ||||||||||||
273 | const FunctionObject *fun = thisObject->as<FunctionObject>(); | - | ||||||||||||
274 | if (!fun
| 22-1306 | ||||||||||||
275 | return executed 22 times by 2 tests: v4->throwTypeError();return v4->throwTypeError(); Executed by:
executed 22 times by 2 tests: return v4->throwTypeError(); Executed by:
| 22 | ||||||||||||
276 | - | |||||||||||||
277 | const Scope scope(fun->engine()); | - | ||||||||||||
278 | const ScopedString scopedFunctionName(scope, fun->name()); | - | ||||||||||||
279 | const QString functionName(scopedFunctionName ? scopedFunctionName->toQString() : QString()); | - | ||||||||||||
280 | QString functionAsString = ([]() noexcept -> QString { enum { Size = sizeof(u"" "function")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "function" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); | - | ||||||||||||
281 | - | |||||||||||||
282 | - | |||||||||||||
283 | - | |||||||||||||
284 | if (!functionName.isEmpty()
| 600-706 | ||||||||||||
285 | functionAsString.append(QLatin1Char(' ') + functionName); executed 600 times by 4 tests: functionAsString.append(QLatin1Char(' ') + functionName); Executed by:
| 600 | ||||||||||||
286 | - | |||||||||||||
287 | functionAsString.append(([]() noexcept -> QString { enum { Size = sizeof(u"" "() { [code] }")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "() { [code] }" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 1306 times by 4 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 1306 times by 4 tests: }()));return qstring_literal_temp; Executed by:
| 1306 | ||||||||||||
288 | - | |||||||||||||
289 | return executed 1306 times by 4 tests: Encode(v4->newString(functionAsString));return Encode(v4->newString(functionAsString)); Executed by:
executed 1306 times by 4 tests: return Encode(v4->newString(functionAsString)); Executed by:
| 1306 | ||||||||||||
290 | } | - | ||||||||||||
291 | - | |||||||||||||
292 | ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
293 | { | - | ||||||||||||
294 | ExecutionEngine *v4 = b->engine(); | - | ||||||||||||
295 | const FunctionObject *f = thisObject->as<FunctionObject>(); | - | ||||||||||||
296 | if (!f
| 19-259 | ||||||||||||
297 | return executed 19 times by 1 test: v4->throwTypeError();return v4->throwTypeError(); Executed by:
executed 19 times by 1 test: return v4->throwTypeError(); Executed by:
| 19 | ||||||||||||
298 | thisObject = argc
| 28-231 | ||||||||||||
299 | if (argc < 2
| 0-142 | ||||||||||||
300 | return executed 141 times by 1 test: f->call(thisObject, argv, 0);return f->call(thisObject, argv, 0); Executed by:
executed 141 times by 1 test: return f->call(thisObject, argv, 0); Executed by:
| 141 | ||||||||||||
301 | - | |||||||||||||
302 | Object *arr = argv[1].objectValue(); | - | ||||||||||||
303 | if (!arr
| 8-108 | ||||||||||||
304 | return executed 8 times by 1 test: v4->throwTypeError();return v4->throwTypeError(); Executed by:
executed 8 times by 1 test: return v4->throwTypeError(); Executed by:
| 8 | ||||||||||||
305 | - | |||||||||||||
306 | uint len = arr->getLength(); | - | ||||||||||||
307 | - | |||||||||||||
308 | Scope scope(v4); | - | ||||||||||||
309 | Value *arguments = scope.alloc(len); | - | ||||||||||||
310 | if (len
| 10-98 | ||||||||||||
311 | if (ArgumentsObject::isNonStrictArgumentsObject(arr)
| 0-84 | ||||||||||||
312 | QV4::ArgumentsObject *a = arr->cast<ArgumentsObject>(); | - | ||||||||||||
313 | int l = qMin(len, (uint)a->d()->context->argc()); | - | ||||||||||||
314 | memcpy(arguments, a->d()->context->args(), l*sizeof(Value)); | - | ||||||||||||
315 | for (quint32 i = l; i < len
| 0-14 | ||||||||||||
316 | arguments[i] = Primitive::undefinedValue(); never executed: arguments[i] = Primitive::undefinedValue(); | 0 | ||||||||||||
317 | } executed 14 times by 1 test: else if (arr->arrayType() == Heap::ArrayData::Simpleend of block Executed by:
| 0-84 | ||||||||||||
318 | auto sad = static_cast<Heap::SimpleArrayData *>(arr->arrayData()); | - | ||||||||||||
319 | uint alen = sad
| 6-78 | ||||||||||||
320 | if (alen > len
| 0-84 | ||||||||||||
321 | alen = len; never executed: alen = len; | 0 | ||||||||||||
322 | for (uint i = 0; i < alen
| 84-226 | ||||||||||||
323 | arguments[i] = sad->data(i); executed 226 times by 1 test: arguments[i] = sad->data(i); Executed by:
| 226 | ||||||||||||
324 | for (quint32 i = alen; i < len
| 84-406 | ||||||||||||
325 | arguments[i] = Primitive::undefinedValue(); executed 406 times by 1 test: arguments[i] = Primitive::undefinedValue(); Executed by:
| 406 | ||||||||||||
326 | } executed 84 times by 1 test: else {end of block Executed by:
| 84 | ||||||||||||
327 | for (quint32 i = 0; i < len
| 0 | ||||||||||||
328 | arguments[i] = arr->get(i); never executed: arguments[i] = arr->get(i); | 0 | ||||||||||||
329 | } never executed: end of block | 0 | ||||||||||||
330 | } | - | ||||||||||||
331 | - | |||||||||||||
332 | return executed 108 times by 2 tests: f->call(thisObject, arguments, len);return f->call(thisObject, arguments, len); Executed by:
executed 108 times by 2 tests: return f->call(thisObject, arguments, len); Executed by:
| 108 | ||||||||||||
333 | } | - | ||||||||||||
334 | - | |||||||||||||
335 | ReturnedValue FunctionPrototype::method_call(const QV4::FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
336 | { | - | ||||||||||||
337 | if (!thisObject->isFunctionObject()
| 44-28216 | ||||||||||||
338 | return executed 44 times by 1 test: b->engine()->throwTypeError();return b->engine()->throwTypeError(); Executed by:
executed 44 times by 1 test: return b->engine()->throwTypeError(); Executed by:
| 44 | ||||||||||||
339 | - | |||||||||||||
340 | const FunctionObject *f = static_cast<const FunctionObject *>(thisObject); | - | ||||||||||||
341 | - | |||||||||||||
342 | thisObject = argc
| 34-28183 | ||||||||||||
343 | if (argc
| 34-28207 | ||||||||||||
344 | ++argv; | - | ||||||||||||
345 | --argc; | - | ||||||||||||
346 | } executed 28196 times by 3 tests: end of block Executed by:
| 28196 | ||||||||||||
347 | return executed 28237 times by 3 tests: f->call(thisObject, argv, argc);return f->call(thisObject, argv, argc); Executed by:
executed 28237 times by 3 tests: return f->call(thisObject, argv, argc); Executed by:
| 28237 | ||||||||||||
348 | } | - | ||||||||||||
349 | - | |||||||||||||
350 | ReturnedValue FunctionPrototype::method_bind(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
351 | { | - | ||||||||||||
352 | QV4::Scope scope(b); | - | ||||||||||||
353 | ScopedFunctionObject target(scope, thisObject); | - | ||||||||||||
354 | if (!target
| 0-571 | ||||||||||||
355 | return executed 55 times by 1 test: scope.engine->throwTypeError();return scope.engine->throwTypeError(); Executed by:
executed 55 times by 1 test: return scope.engine->throwTypeError(); Executed by:
| 55 | ||||||||||||
356 | - | |||||||||||||
357 | ScopedValue boundThis(scope, argc ? argv[0] : Primitive::undefinedValue()); | - | ||||||||||||
358 | Scoped<MemberData> boundArgs(scope, (Heap::MemberData *)nullptr); | - | ||||||||||||
359 | - | |||||||||||||
360 | int nArgs = (
| 114-451 | ||||||||||||
361 | if (target->isBoundFunction()
| 22-543 | ||||||||||||
362 | BoundFunction *bound = static_cast<BoundFunction *>(target.getPointer()); | - | ||||||||||||
363 | Scoped<MemberData> oldArgs(scope, bound->boundArgs()); | - | ||||||||||||
364 | boundThis = bound->boundThis(); | - | ||||||||||||
365 | int oldSize = !oldArgs
| 2-20 | ||||||||||||
366 | if (oldSize + nArgs
| 2-20 | ||||||||||||
367 | boundArgs = MemberData::allocate(scope.engine, oldSize + nArgs); | - | ||||||||||||
368 | boundArgs->d()->values.size = oldSize + nArgs; | - | ||||||||||||
369 | for (uint i = 0; i < static_cast<uint>(oldSize)
| 2 | ||||||||||||
370 | boundArgs->set(scope.engine, i, oldArgs->data()[i]); executed 2 times by 1 test: boundArgs->set(scope.engine, i, oldArgs->data()[i]); Executed by:
| 2 | ||||||||||||
371 | for (uint i = 0; i < static_cast<uint>(nArgs)
| 2 | ||||||||||||
372 | boundArgs->set(scope.engine, oldSize + i, argv[i + 1]); executed 2 times by 1 test: boundArgs->set(scope.engine, oldSize + i, argv[i + 1]); Executed by:
| 2 | ||||||||||||
373 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
374 | target = bound->target(); | - | ||||||||||||
375 | } executed 22 times by 2 tests: else if (nArgsend of block Executed by:
| 22-461 | ||||||||||||
376 | boundArgs = MemberData::allocate(scope.engine, nArgs); | - | ||||||||||||
377 | boundArgs->d()->values.size = nArgs; | - | ||||||||||||
378 | for (uint i = 0, ei = static_cast<uint>(nArgs); i < ei
| 90-136 | ||||||||||||
379 | boundArgs->set(scope.engine, i, argv[i + 1]); executed 136 times by 3 tests: boundArgs->set(scope.engine, i, argv[i + 1]); Executed by:
| 136 | ||||||||||||
380 | } executed 90 times by 3 tests: end of block Executed by:
| 90 | ||||||||||||
381 | - | |||||||||||||
382 | ScopedContext ctx(scope, target->scope()); | - | ||||||||||||
383 | Heap::BoundFunction *bound = BoundFunction::create(ctx, target, boundThis, boundArgs); | - | ||||||||||||
384 | bound->setFunction(target->function()); | - | ||||||||||||
385 | return executed 574 times by 3 tests: bound->asReturnedValue();return bound->asReturnedValue(); Executed by:
executed 574 times by 3 tests: return bound->asReturnedValue(); Executed by:
| 574 | ||||||||||||
386 | } | - | ||||||||||||
387 | - | |||||||||||||
388 | ReturnedValue FunctionPrototype::method_hasInstance(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
389 | { | - | ||||||||||||
390 | if (!argc
| 8-4235391 | ||||||||||||
391 | return executed 8 times by 1 test: false;return false; Executed by:
executed 8 times by 1 test: return false; Executed by:
| 8 | ||||||||||||
392 | const Object *o = thisObject->as<Object>(); | - | ||||||||||||
393 | if (!o
| 0-4250958 | ||||||||||||
394 | return never executed: f->engine()->throwTypeError();return f->engine()->throwTypeError(); never executed: return f->engine()->throwTypeError(); | 0 | ||||||||||||
395 | - | |||||||||||||
396 | return executed 4247077 times by 11 tests: Object::virtualInstanceOf(o, argv[0]);return Object::virtualInstanceOf(o, argv[0]); Executed by:
executed 4247077 times by 11 tests: return Object::virtualInstanceOf(o, argv[0]); Executed by:
| 4247077 | ||||||||||||
397 | } | - | ||||||||||||
398 | - | |||||||||||||
399 | const QV4::VTable ScriptFunction::static_vtbl = { (std::is_same<ScriptFunction::SuperClass, Object>::value) ? nullptr : &ScriptFunction::SuperClass::static_vtbl, (sizeof(ScriptFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(ScriptFunction::Data) + (ScriptFunction::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(ScriptFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), ScriptFunction::IsExecutionContext, ScriptFunction::IsString, ScriptFunction::IsObject, ScriptFunction::IsFunctionObject, ScriptFunction::IsErrorObject, ScriptFunction::IsArrayData, ScriptFunction::IsStringOrSymbol, ScriptFunction::MyType, { 0, 0, 0, 0 }, "ScriptFunction", ScriptFunction::virtualDestroy, ScriptFunction::Data::markObjects, ScriptFunction::virtualIsEqualTo, ScriptFunction::virtualGet, ScriptFunction::virtualPut, ScriptFunction::virtualDeleteProperty, ScriptFunction::virtualHasProperty, ScriptFunction::virtualGetOwnProperty, ScriptFunction::virtualDefineOwnProperty, ScriptFunction::virtualIsExtensible, ScriptFunction::virtualPreventExtensions, ScriptFunction::virtualGetPrototypeOf, ScriptFunction::virtualSetPrototypeOf, ScriptFunction::virtualGetLength, ScriptFunction::virtualAdvanceIterator, ScriptFunction::virtualInstanceOf, ScriptFunction::virtualCall, ScriptFunction::virtualCallAsConstructor, }; | - | ||||||||||||
400 | - | |||||||||||||
401 | ReturnedValue ScriptFunction::virtualCallAsConstructor(const FunctionObject *fo, const Value *argv, int argc, const Value *newTarget) | - | ||||||||||||
402 | { | - | ||||||||||||
403 | ExecutionEngine *v4 = fo->engine(); | - | ||||||||||||
404 | const ScriptFunction *f = static_cast<const ScriptFunction *>(fo); | - | ||||||||||||
405 | ((newTarget->isFunctionObject()) ? static_cast<void>(0) : qt_assert("newTarget->isFunctionObject()", __FILE__, 465)); | - | ||||||||||||
406 | const FunctionObject *nt = static_cast<const FunctionObject *>(newTarget); | - | ||||||||||||
407 | - | |||||||||||||
408 | Scope scope(v4); | - | ||||||||||||
409 | Scoped<InternalClass> ic(scope); | - | ||||||||||||
410 | if (nt->d() == f->d()
| 208-14395 | ||||||||||||
411 | ic = f->classForConstructor(); | - | ||||||||||||
412 | } executed 14414 times by 3 tests: else {end of block Executed by:
| 14414 | ||||||||||||
413 | const Object *o = nt->d()->protoProperty(); | - | ||||||||||||
414 | ic = scope.engine->internalClasses(EngineBase::Class_Object); | - | ||||||||||||
415 | if (o
| 0-208 | ||||||||||||
416 | ic = ic->changePrototype(o->d()); executed 208 times by 1 test: ic = ic->changePrototype(o->d()); Executed by:
| 208 | ||||||||||||
417 | } executed 208 times by 1 test: end of block Executed by:
| 208 | ||||||||||||
418 | ScopedValue thisObject(scope, v4->memoryManager->allocObject<Object>(ic)); | - | ||||||||||||
419 | - | |||||||||||||
420 | CppStackFrame frame; | - | ||||||||||||
421 | frame.init(v4, f->function(), argv, argc); | - | ||||||||||||
422 | frame.setupJSFrame(v4->jsStackTop, *f, f->scope(), | - | ||||||||||||
423 | thisObject, | - | ||||||||||||
424 | newTarget ? *newTarget : Primitive::undefinedValue()); | - | ||||||||||||
425 | - | |||||||||||||
426 | frame.push(); | - | ||||||||||||
427 | v4->jsStackTop += frame.requiredJSStackFrameSize(); | - | ||||||||||||
428 | - | |||||||||||||
429 | ReturnedValue result = Moth::VME::exec(&frame, v4); | - | ||||||||||||
430 | - | |||||||||||||
431 | frame.pop(); | - | ||||||||||||
432 | - | |||||||||||||
433 | if (__builtin_expect(!!(v4->hasException), false)
| 66-14561 | ||||||||||||
434 | return executed 66 times by 2 tests: Encode::undefined();return Encode::undefined(); Executed by:
executed 66 times by 2 tests: return Encode::undefined(); Executed by:
| 66 | ||||||||||||
435 | else if (!Value::fromReturnedValue(result).isObject()
| 184-14372 | ||||||||||||
436 | return executed 14376 times by 3 tests: thisObject->asReturnedValue();return thisObject->asReturnedValue(); Executed by:
executed 14376 times by 3 tests: return thisObject->asReturnedValue(); Executed by:
| 14376 | ||||||||||||
437 | return executed 184 times by 2 tests: result;return result; Executed by:
executed 184 times by 2 tests: return result; Executed by:
| 184 | ||||||||||||
438 | } | - | ||||||||||||
439 | - | |||||||||||||
440 | ReturnedValue ScriptFunction::virtualCall(const FunctionObject *fo, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
441 | { | - | ||||||||||||
442 | ExecutionEngine *engine = fo->engine(); | - | ||||||||||||
443 | CppStackFrame frame; | - | ||||||||||||
444 | frame.init(engine, fo->function(), argv, argc); | - | ||||||||||||
445 | frame.setupJSFrame(engine->jsStackTop, *fo, fo->scope(), | - | ||||||||||||
446 | thisObject ? *thisObject : Primitive::undefinedValue(), | - | ||||||||||||
447 | Primitive::undefinedValue()); | - | ||||||||||||
448 | - | |||||||||||||
449 | frame.push(); | - | ||||||||||||
450 | engine->jsStackTop += frame.requiredJSStackFrameSize(); | - | ||||||||||||
451 | - | |||||||||||||
452 | ReturnedValue result = Moth::VME::exec(&frame, engine); | - | ||||||||||||
453 | - | |||||||||||||
454 | frame.pop(); | - | ||||||||||||
455 | - | |||||||||||||
456 | return executed 14908599 times by 59 tests: result;return result; Executed by:
executed 14908599 times by 59 tests: return result; Executed by:
| 14908599 | ||||||||||||
457 | } | - | ||||||||||||
458 | - | |||||||||||||
459 | void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function) | - | ||||||||||||
460 | { | - | ||||||||||||
461 | FunctionObject::init(); | - | ||||||||||||
462 | this->scope.set(scope->engine(), scope->d()); | - | ||||||||||||
463 | - | |||||||||||||
464 | setFunction(function); | - | ||||||||||||
465 | ((function) ? static_cast<void>(0) : qt_assert("function", __FILE__, 525)); | - | ||||||||||||
466 | - | |||||||||||||
467 | Scope s(scope); | - | ||||||||||||
468 | ScopedFunctionObject f(s, this); | - | ||||||||||||
469 | - | |||||||||||||
470 | ScopedString name(s, function->name()); | - | ||||||||||||
471 | if (name
| 0-1522497 | ||||||||||||
472 | f->setName(name); executed 1522416 times by 62 tests: f->setName(name); Executed by:
| 1522416 | ||||||||||||
473 | f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_Prototype, Heap::FunctionObject::Index_ProtoConstructor); | - | ||||||||||||
474 | - | |||||||||||||
475 | ((internalClass && internalClass->find(s.engine->id_length()->propertyKey()) == Index_Length) ? static_cast<void>(0) : qt_assert("internalClass && internalClass->find(s.engine->id_length()->propertyKey()) == Index_Length", __FILE__, 535)); | - | ||||||||||||
476 | setProperty(s.engine, Index_Length, Primitive::fromInt32(int(function->compiledFunction->length))); | - | ||||||||||||
477 | } executed 1523569 times by 62 tests: end of block Executed by:
| 1523569 | ||||||||||||
478 | - | |||||||||||||
479 | Heap::InternalClass *ScriptFunction::classForConstructor() const | - | ||||||||||||
480 | { | - | ||||||||||||
481 | const Object *o = d()->protoProperty(); | - | ||||||||||||
482 | if (d()->cachedClassForConstructor && d()->cachedClassForConstructor->prototype == o->d()
| 4-3208 | ||||||||||||
483 | return executed 3208 times by 2 tests: d()->cachedClassForConstructor;return d()->cachedClassForConstructor; Executed by:
executed 3208 times by 2 tests: return d()->cachedClassForConstructor; Executed by:
| 3208 | ||||||||||||
484 | - | |||||||||||||
485 | Scope scope(engine()); | - | ||||||||||||
486 | Scoped<InternalClass> ic(scope, engine()->internalClasses(EngineBase::Class_Object)); | - | ||||||||||||
487 | if (o
| 8-11200 | ||||||||||||
488 | ic = ic->changePrototype(o->d()); executed 11200 times by 3 tests: ic = ic->changePrototype(o->d()); Executed by:
| 11200 | ||||||||||||
489 | d()->cachedClassForConstructor.set(scope.engine, ic->d()); | - | ||||||||||||
490 | - | |||||||||||||
491 | return executed 11227 times by 3 tests: ic->d();return ic->d(); Executed by:
executed 11227 times by 3 tests: return ic->d(); Executed by:
| 11227 | ||||||||||||
492 | } | - | ||||||||||||
493 | - | |||||||||||||
494 | const QV4::VTable ConstructorFunction::static_vtbl = { (std::is_same<ConstructorFunction::SuperClass, Object>::value) ? nullptr : &ConstructorFunction::SuperClass::static_vtbl, (sizeof(ConstructorFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(ConstructorFunction::Data) + (ConstructorFunction::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(ConstructorFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), ConstructorFunction::IsExecutionContext, ConstructorFunction::IsString, ConstructorFunction::IsObject, ConstructorFunction::IsFunctionObject, ConstructorFunction::IsErrorObject, ConstructorFunction::IsArrayData, ConstructorFunction::IsStringOrSymbol, ConstructorFunction::MyType, { 0, 0, 0, 0 }, "ConstructorFunction", ConstructorFunction::virtualDestroy, ConstructorFunction::Data::markObjects, ConstructorFunction::virtualIsEqualTo, ConstructorFunction::virtualGet, ConstructorFunction::virtualPut, ConstructorFunction::virtualDeleteProperty, ConstructorFunction::virtualHasProperty, ConstructorFunction::virtualGetOwnProperty, ConstructorFunction::virtualDefineOwnProperty, ConstructorFunction::virtualIsExtensible, ConstructorFunction::virtualPreventExtensions, ConstructorFunction::virtualGetPrototypeOf, ConstructorFunction::virtualSetPrototypeOf, ConstructorFunction::virtualGetLength, ConstructorFunction::virtualAdvanceIterator, ConstructorFunction::virtualInstanceOf, ConstructorFunction::virtualCall, ConstructorFunction::virtualCallAsConstructor, }; | - | ||||||||||||
495 | - | |||||||||||||
496 | ReturnedValue ConstructorFunction::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget) | - | ||||||||||||
497 | { | - | ||||||||||||
498 | const ConstructorFunction *c = static_cast<const ConstructorFunction *>(f); | - | ||||||||||||
499 | if (!c->d()->isDerivedConstructor
| 224-376 | ||||||||||||
500 | return executed 224 times by 1 test: ScriptFunction::virtualCallAsConstructor(f, argv, argc, newTarget);return ScriptFunction::virtualCallAsConstructor(f, argv, argc, newTarget); Executed by:
executed 224 times by 1 test: return ScriptFunction::virtualCallAsConstructor(f, argv, argc, newTarget); Executed by:
| 224 | ||||||||||||
501 | - | |||||||||||||
502 | ExecutionEngine *v4 = f->engine(); | - | ||||||||||||
503 | - | |||||||||||||
504 | CppStackFrame frame; | - | ||||||||||||
505 | frame.init(v4, f->function(), argv, argc); | - | ||||||||||||
506 | frame.setupJSFrame(v4->jsStackTop, *f, f->scope(), | - | ||||||||||||
507 | Primitive::undefinedValue(), | - | ||||||||||||
508 | newTarget ? *newTarget : Primitive::undefinedValue()); | - | ||||||||||||
509 | - | |||||||||||||
510 | frame.push(); | - | ||||||||||||
511 | v4->jsStackTop += frame.requiredJSStackFrameSize(); | - | ||||||||||||
512 | - | |||||||||||||
513 | ReturnedValue result = Moth::VME::exec(&frame, v4); | - | ||||||||||||
514 | - | |||||||||||||
515 | frame.pop(); | - | ||||||||||||
516 | - | |||||||||||||
517 | if (__builtin_expect(!!(v4->hasException), false)
| 88-287 | ||||||||||||
518 | return executed 88 times by 1 test: Encode::undefined();return Encode::undefined(); Executed by:
executed 88 times by 1 test: return Encode::undefined(); Executed by:
| 88 | ||||||||||||
519 | else if (Value::fromReturnedValue(result).isObject()
| 12-275 | ||||||||||||
520 | return executed 12 times by 1 test: result;return result; Executed by:
executed 12 times by 1 test: return result; Executed by:
| 12 | ||||||||||||
521 | else if (!Value::fromReturnedValue(result).isUndefined()
| 28-248 | ||||||||||||
522 | return executed 28 times by 1 test: v4->throwTypeError();return v4->throwTypeError(); Executed by:
executed 28 times by 1 test: return v4->throwTypeError(); Executed by:
| 28 | ||||||||||||
523 | return executed 248 times by 1 test: frame.jsFrame->thisObject.asReturnedValue();return frame.jsFrame->thisObject.asReturnedValue(); Executed by:
executed 248 times by 1 test: return frame.jsFrame->thisObject.asReturnedValue(); Executed by:
| 248 | ||||||||||||
524 | } | - | ||||||||||||
525 | - | |||||||||||||
526 | ReturnedValue ConstructorFunction::virtualCall(const FunctionObject *f, const Value *, const Value *, int) | - | ||||||||||||
527 | { | - | ||||||||||||
528 | return executed 16 times by 1 test: f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Cannot call a class constructor without |new|")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Cannot call a class constructor without |new|" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Cannot call a class constructor without |new|")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Cannot call a class constructor without |new|" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); Executed by:
executed 16 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 16 times by 1 test: }()));return qstring_literal_temp; Executed by:
executed 16 times by 1 test: return f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Cannot call a class constructor without |new|")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Cannot call a class constructor without |new|" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); Executed by:
| 16 | ||||||||||||
529 | } | - | ||||||||||||
530 | - | |||||||||||||
531 | const QV4::VTable MemberFunction::static_vtbl = { (std::is_same<MemberFunction::SuperClass, Object>::value) ? nullptr : &MemberFunction::SuperClass::static_vtbl, (sizeof(MemberFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(MemberFunction::Data) + (MemberFunction::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(MemberFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), MemberFunction::IsExecutionContext, MemberFunction::IsString, MemberFunction::IsObject, MemberFunction::IsFunctionObject, MemberFunction::IsErrorObject, MemberFunction::IsArrayData, MemberFunction::IsStringOrSymbol, MemberFunction::MyType, { 0, 0, 0, 0 }, "MemberFunction", MemberFunction::virtualDestroy, MemberFunction::Data::markObjects, MemberFunction::virtualIsEqualTo, MemberFunction::virtualGet, MemberFunction::virtualPut, MemberFunction::virtualDeleteProperty, MemberFunction::virtualHasProperty, MemberFunction::virtualGetOwnProperty, MemberFunction::virtualDefineOwnProperty, MemberFunction::virtualIsExtensible, MemberFunction::virtualPreventExtensions, MemberFunction::virtualGetPrototypeOf, MemberFunction::virtualSetPrototypeOf, MemberFunction::virtualGetLength, MemberFunction::virtualAdvanceIterator, MemberFunction::virtualInstanceOf, MemberFunction::virtualCall, MemberFunction::virtualCallAsConstructor, }; | - | ||||||||||||
532 | - | |||||||||||||
533 | ReturnedValue MemberFunction::virtualCallAsConstructor(const FunctionObject *f, const Value *, int, const Value *) | - | ||||||||||||
534 | { | - | ||||||||||||
535 | return never executed: f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Function is not a constructor.")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Function is not a constructor." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Function is not a constructor.")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Function is not a constructor." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; never executed: return f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Function is not a constructor.")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Function is not a constructor." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); | 0 | ||||||||||||
536 | } | - | ||||||||||||
537 | - | |||||||||||||
538 | const QV4::VTable DefaultClassConstructorFunction::static_vtbl = { (std::is_same<DefaultClassConstructorFunction::SuperClass, Object>::value) ? nullptr : &DefaultClassConstructorFunction::SuperClass::static_vtbl, (sizeof(DefaultClassConstructorFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(DefaultClassConstructorFunction::Data) + (DefaultClassConstructorFunction::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(DefaultClassConstructorFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), DefaultClassConstructorFunction::IsExecutionContext, DefaultClassConstructorFunction::IsString, DefaultClassConstructorFunction::IsObject, DefaultClassConstructorFunction::IsFunctionObject, DefaultClassConstructorFunction::IsErrorObject, DefaultClassConstructorFunction::IsArrayData, DefaultClassConstructorFunction::IsStringOrSymbol, DefaultClassConstructorFunction::MyType, { 0, 0, 0, 0 }, "DefaultClassConstructorFunction", DefaultClassConstructorFunction::virtualDestroy, DefaultClassConstructorFunction::Data::markObjects, DefaultClassConstructorFunction::virtualIsEqualTo, DefaultClassConstructorFunction::virtualGet, DefaultClassConstructorFunction::virtualPut, DefaultClassConstructorFunction::virtualDeleteProperty, DefaultClassConstructorFunction::virtualHasProperty, DefaultClassConstructorFunction::virtualGetOwnProperty, DefaultClassConstructorFunction::virtualDefineOwnProperty, DefaultClassConstructorFunction::virtualIsExtensible, DefaultClassConstructorFunction::virtualPreventExtensions, DefaultClassConstructorFunction::virtualGetPrototypeOf, DefaultClassConstructorFunction::virtualSetPrototypeOf, DefaultClassConstructorFunction::virtualGetLength, DefaultClassConstructorFunction::virtualAdvanceIterator, DefaultClassConstructorFunction::virtualInstanceOf, DefaultClassConstructorFunction::virtualCall, DefaultClassConstructorFunction::virtualCallAsConstructor, }; | - | ||||||||||||
539 | - | |||||||||||||
540 | ReturnedValue DefaultClassConstructorFunction::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget) | - | ||||||||||||
541 | { | - | ||||||||||||
542 | const DefaultClassConstructorFunction *c = static_cast<const DefaultClassConstructorFunction *>(f); | - | ||||||||||||
543 | ExecutionEngine *v4 = f->engine(); | - | ||||||||||||
544 | - | |||||||||||||
545 | Scope scope(v4); | - | ||||||||||||
546 | - | |||||||||||||
547 | if (!c->d()->isDerivedConstructor
| 359-2739 | ||||||||||||
548 | ScopedObject proto(scope, static_cast<const Object *>(newTarget) ->get(scope.engine->id_prototype())); | - | ||||||||||||
549 | ScopedObject c(scope, scope.engine->newObject()); | - | ||||||||||||
550 | c->setPrototypeUnchecked(proto); | - | ||||||||||||
551 | return executed 2762 times by 1 test: c->asReturnedValue();return c->asReturnedValue(); Executed by:
executed 2762 times by 1 test: return c->asReturnedValue(); Executed by:
| 2762 | ||||||||||||
552 | } | - | ||||||||||||
553 | - | |||||||||||||
554 | ScopedFunctionObject super(scope, f->getPrototypeOf()); | - | ||||||||||||
555 | ((super->isFunctionObject()) ? static_cast<void>(0) : qt_assert("super->isFunctionObject()", __FILE__, 615)); | - | ||||||||||||
556 | - | |||||||||||||
557 | CppStackFrame frame; | - | ||||||||||||
558 | frame.init(v4, nullptr, argv, argc); | - | ||||||||||||
559 | frame.setupJSFrame(v4->jsStackTop, *f, f->scope(), | - | ||||||||||||
560 | Primitive::undefinedValue(), | - | ||||||||||||
561 | newTarget ? *newTarget : Primitive::undefinedValue(), argc, argc); | - | ||||||||||||
562 | - | |||||||||||||
563 | frame.push(); | - | ||||||||||||
564 | v4->jsStackTop += frame.requiredJSStackFrameSize(argc); | - | ||||||||||||
565 | - | |||||||||||||
566 | - | |||||||||||||
567 | ReturnedValue result = super->callAsConstructor(argv, argc, newTarget); | - | ||||||||||||
568 | - | |||||||||||||
569 | frame.pop(); | - | ||||||||||||
570 | - | |||||||||||||
571 | if (__builtin_expect(!!(v4->hasException), false)
| 12-347 | ||||||||||||
572 | return executed 12 times by 1 test: Encode::undefined();return Encode::undefined(); Executed by:
executed 12 times by 1 test: return Encode::undefined(); Executed by:
| 12 | ||||||||||||
573 | else if (Value::fromReturnedValue(result).isObject()
| 0-348 | ||||||||||||
574 | return executed 348 times by 1 test: result;return result; Executed by:
executed 348 times by 1 test: return result; Executed by:
| 348 | ||||||||||||
575 | else if (!Value::fromReturnedValue(result).isUndefined()
| 0 | ||||||||||||
576 | return never executed: v4->throwTypeError();return v4->throwTypeError(); never executed: return v4->throwTypeError(); | 0 | ||||||||||||
577 | return never executed: frame.jsFrame->thisObject.asReturnedValue();return frame.jsFrame->thisObject.asReturnedValue(); never executed: return frame.jsFrame->thisObject.asReturnedValue(); | 0 | ||||||||||||
578 | } | - | ||||||||||||
579 | - | |||||||||||||
580 | ReturnedValue DefaultClassConstructorFunction::virtualCall(const FunctionObject *f, const Value *, const Value *, int) | - | ||||||||||||
581 | { | - | ||||||||||||
582 | return executed 20 times by 1 test: f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Cannot call a class constructor without |new|")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Cannot call a class constructor without |new|" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Cannot call a class constructor without |new|")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Cannot call a class constructor without |new|" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); Executed by:
executed 20 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 20 times by 1 test: }()));return qstring_literal_temp; Executed by:
executed 20 times by 1 test: return f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Cannot call a class constructor without |new|")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Cannot call a class constructor without |new|" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); Executed by:
| 20 | ||||||||||||
583 | } | - | ||||||||||||
584 | - | |||||||||||||
585 | const QV4::VTable IndexedBuiltinFunction::static_vtbl = { (std::is_same<IndexedBuiltinFunction::SuperClass, Object>::value) ? nullptr : &IndexedBuiltinFunction::SuperClass::static_vtbl, (sizeof(IndexedBuiltinFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(IndexedBuiltinFunction::Data) + (IndexedBuiltinFunction::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(IndexedBuiltinFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), IndexedBuiltinFunction::IsExecutionContext, IndexedBuiltinFunction::IsString, IndexedBuiltinFunction::IsObject, IndexedBuiltinFunction::IsFunctionObject, IndexedBuiltinFunction::IsErrorObject, IndexedBuiltinFunction::IsArrayData, IndexedBuiltinFunction::IsStringOrSymbol, IndexedBuiltinFunction::MyType, { 0, 0, 0, 0 }, "IndexedBuiltinFunction", IndexedBuiltinFunction::virtualDestroy, IndexedBuiltinFunction::Data::markObjects, IndexedBuiltinFunction::virtualIsEqualTo, IndexedBuiltinFunction::virtualGet, IndexedBuiltinFunction::virtualPut, IndexedBuiltinFunction::virtualDeleteProperty, IndexedBuiltinFunction::virtualHasProperty, IndexedBuiltinFunction::virtualGetOwnProperty, IndexedBuiltinFunction::virtualDefineOwnProperty, IndexedBuiltinFunction::virtualIsExtensible, IndexedBuiltinFunction::virtualPreventExtensions, IndexedBuiltinFunction::virtualGetPrototypeOf, IndexedBuiltinFunction::virtualSetPrototypeOf, IndexedBuiltinFunction::virtualGetLength, IndexedBuiltinFunction::virtualAdvanceIterator, IndexedBuiltinFunction::virtualInstanceOf, IndexedBuiltinFunction::virtualCall, IndexedBuiltinFunction::virtualCallAsConstructor, }; | - | ||||||||||||
586 | - | |||||||||||||
587 | const QV4::VTable BoundFunction::static_vtbl = { (std::is_same<BoundFunction::SuperClass, Object>::value) ? nullptr : &BoundFunction::SuperClass::static_vtbl, (sizeof(BoundFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(BoundFunction::Data) + (BoundFunction::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(BoundFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), BoundFunction::IsExecutionContext, BoundFunction::IsString, BoundFunction::IsObject, BoundFunction::IsFunctionObject, BoundFunction::IsErrorObject, BoundFunction::IsArrayData, BoundFunction::IsStringOrSymbol, BoundFunction::MyType, { 0, 0, 0, 0 }, "BoundFunction", BoundFunction::virtualDestroy, BoundFunction::Data::markObjects, BoundFunction::virtualIsEqualTo, BoundFunction::virtualGet, BoundFunction::virtualPut, BoundFunction::virtualDeleteProperty, BoundFunction::virtualHasProperty, BoundFunction::virtualGetOwnProperty, BoundFunction::virtualDefineOwnProperty, BoundFunction::virtualIsExtensible, BoundFunction::virtualPreventExtensions, BoundFunction::virtualGetPrototypeOf, BoundFunction::virtualSetPrototypeOf, BoundFunction::virtualGetLength, BoundFunction::virtualAdvanceIterator, BoundFunction::virtualInstanceOf, BoundFunction::virtualCall, BoundFunction::virtualCallAsConstructor, }; | - | ||||||||||||
588 | - | |||||||||||||
589 | void Heap::BoundFunction::init(QV4::ExecutionContext *scope, QV4::FunctionObject *target, | - | ||||||||||||
590 | const Value &boundThis, QV4::MemberData *boundArgs) | - | ||||||||||||
591 | { | - | ||||||||||||
592 | Scope s(scope); | - | ||||||||||||
593 | Heap::FunctionObject::init(scope, ([]() noexcept -> QString { enum { Size = sizeof(u"" "__bound function__")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "__bound function__" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 567 times by 3 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 567 times by 3 tests: }()));return qstring_literal_temp; Executed by:
| 567 | ||||||||||||
594 | this->target.set(s.engine, target->d()); | - | ||||||||||||
595 | this->boundArgs.set(s.engine, boundArgs ? boundArgs->d() : nullptr); | - | ||||||||||||
596 | this->boundThis.set(scope->engine(), boundThis); | - | ||||||||||||
597 | - | |||||||||||||
598 | ScopedObject f(s, this); | - | ||||||||||||
599 | - | |||||||||||||
600 | ScopedValue l(s, target->get(s.engine->id_length())); | - | ||||||||||||
601 | int len = l->toUInt32(); | - | ||||||||||||
602 | if (boundArgs
| 90-480 | ||||||||||||
603 | len -= boundArgs->size(); executed 90 times by 3 tests: len -= boundArgs->size(); Executed by:
| 90 | ||||||||||||
604 | if (len < 0
| 32-538 | ||||||||||||
605 | len = 0; executed 32 times by 1 test: len = 0; Executed by:
| 32 | ||||||||||||
606 | f->defineReadonlyConfigurableProperty(s.engine->id_length(), Primitive::fromInt32(len)); | - | ||||||||||||
607 | - | |||||||||||||
608 | ScopedProperty pd(s); | - | ||||||||||||
609 | pd->value = s.engine->thrower(); | - | ||||||||||||
610 | pd->set = s.engine->thrower(); | - | ||||||||||||
611 | f->insertMember(s.engine->id_arguments(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); | - | ||||||||||||
612 | f->insertMember(s.engine->id_caller(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); | - | ||||||||||||
613 | } executed 576 times by 3 tests: end of block Executed by:
| 576 | ||||||||||||
614 | - | |||||||||||||
615 | ReturnedValue BoundFunction::virtualCall(const FunctionObject *fo, const Value *, const Value *argv, int argc) | - | ||||||||||||
616 | { | - | ||||||||||||
617 | const BoundFunction *f = static_cast<const BoundFunction *>(fo); | - | ||||||||||||
618 | Scope scope(f->engine()); | - | ||||||||||||
619 | - | |||||||||||||
620 | if (scope.hasException()
| 0-186 | ||||||||||||
621 | return never executed: Encode::undefined();return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||
622 | - | |||||||||||||
623 | Scoped<MemberData> boundArgs(scope, f->boundArgs()); | - | ||||||||||||
624 | ScopedFunctionObject target(scope, f->target()); | - | ||||||||||||
625 | JSCallData jsCallData(scope, (boundArgs ? boundArgs->size() : 0) + argc); | - | ||||||||||||
626 | *jsCallData->thisObject = f->boundThis(); | - | ||||||||||||
627 | Value *argp = jsCallData->args; | - | ||||||||||||
628 | if (boundArgs
| 42-143 | ||||||||||||
629 | memcpy(argp, boundArgs->data(), boundArgs->size()*sizeof(Value)); | - | ||||||||||||
630 | argp += boundArgs->size(); | - | ||||||||||||
631 | } executed 41 times by 2 tests: end of block Executed by:
| 41 | ||||||||||||
632 | memcpy(argp, argv, argc*sizeof(Value)); | - | ||||||||||||
633 | return executed 184 times by 2 tests: target->call(jsCallData);return target->call(jsCallData); Executed by:
executed 184 times by 2 tests: return target->call(jsCallData); Executed by:
| 184 | ||||||||||||
634 | } | - | ||||||||||||
635 | - | |||||||||||||
636 | ReturnedValue BoundFunction::virtualCallAsConstructor(const FunctionObject *fo, const Value *argv, int argc, const Value *) | - | ||||||||||||
637 | { | - | ||||||||||||
638 | const BoundFunction *f = static_cast<const BoundFunction *>(fo); | - | ||||||||||||
639 | Scope scope(f->engine()); | - | ||||||||||||
640 | - | |||||||||||||
641 | if (scope.hasException()
| 0-100 | ||||||||||||
642 | return never executed: Encode::undefined();return Encode::undefined(); never executed: return Encode::undefined(); | 0 | ||||||||||||
643 | - | |||||||||||||
644 | Scoped<MemberData> boundArgs(scope, f->boundArgs()); | - | ||||||||||||
645 | ScopedFunctionObject target(scope, f->target()); | - | ||||||||||||
646 | JSCallData jsCallData(scope, (boundArgs ? boundArgs->size() : 0) + argc); | - | ||||||||||||
647 | Value *argp = jsCallData->args; | - | ||||||||||||
648 | if (boundArgs
| 36-64 | ||||||||||||
649 | memcpy(argp, boundArgs->data(), boundArgs->size()*sizeof(Value)); | - | ||||||||||||
650 | argp += boundArgs->size(); | - | ||||||||||||
651 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||
652 | memcpy(argp, argv, argc*sizeof(Value)); | - | ||||||||||||
653 | return executed 100 times by 1 test: target->callAsConstructor(jsCallData);return target->callAsConstructor(jsCallData); Executed by:
executed 100 times by 1 test: return target->callAsConstructor(jsCallData); Executed by:
| 100 | ||||||||||||
654 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |