OpenCoverage

qv4script.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4script.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 "qv4script_p.h"-
41#include <private/qv4mm_p.h>-
42#include "qv4functionobject_p.h"-
43#include "qv4function_p.h"-
44#include "qv4context_p.h"-
45#include "qv4debugging_p.h"-
46#include "qv4profiling_p.h"-
47#include "qv4scopedvalue_p.h"-
48#include "qv4jscall_p.h"-
49-
50#include <private/qqmljsengine_p.h>-
51#include <private/qqmljslexer_p.h>-
52#include <private/qqmljsparser_p.h>-
53#include <private/qqmljsast_p.h>-
54#include <private/qqmlengine_p.h>-
55#include <private/qv4profiling_p.h>-
56#include <qv4runtimecodegen_p.h>-
57-
58#include <QtCore/QDebug>-
59#include <QtCore/QString>-
60-
61using namespace QV4;-
62-
63Script::Script(ExecutionEngine *v4, QmlContext *qml, const QQmlRefPointer<CompiledData::CompilationUnit> &compilationUnit)-
64 : line(1), column(0), context(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false)-
65 , compilationUnit(compilationUnit), vmFunction(nullptr), parseAsBinding(true)-
66{-
67 if (qml)
qmlDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 250 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlincubator
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmltranslation
  • tst_qqmlvaluetypes
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
  • tst_quicktestmainwithsetup
  • tst_testfiltering
2-250
68 qmlContext.set(v4, *qml);
executed 2 times by 1 test: qmlContext.set(v4, *qml);
Executed by:
  • tst_qmlcachegen
2
69-
70 parsed = true;-
71-
72 vmFunction = compilationUnit ? compilationUnit->linkToEngine(v4) : nullptr;
compilationUnitDescription
TRUEevaluated 252 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlincubator
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmltranslation
  • tst_qqmlvaluetypes
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
  • tst_quicktestmainwithsetup
  • tst_testfiltering
FALSEnever evaluated
0-252
73}
executed 252 times by 13 tests: end of block
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlincubator
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmltranslation
  • tst_qqmlvaluetypes
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
  • tst_quicktestmainwithsetup
  • tst_testfiltering
