OpenCoverage

qv4function.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4function.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQml module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qv4function_p.h"-
41#include "qv4functionobject_p.h"-
42#include "qv4managed_p.h"-
43#include "qv4string_p.h"-
44#include "qv4value_p.h"-
45#include "qv4engine_p.h"-
46#include "qv4lookup_p.h"-
47#include <private/qv4mm_p.h>-
48#include <private/qv4identifiertable_p.h>-
49#include <assembler/MacroAssemblerCodeRef.h>-
50#include <private/qv4vme_moth_p.h>-
51#include <private/qqmlglobal_p.h>-
52-
53QT_BEGIN_NAMESPACE-
54-
55using namespace QV4;-
56-
57ReturnedValue Function::call(const Value *thisObject, const Value *argv, int argc, const ExecutionContext *context) {-
58 ExecutionEngine *engine = context->engine();-
59 CppStackFrame frame;-
60 frame.init(engine, this, argv, argc);-
61 frame.setupJSFrame(engine->jsStackTop, Primitive::undefinedValue(), context->d(),-
62 thisObject ? *thisObject : Primitive::undefinedValue(),-
63 Primitive::undefinedValue());-
64-
65 frame.push();-
66 engine->jsStackTop += frame.requiredJSStackFrameSize();-
67-
68 ReturnedValue result = Moth::VME::exec(&frame, engine);-
69-
70 frame.pop();-
71-
72 return result;
executed 2773696 times by 134 tests: return result;
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • ...
2773696
73}-
74-
75Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function)-
76 : compiledFunction(function)-
77 , compilationUnit(unit)-
78 , codeData(function->code())-
79 , jittedCode(nullptr)-
80 , codeRef(nullptr)-
81 , hasQmlDependencies(function->hasQmlDependencies())-
82{-
83 Scope scope(engine);-
84 Scoped<InternalClass> ic(scope, engine->internalClasses(EngineBase::Class_CallContext));-
85-
86 // first locals-
87 const quint32_le *localsIndices = compiledFunction->localsTable();-
88 for (quint32 i = 0; i < compiledFunction->nLocals; ++i)
i < compiledFunction->nLocalsDescription
TRUEevaluated 109752 times by 14 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qqmlcomponent
  • tst_qqmlconsole
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmlxmlhttprequest
  • tst_qquickworkerscript
  • tst_qv4debugger
FALSEevaluated 3439129 times by 137 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • ...
109752-3439129
89 ic = ic->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable);
executed 109752 times by 14 tests: ic = ic->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable);
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qqmlcomponent
  • tst_qqmlconsole
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmlxmlhttprequest
  • tst_qquickworkerscript
  • tst_qv4debugger
109752
90-
91 const quint32_le *formalsIndices = compiledFunction->formalsTable();-
92 for (quint32 i = 0; i < compiledFunction->nFormals; ++i)
i < compiledFunction->nFormalsDescription
TRUEevaluated 1764175 times by 56 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qmlcachegen
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlitemmodels
  • tst_qqmllistmodelworkerscript
  • tst_qqmllocale
  • tst_qqmlmetaobject
  • tst_qqmlprofilerservice
  • tst_qqmlqt
  • tst_qqmlsettings
  • tst_qqmlsqldatabase
  • tst_qqmlvaluetypeproviders
  • tst_qqmlvaluetypes
  • tst_qqmlxmlhttprequest
  • tst_qquickaccessible
  • tst_qquickanimatedsprite
  • ...
FALSEevaluated 3440292 times by 137 tests
Evaluated by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • ...
1764175-3440292
93 ic = ic->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[formalsIndices[i]]), Attr_NotConfigurable);
executed 1764265 times by 56 tests: ic = ic->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[formalsIndices[i]]), Attr_NotConfigurable);
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qmlcachegen
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlitemmodels
  • tst_qqmllistmodelworkerscript
  • tst_qqmllocale
  • tst_qqmlmetaobject
  • tst_qqmlprofilerservice
  • tst_qqmlqt
  • tst_qqmlsettings
  • tst_qqmlsqldatabase
  • tst_qqmlvaluetypeproviders
  • tst_qqmlvaluetypes
  • tst_qqmlxmlhttprequest
  • tst_qquickaccessible
  • tst_qquickanimatedsprite
  • ...
