5#include <private/qv4mm_p.h>
11#include <private/qqmljsengine_p.h>
12#include <private/qqmljslexer_p.h>
13#include <private/qqmljsparser_p.h>
14#include <private/qqmljsast_p.h>
15#include <private/qqmlengine_p.h>
16#include <private/qqmlsourcecoordinate_p.h>
17#include <private/qv4profiling_p.h>
20#include <QtCore/QDebug>
21#include <QtCore/QString>
22#include <QScopedValueRollback>
29 , compilationUnit(compilationUnit), vmFunction(
nullptr), parseAsBinding(true)
56 static const int snippetLength = 70;
57 qWarning() <<
"Warning: Using function expressions as statements in scripts is not compliant with the ECMAScript specification:\n"
59 <<
"\nThis will throw a syntax error in Qt 5.12. If you want a function expression, surround it by parentheses.";
67 const bool parsed = parser.parseProgram();
69 const auto diagnosticMessages = parser.diagnosticMessages();
76 <<
": warning: " <<
m.message;
82 Program *
program = AST::cast<Program *>(parser.rootNode());
145 Lexer lexer(jsEngine);
149 parser.parseProgram();
154 *reportedErrors << errors;
165 Codegen cg(unitGenerator,
false);
168 if (reportedErrors) {
169 const auto v4Error = cg.
error();
174 error.setDescription(v4Error.message);
189 const ExecutionEngine::DiskCacheOptions options =
engine->diskCacheOptions();
209 *
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");
QJSValue globalObject() const
Returns this engine's Global Object.
bool isEmpty() const noexcept
void append(parameter_type t)
static QList< QQmlError > qmlErrorFromDiagnostics(const QString &fileName, const QList< QQmlJS::DiagnosticMessage > &diagnosticMessages)
The QQmlError class encapsulates a QML error.
void setCode(const QString &code, int lineno, bool qmlMode=true, CodeContinuation codeContinuation=CodeContinuation::Reset)
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
void setUseFastLookups(bool b)
void generateFromProgram(const QString &fileName, const QString &finalUrl, const QString &sourceCode, QQmlJS::AST::Program *ast, Module *module, ContextType contextType=ContextType::Global)
QQmlJS::DiagnosticMessage error() const
QV4::CompiledData::CompilationUnit generateCompilationUnit(bool generateUnitData=true)
static QQmlRefPointer< ExecutableCompilationUnit > create()
ReturnedValue value() const
void set(ExecutionEngine *engine, const Value &value)
\qmltype Particle \inqmlmodule QtQuick.Particles
DBusConnection const char DBusError * error
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei GLsizei GLchar * source
GLenum GLenum GLsizei void GLsizei void * column
QQmlContext * qmlContext(const QObject *obj)
int qmlConvertSourceCoordinate< quint32, int >(quint32 n)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
static constexpr ReturnedValue undefined()
QV4::Debugging::Debugger * debugger() const
ReturnedValue throwError(const Value &value)
Heap::Object * newSyntaxErrorObject(const QString &message, const QString &fileName, int line, int column)
ReturnedValue throwSyntaxError(const QString &message)
bool call(QObject *thisObject, void **a, const QMetaType *types, int argc, ExecutionContext *context)
ExecutionEngine * engine() const
Script(ExecutionContext *scope, QV4::Compiler::ContextType mode, const QString &sourceCode, const QString &source=QString(), int line=1, int column=0)
ReturnedValue run(const QV4::Value *thisObject=nullptr)
QV4::Compiler::ContextType contextType
QV4::PersistentValue qmlContext
static Script * createFromFileOrCache(ExecutionEngine *engine, QmlContext *qmlContext, const QString &fileName, const QUrl &originalUrl, QString *error)
ExecutionContext * context
QQmlRefPointer< ExecutableCompilationUnit > compilationUnit
static QV4::CompiledData::CompilationUnit precompile(QV4::Compiler::Module *module, QQmlJS::Engine *jsEngine, Compiler::JSUnitGenerator *unitGenerator, const QString &fileName, const QString &finalUrl, const QString &source, QList< QQmlError > *reportedErrors=nullptr, QV4::Compiler::ContextType contextType=QV4::Compiler::ContextType::Global)