252
74-
75Script::~Script()-
76{-
77}-
78-
79void Script::parse()-
80{-
81 if (parsed)
parsedDescription
TRUEevaluated 22 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
FALSEevaluated 2818282 times by 31 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlxmlhttprequest
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • ...
22-2818282
82 return;
executed 22 times by 3 tests: return;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickworkerscript
22
83-
84 using namespace QV4::Compiler;-
85-
86 parsed = true;-
87-
88 ExecutionEngine *v4 = context->engine();-
89 Scope valueScope(v4);-
90-
91 Module module(v4->debugger() != nullptr);-
92-
93 if (sourceCode.startsWith(QLatin1String("function("))) {
sourceCode.sta...("function("))Description
TRUEnever evaluated
FALSEevaluated 2817831 times by 31 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlxmlhttprequest
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • ...
0-2817831
94 static const int snippetLength = 70;-
95 qWarning() << "Warning: Using function expressions as statements in scripts is not compliant with the ECMAScript specification:\n"-
96 << (sourceCode.leftRef(snippetLength) + QLatin1String("..."))-
97 << "\nThis will throw a syntax error in Qt 5.12. If you want a function expression, surround it by parentheses.";-
98 }
never executed: end of block
0
99-
100 Engine ee, *engine = &ee;-
101 Lexer lexer(engine);-
102 lexer.setCode(sourceCode, line, parseAsBinding);-
103 Parser parser(engine);-
104-
105 const bool parsed = parser.parseProgram();-
106-
107 const auto diagnosticMessages = parser.diagnosticMessages();-
108 for (const DiagnosticMessage &m : diagnosticMessages) {-
109 if (m.isError()) {
m.isError()Description
TRUEevaluated 4804 times by 7 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlexpression
  • tst_qquickvisualdatamodel
  • tst_qquickworkerscript
FALSEnever evaluated
0-4804
110 valueScope.engine->throwSyntaxError(m.message, sourceFile, m.loc.startLine, m.loc.startColumn);-
111 return;
executed 4782 times by 7 tests: return;
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qjsvalue
  • tst_qqmlecmascript
  • tst_qqmlexpression
  • tst_qquickvisualdatamodel
  • tst_qquickworkerscript
4782
112 } else {-
113 qWarning() << sourceFile << ':' << m.loc.startLine << ':' << m.loc.startColumn-
114 << ": warning: " << m.message;-
115 }
never executed: end of block
0
116 }-
117-
118 if (parsed) {
parsedDescription
TRUEevaluated 2813723 times by 31 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlxmlhttprequest
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • ...
FALSEevaluated 316 times by 1 test
Evaluated by:
  • tst_ecmascripttests
316-2813723
119 using namespace AST;-
120 Program *program = AST::cast<Program *>(parser.rootNode());-
121 if (!program) {
!programDescription
TRUEevaluated 523002 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
FALSEevaluated 2288635 times by 31 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlxmlhttprequest
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • ...
523002-2288635
122 // if parsing was successful, and we have no program, then-
123 // we're done...:-
124 return;
executed 522737 times by 3 tests: return;
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
522737
125 }-
126-
127 QV4::Compiler::JSUnitGenerator jsGenerator(&module);-
128 RuntimeCodegen cg(v4, &jsGenerator, strictMode);-
129 if (inheritContext)
inheritContextDescription
TRUEevaluated 1677898 times by 29 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlxmlhttprequest
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • tst_qquickstates
  • ...
FALSEevaluated 611236 times by 8 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qquickworkerscript
  • tst_qv4assembler
611236-1677898
130 cg.setUseFastLookups(false);
executed 1677898 times by 29 tests: cg.setUseFastLookups(false);
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlxmlhttprequest
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • tst_qquickstates
  • ...
1677898
131 cg.generateFromProgram(sourceFile, sourceFile, sourceCode, program, &module, contextType);-
132 if (v4->hasException)
v4->hasExceptionDescription
TRUEevaluated 1212 times by 3 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
FALSEevaluated 2286334 times by 31 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlxmlhttprequest
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • ...
1212-2286334
133 return;
executed 1205 times by 3 tests: return;
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
1205
134-
135 compilationUnit = cg.generateCompilationUnit();-
136 vmFunction = compilationUnit->linkToEngine(v4);-
137 }
executed 2288281 times by 31 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlxmlhttprequest
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • ...
2288281
138-
139 if (!vmFunction) {
!vmFunctionDescription
TRUEevaluated 316 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 2288254 times by 31 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlxmlhttprequest
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • ...
316-2288254
140 // ### FIX file/line number-
141 ScopedObject error(valueScope, v4->newSyntaxErrorObject(QStringLiteral("Syntax error")));
executed 316 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_ecmascripttests
316
142 v4->throwError(error);-
143 }
executed 317 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
317
144}
executed 2288656 times by 31 tests: end of block
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlexpression
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlxmlhttprequest
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickgridview
  • tst_qquicklistview
  • tst_qquickpathview
  • tst_qquickpositioners
  • tst_qquickrepeater
  • ...