1764265
94 internalClass = ic->d();-
95-
96 nFormals = compiledFunction->nFormals;-
97}
executed 3439949 times by 137 tests: end of block
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • ...
3439949
98-
99Function::~Function()-
100{-
101 delete codeRef;-
102}
executed 3442436 times by 137 tests: end of block
Executed by:
  • tst_bindingdependencyapi
  • tst_drawingmodes
  • tst_ecmascripttests
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qmldiskcache
  • tst_qqmlapplicationengine
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlcontext
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmlincubator
  • tst_qqmlinfo
  • tst_qqmlinstantiator
  • ...
3442436
103-
104void Function::updateInternalClass(ExecutionEngine *engine, const QList<QByteArray> &parameters)-
105{-
106 QStringList parameterNames;-
107-
108 // Resolve duplicate parameter names:-
109 for (int i = 0, ei = parameters.count(); i != ei; ++i) {
i != eiDescription
TRUEevaluated 12 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlconnections
  • tst_qquickapplication
FALSEevaluated 10 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlconnections
  • tst_qquickapplication
10-12
110 const QByteArray &param = parameters.at(i);-
111 int duplicate = -1;-
112-
113 for (int j = i - 1; j >= 0; --j) {
j >= 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlconnections
FALSEevaluated 12 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlconnections
  • tst_qquickapplication
2-12
114 const QByteArray &prevParam = parameters.at(j);-
115 if (param == prevParam) {
param == prevParamDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlconnections
0-2
116 duplicate = j;-
117 break;
never executed: break;
0
118 }-
119 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qqmlconnections
2
120-
121 if (duplicate == -1) {
duplicate == -1Description
TRUEevaluated 12 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlconnections
  • tst_qquickapplication
FALSEnever evaluated
0-12
122 parameterNames.append(QString::fromUtf8(param));-
123 } else {
executed 12 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlconnections
  • tst_qquickapplication
12
124 const QString &dup = parameterNames[duplicate];-
125 parameterNames.append(dup);-
126 parameterNames[duplicate] =-
127 QString(0xfffe) + QString::number(duplicate) + dup;-
128 }
never executed: end of block
0
129-
130 }-
131-
132 internalClass = engine->internalClasses(EngineBase::Class_CallContext);-
133-
134 // first locals-
135 const quint32_le *localsIndices = compiledFunction->localsTable();-
136 for (quint32 i = 0; i < compiledFunction->nLocals; ++i)
i < compiledFunction->nLocalsDescription
TRUEnever evaluated
FALSEevaluated 10 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlconnections
  • tst_qquickapplication
0-10
137 internalClass = internalClass->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable);
never executed: internalClass = internalClass->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable);
0
138-
139 Scope scope(engine);-
140 ScopedString arg(scope);-
141 for (const QString &parameterName : parameterNames) {-
142 arg = engine->newIdentifier(parameterName);-
143 internalClass = internalClass->addMember(arg->propertyKey(), Attr_NotConfigurable);-
144 }
executed 12 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlconnections
  • tst_qquickapplication
12
145 nFormals = parameters.size();-
146}
executed 10 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlconnections
  • tst_qquickapplication
10
147-
148QQmlSourceLocation Function::sourceLocation() const-
149{-
150 return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column);
executed 90 times by 8 tests: return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column);
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmlprofilerservice
  • tst_qqmlproperty
  • tst_qqmlpropertymap
  • tst_qqmlvaluetypes
  • tst_qquickpathview
  • tst_qquicktextinput
90
151}-
152-
153QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0