1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QV4SCRIPT_H
#define QV4SCRIPT_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <private/qv4compilercontext_p.h>
#include <private/qv4engine_p.h>
#include <private/qv4global_p.h>
#include <private/qv4qmlcontext_p.h>
#include <QtQml/qqmlerror.h>
QT_BEGIN_NAMESPACE
class QQmlContextData;
namespace QQmlJS {
class Engine;
}
namespace QV4 {
struct Q_QML_EXPORT Script
{
enum class InheritContext { No, Yes };
static QQmlRefPointer<QV4::CompiledData::CompilationUnit> precompile(
QV4::Compiler::Module *module, QQmlJS::Engine *jsEngine,
Compiler::JSUnitGenerator *unitGenerator, const QString &fileName,
const QString &source, QList<QQmlError> *reportedErrors = nullptr,
QV4::Compiler::ContextType contextType = QV4::Compiler::ContextType::Global,
InheritContext inheritContext = InheritContext::No);
Script(
ExecutionContext *scope, QV4::Compiler::ContextType mode, const QString &sourceCode,
const QString &source = QString(), int line = 1)
: m_sourceFile(source)
, m_sourceCode(sourceCode)
, m_context(scope)
, m_line(line)
, m_contextType(mode)
{}
Script(
ExecutionEngine *engine, QmlContext *qml, bool parseAsBinding, const QString &sourceCode,
const QString &source = QString(), int line = 1)
: m_sourceFile(source)
, m_sourceCode(sourceCode)
, m_context(engine->rootContext())
, m_line(line)
, m_parseAsBinding(parseAsBinding)
, m_inheritContext(true)
{
if (qml)
m_qmlContext.set(engine, *qml);
}
Script(
ExecutionEngine *engine, QmlContext *qml,
const QQmlRefPointer<ExecutableCompilationUnit> &compilationUnit);
~Script();
void setStrictMode(bool strictMode = true) { m_strictMode = strictMode; }
void setInheritContext(bool inheritContext = true) { m_inheritContext = inheritContext; }
void setParseAsBinding(bool parseAsBinding = true) { m_parseAsBinding = parseAsBinding; }
QQmlRefPointer<ExecutableCompilationUnit> compilationUnit() const { return m_compilationUnit; }
void parse();
ReturnedValue run(const QV4::Value *thisObject = nullptr);
Function *function();
private:
QString m_sourceFile;
QString m_sourceCode;
QV4::PersistentValue m_qmlContext;
QQmlRefPointer<ExecutableCompilationUnit> m_compilationUnit;
QV4::WriteBarrier::Pointer<Function> m_vmFunction;
ExecutionContext *m_context = nullptr;
int m_line = 1;
QV4::Compiler::ContextType m_contextType = QV4::Compiler::ContextType::Eval;
bool m_strictMode = false;
bool m_parseAsBinding = false;
bool m_inheritContext = false;
bool m_parsed = false;
};
}
QT_END_NAMESPACE
#endif
|