2288656
145-
146ReturnedValue Script::run(const QV4::Value *thisObject)-
147{-
148 if (!parsed)
!parsedDescription
TRUEevaluated 2374 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qquickworkerscript
FALSEevaluated 118459 times by 26 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmlcontext
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmllistmodelworkerscript
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmltranslation
  • tst_qqmlvaluetypes
  • tst_qqmlxmlhttprequest
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
  • tst_qquickworkerscript
  • tst_quicktestmainwithsetup
  • tst_qv4assembler
  • tst_qv4debugger
  • ...
2374-118459
149 parse();
executed 2374 times by 5 tests: parse();
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qquickworkerscript
2374
150 if (!vmFunction)
!vmFunctionDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qjsengine
  • tst_qqmlecmascript
FALSEevaluated 121381 times by 26 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmlcontext
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmllistmodelworkerscript
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmltranslation
  • tst_qqmlvaluetypes
  • tst_qqmlxmlhttprequest
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
  • tst_qquickworkerscript
  • tst_quicktestmainwithsetup
  • tst_qv4assembler
  • tst_qv4debugger
  • ...
12-121381
151 return Encode::undefined();
executed 12 times by 2 tests: return Encode::undefined();
Executed by:
  • tst_qjsengine
  • tst_qqmlecmascript
12
152-
153 QV4::ExecutionEngine *engine = context->engine();-
154 QV4::Scope valueScope(engine);-
155-
156 if (qmlContext.isUndefined()) {
qmlContext.isUndefined()Description
TRUEevaluated 119455 times by 14 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickworkerscript
  • tst_qv4assembler
  • tst_qv4debugger
FALSEevaluated 1498 times by 17 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmllistmodelworkerscript
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmltranslation
  • tst_qqmlvaluetypes
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
  • tst_qquickworkerscript
  • tst_quicktestmainwithsetup
  • tst_testfiltering
1498-119455
157 TemporaryAssignment<Function*> savedGlobalCode(engine->globalCode, vmFunction);-
158-
159 return vmFunction->call(thisObject ? thisObject : engine->globalObject, nullptr, 0,
executed 119728 times by 14 tests: return vmFunction->call(thisObject ? thisObject : engine->globalObject, nullptr, 0, context);
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickworkerscript
  • tst_qv4assembler
  • tst_qv4debugger
119728
160 context);
executed 119728 times by 14 tests: return vmFunction->call(thisObject ? thisObject : engine->globalObject, nullptr, 0, context);
Executed by:
  • tst_ecmascripttests
  • tst_examples
  • tst_qjsengine
  • tst_qjsonbinding
  • tst_qjsvalue
  • tst_qjsvalueiterator
  • tst_qmlcachegen
  • tst_qqmldebugjs
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlxmlhttprequest
  • tst_qquickworkerscript
  • tst_qv4assembler
  • tst_qv4debugger
119728
161 } else {-
162 Scoped<QmlContext> qml(valueScope, qmlContext.value());-
163 return vmFunction->call(thisObject, nullptr, 0, qml);
executed 1498 times by 17 tests: return vmFunction->call(thisObject, nullptr, 0, qml);
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmllistmodelworkerscript
  • tst_qqmlproperty
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmltranslation
  • tst_qqmlvaluetypes
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
  • tst_qquickworkerscript
  • tst_quicktestmainwithsetup
  • tst_testfiltering
1498
164 }-
165}-
166-
167Function *Script::function()-
168{-
169 if (!parsed)
!parsedDescription
TRUEnever evaluated
FALSEevaluated 1577457 times by 7 tests
Evaluated by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
0-1577457
170 parse();
never executed: parse();
0
171 return vmFunction;
executed 1577049 times by 7 tests: return vmFunction;
Executed by:
  • tst_ecmascripttests
  • tst_qjsengine
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qqmlmetatype
  • tst_qqmlqt
  • tst_qquickworkerscript
1577049
172}-
173-
174QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile(QV4::Compiler::Module *module, QQmlJS::Engine *jsEngine, Compiler::JSUnitGenerator *unitGenerator,-
175 const QString &fileName, const QString &finalUrl, const QString &source,-
176 QList<QQmlError> *reportedErrors)-
177{-
178 using namespace QV4::Compiler;-
179 using namespace QQmlJS::AST;-
180-
181 Lexer lexer(jsEngine);-
182 lexer.setCode(source, /*line*/1, /*qml mode*/false);-
183 Parser parser(jsEngine);-
184-
185 parser.parseProgram();-
186-
187 QList<QQmlError> errors;-
188-
189 const auto diagnosticMessages = parser.diagnosticMessages();-
190 for (const DiagnosticMessage &m : diagnosticMessages) {-
191 if (m.isWarning()) {
m.isWarning()Description
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
0-26
192 qWarning("%s:%d : %s", qPrintable(fileName), m.loc.startLine, qPrintable(m.message));-
193 continue;
never executed: continue;
0
194 }-
195-
196 QQmlError error;-
197 error.setUrl(QUrl(fileName));-
198 error.setDescription(m.message);-
199 error.setLine(m.loc.startLine);-
200 error.setColumn(m.loc.startColumn);-
201 errors << error;-
202 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_qqmlecmascript
26
203-
204 if (!errors.isEmpty()) {
!errors.isEmpty()Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEevaluated 90 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlincubator
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmltranslation
  • tst_qqmlvaluetypes
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
  • tst_quicktestmainwithsetup
  • tst_testfiltering
26-90
205 if (reportedErrors)
reportedErrorsDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
0-26
206 *reportedErrors << errors;
executed 26 times by 1 test: *reportedErrors << errors;
Executed by:
  • tst_qqmlecmascript
26
207 return nullptr;
executed 26 times by 1 test: return nullptr;
Executed by:
  • tst_qqmlecmascript
26
208 }-
209-
210 Program *program = AST::cast<Program *>(parser.rootNode());-
211 if (!program) {
!programDescription
TRUEnever evaluated
FALSEevaluated 90 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlincubator
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmltranslation
  • tst_qqmlvaluetypes
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
  • tst_quicktestmainwithsetup
  • tst_testfiltering
0-90
212 // if parsing was successful, and we have no program, then-
213 // we're done...:-
214 return nullptr;
never executed: return nullptr;
0
215 }-
216-
217 Codegen cg(unitGenerator, /*strict mode*/false);-
218 cg.setUseFastLookups(false);-
219 cg.generateFromProgram(fileName, finalUrl, source, program, module, ContextType::Global);-
220 errors = cg.qmlErrors();-
221 if (!errors.isEmpty()) {
!errors.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 90 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlincubator
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmltranslation
  • tst_qqmlvaluetypes
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
  • tst_quicktestmainwithsetup
  • tst_testfiltering
0-90
222 if (reportedErrors)
reportedErrorsDescription
TRUEnever evaluated
FALSEnever evaluated
0
223 *reportedErrors << errors;
never executed: *reportedErrors << errors;
0
224 return nullptr;
never executed: return nullptr;
0
225 }-
226-
227 return cg.generateCompilationUnit(/*generate unit data*/false);
executed 90 times by 12 tests: return cg.generateCompilationUnit( false);
Executed by:
  • tst_examples
  • tst_qqmlcontext
  • tst_qqmlecmascript
  • tst_qqmlincubator
  • tst_qqmlqt
  • tst_qqmlsqldatabase
  • tst_qqmltranslation
  • tst_qqmlvaluetypes
  • tst_qquickanimationcontroller
  • tst_qquicklayouts
  • tst_quicktestmainwithsetup
  • tst_testfiltering
90
228}-
229-
230Script *Script::createFromFileOrCache(ExecutionEngine *engine, QmlContext *qmlContext, const QString &fileName, const QUrl &originalUrl, QString *error)-
231{-
232 if (error)
errorDescription
TRUEevaluated 1178 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qquickworkerscript
FALSEnever evaluated
0-1178
233 error->clear();
executed 1178 times by 5 tests: error->clear();
Executed by:
  • tst_examples
  • tst_qmlcachegen
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qquickworkerscript
1178
234-
235 QQmlMetaType::CachedUnitLookupError cacheError = QQmlMetaType::CachedUnitLookupError::NoError;-
236 if (const QV4::CompiledData::Unit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(originalUrl, &cacheError)) {
const QV4::Com..., &cacheError)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 1176 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qquickworkerscript
2-1176
237 QQmlRefPointer<QV4::CompiledData::CompilationUnit> jsUnit;-
238 jsUnit.adopt(new QV4::CompiledData::CompilationUnit(cachedUnit));-
239 return new QV4::Script(engine, qmlContext, jsUnit);
executed 2 times by 1 test: return new QV4::Script(engine, qmlContext, jsUnit);
Executed by:
  • tst_qmlcachegen
2
240 }-
241-
242 QFile f(fileName);-
243 if (!f.open(QIODevice::ReadOnly)) {
!f.open(QIODevice::ReadOnly)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEevaluated 1174 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qquickworkerscript
2-1174
244 if (error) {
errorDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
0-2
245 if (cacheError == QQmlMetaType::CachedUnitLookupError::VersionMismatch)
cacheError == ...ersionMismatchDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
0-2
246 *error = originalUrl.toString() + QString::fromUtf8(" was compiled ahead of time with an incompatible version of Qt and the original source code cannot be found. Please recompile");
never executed: *error = originalUrl.toString() + QString::fromUtf8(" was compiled ahead of time with an incompatible version of Qt and the original source code cannot be found. Please recompile");
0
247 else-
248 *error = QString::fromUtf8("Error opening source file %1: %2").arg(originalUrl.toString()).arg(f.errorString());
executed 2 times by 1 test: *error = QString::fromUtf8("Error opening source file %1: %2").arg(originalUrl.toString()).arg(f.errorString());
Executed by:
  • tst_qqmlecmascript
2
249 }-
250 return nullptr;
executed 2 times by 1 test: return nullptr;
Executed by:
  • tst_qqmlecmascript
2
251 }-
252-
253 QByteArray data = f.readAll();-
254 QString sourceCode = QString::fromUtf8(data);-
255 QmlIR::Document::removeScriptPragmas(sourceCode);-
256-
257 auto result = new QV4::Script(engine, qmlContext, sourceCode, originalUrl.toString());-
258 result->parse();-
259 return result;
executed 1174 times by 4 tests: return result;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmllistmodelworkerscript
  • tst_qquickworkerscript
1174
260}-
261-
262QV4::ReturnedValue Script::evaluate(ExecutionEngine *engine, const QString &script, QmlContext *qmlContext)-
263{-
264 QV4::Scope scope(engine);-
265 QV4::Script qmlScript(engine, qmlContext, script, QString());-
266-
267 qmlScript.parse();-
268 QV4::ScopedValue result(scope);-
269 if (!scope.engine->hasException)
!scope.engine->hasExceptionDescription
TRUEnever evaluated
FALSEnever evaluated
0
270 result = qmlScript.run();
never executed: result = qmlScript.run();
0
271 if (scope.engine->hasException) {
scope.engine->hasExceptionDescription
TRUEnever evaluated
FALSEnever evaluated
0
272 scope.engine->catchException();-
273 return Encode::undefined();
never executed: return Encode::undefined();
0
274 }-
275 return result->asReturnedValue();
never executed: return result->asReturnedValue();
0
276}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0