diff options
| author | Ulf Hermann <[email protected]> | 2025-06-02 12:02:35 +0200 |
|---|---|---|
| committer | Ulf Hermann <[email protected]> | 2025-06-05 20:56:15 +0200 |
| commit | 18d370ffb1f09d47f6d2283f1f893503e0aac30e (patch) | |
| tree | 0721eb4330c9039d4d1691f070b35be4da7c14b2 | |
| parent | 03a5b7c56637029638a8573c43fa6bd0b69b3dda (diff) | |
QtQml: Better encapsulate QV4::Script
Make members private, add accessors, add m_ to member names, etc.
Change-Id: I497db10b62bbfb32f55dca227af9a518da6eaa70
Reviewed-by: Sami Shalayel <[email protected]>
| -rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 7 | ||||
| -rw-r--r-- | src/qml/jsapi/qjsengine.cpp | 12 | ||||
| -rw-r--r-- | src/qml/jsruntime/qv4globalobject.cpp | 4 | ||||
| -rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 117 | ||||
| -rw-r--r-- | src/qml/jsruntime/qv4script_p.h | 99 | ||||
| -rw-r--r-- | src/qml/qml/qqmljavascriptexpression.cpp | 2 | ||||
| -rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 6 | ||||
| -rw-r--r-- | tests/auto/qml/v4misc/tst_v4misc.cpp | 2 | ||||
| -rw-r--r-- | tools/qmljs/qmljs.cpp | 4 |
10 files changed, 148 insertions, 109 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 847954d3de..eb99b36791 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -72,11 +72,11 @@ void JavaScriptJob::run() QV4::Script script(ctx, QV4::Compiler::ContextType::Eval, this->script); if (const QV4::Function *function = frame ? frame->v4Function : engine->globalCode) - script.strictMode = function->isStrict(); + script.setStrictMode(function->isStrict()); // In order for property lookups in QML to work, we need to disable fast v4 lookups. That // is a side-effect of inheritContext. - script.inheritContext = true; + script.setInheritContext(); script.parse(); QV4::ScopedValue result(scope); if (!scope.hasException()) { diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index ae68f7d980..f510f8ea4f 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -221,11 +221,12 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) QV4::Script script(ctx, QV4::Compiler::ContextType::Eval, expression); if (const QV4::Function *function = m_engine->currentStackFrame - ? m_engine->currentStackFrame->v4Function : m_engine->globalCode) - script.strictMode = function->isStrict(); + ? m_engine->currentStackFrame->v4Function : m_engine->globalCode) { + script.setStrictMode(function->isStrict()); + } // In order for property lookups in QML to work, we need to disable fast v4 lookups. // That is a side-effect of inheritContext. - script.inheritContext = true; + script.setInheritContext(); script.parse(); if (!m_engine->hasException) { if (m_engine->currentStackFrame) { diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index 0b7a9efc7d..8cae6c55be 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -520,12 +520,12 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in QV4::ScopedValue result(scope); QV4::Script script(v4->rootContext(), QV4::Compiler::ContextType::Global, program, urlForFileName(fileName).toString(), lineNumber); - script.strictMode = false; + script.setStrictMode(false); if (v4->currentStackFrame) - script.strictMode = v4->currentStackFrame->v4Function->isStrict(); + script.setStrictMode(v4->currentStackFrame->v4Function->isStrict()); else if (v4->globalCode) - script.strictMode = v4->globalCode->isStrict(); - script.inheritContext = true; + script.setStrictMode(v4->globalCode->isStrict()); + script.setInheritContext(); script.parse(); if (!scope.hasException()) result = script.run(); @@ -547,8 +547,8 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in if (v4->isInterrupted.loadRelaxed()) result = v4->newErrorObject(QStringLiteral("Interrupted")); - if (script.compilationUnit) - v4->trimCompilationUnitsForUrl(script.compilationUnit->finalUrl()); + if (const auto cu = script.compilationUnit()) + v4->trimCompilationUnitsForUrl(cu->finalUrl()); return QJSValuePrivate::fromReturnedValue(result->asReturnedValue()); } diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index 989de0de23..f55c1da2a6 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -322,8 +322,8 @@ ReturnedValue EvalFunction::evalCall(const Value *, const Value *argv, int argc, bool inheritContext = !isStrict; Script script(ctx, QV4::Compiler::ContextType::Eval, code, QStringLiteral("eval code")); - script.strictMode = (directCall && isStrict); - script.inheritContext = inheritContext; + script.setStrictMode(directCall && isStrict); + script.setInheritContext(inheritContext); script.parse(); if (v4->hasException) return Encode::undefined(); diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 357f638031..b54d03dee9 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -2,39 +2,40 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qv4script_p.h" -#include <private/qv4mm_p.h> -#include "qv4function_p.h" -#include "qv4context_p.h" -#include "qv4debugging_p.h" -#include "qv4scopedvalue_p.h" +#include <private/qqmlengine_p.h> +#include <private/qqmljsast_p.h> #include <private/qqmljsengine_p.h> #include <private/qqmljslexer_p.h> #include <private/qqmljsparser_p.h> -#include <private/qqmljsast_p.h> -#include <private/qqmlengine_p.h> #include <private/qqmlsourcecoordinate_p.h> +#include <private/qv4context_p.h> +#include <private/qv4function_p.h> +#include <private/qv4mm_p.h> #include <private/qv4profiling_p.h> -#include <qv4runtimecodegen_p.h> +#include <private/qv4runtimecodegen_p.h> +#include <private/qv4scopedvalue_p.h> -#include <QtCore/QDebug> -#include <QtCore/QString> -#include <QScopedValueRollback> +#include <QtCore/qdebug.h> +#include <QtCore/qscopedvaluerollback.h> +#include <QtCore/qstring.h> using namespace QV4; using namespace QQmlJS; -Script::Script(ExecutionEngine *v4, QmlContext *qml, const QQmlRefPointer<ExecutableCompilationUnit> &compilationUnit) - : line(1), column(0), context(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false) - , compilationUnit(compilationUnit), parseAsBinding(true) +Script::Script( + ExecutionEngine *v4, QmlContext *qml, + const QQmlRefPointer<ExecutableCompilationUnit> &compilationUnit) + : m_compilationUnit(compilationUnit) + , m_context(v4->rootContext()) + , m_parseAsBinding(true) + , m_inheritContext(true) + , m_parsed(true) { if (qml) - qmlContext.set(v4, *qml); - - parsed = true; + m_qmlContext.set(v4, *qml); - vmFunction.set(v4, - compilationUnit ? compilationUnit->rootFunction() : nullptr); + m_vmFunction.set(v4, compilationUnit ? compilationUnit->rootFunction() : nullptr); } Script::~Script() @@ -43,17 +44,17 @@ Script::~Script() void Script::parse() { - if (parsed) + if (m_parsed) return; - parsed = true; + m_parsed = true; - ExecutionEngine *v4 = context->engine(); + ExecutionEngine *v4 = m_context->engine(); Scope valueScope(v4); - QV4::Compiler::Module module(sourceFile, sourceFile, v4->debugger() != nullptr); + QV4::Compiler::Module module(m_sourceFile, m_sourceFile, v4->debugger() != nullptr); - if (sourceCode.startsWith(QLatin1String("function("))) { + if (m_sourceCode.startsWith(QLatin1String("function("))) { static const int snippetLength = 70; v4->throwSyntaxError( QLatin1String( @@ -61,13 +62,13 @@ void Script::parse() "with the ECMAScript specification:" "\n%1...\n" "If you want a function expression, surround it by parentheses.") - .arg(QStringView{sourceCode}.left(snippetLength))); + .arg(QStringView{m_sourceCode}.left(snippetLength))); return; } Engine ee, *engine = ⅇ Lexer lexer(engine); - lexer.setCode(sourceCode, line, parseAsBinding); + lexer.setCode(m_sourceCode, m_line, m_parseAsBinding); Parser parser(engine); const bool parsed = parser.parseProgram(); @@ -75,10 +76,11 @@ void Script::parse() const auto diagnosticMessages = parser.diagnosticMessages(); for (const DiagnosticMessage &m : diagnosticMessages) { if (m.isError()) { - valueScope.engine->throwSyntaxError(m.message, sourceFile, m.loc.startLine, m.loc.startColumn); + valueScope.engine->throwSyntaxError( + m.message, m_sourceFile, m.loc.startLine, m.loc.startColumn); return; } else { - qWarning() << sourceFile << ':' << m.loc.startLine << ':' << m.loc.startColumn + qWarning() << m_sourceFile << ':' << m.loc.startLine << ':' << m.loc.startColumn << ": warning: " << m.message; } } @@ -93,18 +95,18 @@ void Script::parse() } QV4::Compiler::JSUnitGenerator jsGenerator(&module); - RuntimeCodegen cg(v4, &jsGenerator, strictMode); - if (inheritContext) + RuntimeCodegen cg(v4, &jsGenerator, m_strictMode); + if (m_inheritContext) cg.setUseFastLookups(false); - cg.generateFromProgram(sourceCode, program, &module, contextType); + cg.generateFromProgram(m_sourceCode, program, &module, m_contextType); if (v4->hasException) return; - compilationUnit = v4->insertCompilationUnit(cg.generateCompilationUnit()); - vmFunction.set(v4, compilationUnit->rootFunction()); + m_compilationUnit = v4->insertCompilationUnit(cg.generateCompilationUnit()); + m_vmFunction.set(v4, m_compilationUnit->rootFunction()); } - if (!vmFunction) { + if (!m_vmFunction) { // ### FIX file/line number ScopedObject error(valueScope, v4->newSyntaxErrorObject(QStringLiteral("Syntax error"))); v4->throwError(error); @@ -113,30 +115,30 @@ void Script::parse() ReturnedValue Script::run(const QV4::Value *thisObject) { - if (!parsed) + if (!m_parsed) parse(); - if (!vmFunction) + if (!m_vmFunction) return Encode::undefined(); - QV4::ExecutionEngine *engine = context->engine(); + QV4::ExecutionEngine *engine = m_context->engine(); QV4::Scope valueScope(engine); - if (qmlContext.isUndefined()) { - QScopedValueRollback<Function*> savedGlobalCode(engine->globalCode, vmFunction); + if (m_qmlContext.isUndefined()) { + QScopedValueRollback<Function*> savedGlobalCode(engine->globalCode, m_vmFunction); - return vmFunction->call(thisObject ? thisObject : engine->globalObject, nullptr, 0, - context); + return m_vmFunction->call(thisObject ? thisObject : engine->globalObject, nullptr, 0, + m_context); } else { - Scoped<QmlContext> qml(valueScope, qmlContext.value()); - return vmFunction->call(thisObject, nullptr, 0, qml); + Scoped<QmlContext> qml(valueScope, m_qmlContext.value()); + return m_vmFunction->call(thisObject, nullptr, 0, qml); } } Function *Script::function() { - if (!parsed) + if (!m_parsed) parse(); - return vmFunction; + return m_vmFunction; } QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile( @@ -154,7 +156,8 @@ QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile( parser.parseProgram(); - QList<QQmlError> errors = QQmlEnginePrivate::qmlErrorFromDiagnostics(fileName, parser.diagnosticMessages()); + QList<QQmlError> errors + = QQmlEnginePrivate::qmlErrorFromDiagnostics(fileName, parser.diagnosticMessages()); if (!errors.isEmpty()) { if (reportedErrors) *reportedErrors << errors; @@ -186,7 +189,9 @@ QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile( return cg.generateCompilationUnit(/*generate unit data*/false); } -Script *Script::createFromFileOrCache(ExecutionEngine *engine, QmlContext *qmlContext, const QString &fileName, const QUrl &originalUrl, QString *error) +Script *Script::createFromFileOrCache( + ExecutionEngine *engine, QmlContext *qmlContext, const QString &fileName, + const QUrl &originalUrl, QString *error) { if (error) error->clear(); @@ -212,10 +217,15 @@ Script *Script::createFromFileOrCache(ExecutionEngine *engine, QmlContext *qmlCo QFile f(fileName); if (!f.open(QIODevice::ReadOnly)) { if (error) { - if (cacheError == QQmlMetaType::CachedUnitLookupError::VersionMismatch) - *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"); - else - *error = QString::fromUtf8("Error opening source file %1: %2").arg(originalUrl.toString()).arg(f.errorString()); + if (cacheError == QQmlMetaType::CachedUnitLookupError::VersionMismatch) { + *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"); + } else { + *error = QString::fromUtf8("Error opening source file %1: %2") + .arg(originalUrl.toString()).arg(f.errorString()); + } } return nullptr; } @@ -223,8 +233,9 @@ Script *Script::createFromFileOrCache(ExecutionEngine *engine, QmlContext *qmlCo QByteArray data = f.readAll(); QString sourceCode = QString::fromUtf8(data); - auto result = new QV4::Script(engine, qmlContext, /*parseAsBinding*/false, sourceCode, originalUrl.toString()); - result->contextType = QV4::Compiler::ContextType::ScriptImportedByQML; + auto result = new QV4::Script( + engine, qmlContext, /*parseAsBinding*/false, sourceCode, originalUrl.toString()); + result->m_contextType = QV4::Compiler::ContextType::ScriptImportedByQML; result->parse(); return result; } diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h index da95503c77..9ed62a2f92 100644 --- a/src/qml/jsruntime/qv4script_p.h +++ b/src/qml/jsruntime/qv4script_p.h @@ -14,13 +14,12 @@ // We mean it. // -#include "qv4global_p.h" -#include "qv4engine_p.h" -#include "qv4functionobject_p.h" -#include "qv4qmlcontext_p.h" -#include "private/qv4compilercontext_p.h" +#include <private/qv4compilercontext_p.h> +#include <private/qv4engine_p.h> +#include <private/qv4global_p.h> +#include <private/qv4qmlcontext_p.h> -#include <QQmlError> +#include <QtQml/qqmlerror.h> QT_BEGIN_NAMESPACE @@ -32,45 +31,73 @@ class Engine; namespace QV4 { -struct Q_QML_EXPORT Script { - Script(ExecutionContext *scope, QV4::Compiler::ContextType mode, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0) - : sourceFile(source), line(line), column(column), sourceCode(sourceCode) - , context(scope), strictMode(false), inheritContext(false), parsed(false), contextType(mode) - , parseAsBinding(false) {} - Script(ExecutionEngine *engine, QmlContext *qml, bool parseAsBinding, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0) - : sourceFile(source), line(line), column(column), sourceCode(sourceCode) - , context(engine->rootContext()), strictMode(false), inheritContext(true), parsed(false) - , parseAsBinding(parseAsBinding) { +struct Q_QML_EXPORT Script +{ + 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); + static Script *createFromFileOrCache( + ExecutionEngine *engine, QmlContext *qmlContext, const QString &fileName, + const QUrl &originalUrl, QString *error); + + 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) - qmlContext.set(engine, *qml); + m_qmlContext.set(engine, *qml); } - Script(ExecutionEngine *engine, QmlContext *qml, const QQmlRefPointer<ExecutableCompilationUnit> &compilationUnit); + + Script( + ExecutionEngine *engine, QmlContext *qml, + const QQmlRefPointer<ExecutableCompilationUnit> &compilationUnit); + ~Script(); - QString sourceFile; - int line; - int column; - QString sourceCode; - ExecutionContext *context; - bool strictMode; - bool inheritContext; - bool parsed; - QV4::Compiler::ContextType contextType = QV4::Compiler::ContextType::Eval; - QV4::PersistentValue qmlContext; - QQmlRefPointer<ExecutableCompilationUnit> compilationUnit; - QV4::WriteBarrier::Pointer<Function> vmFunction; - bool parseAsBinding; + + 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(); - 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); - static Script *createFromFileOrCache(ExecutionEngine *engine, QmlContext *qmlContext, const QString &fileName, const QUrl &originalUrl, QString *error); +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; }; } diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index ab19c2a91a..a92be316d9 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -505,7 +505,7 @@ void QQmlJavaScriptExpression::createQmlBinding( ep->warning(error->error()); return; } - setupFunction(qmlContext, script.vmFunction); + setupFunction(qmlContext, script.function()); } void QQmlJavaScriptExpression::setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f) diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 9b901ef629..9ee27c3c59 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -2819,7 +2819,7 @@ static inline bool evaluate_error(QV4::ExecutionEngine *v4, const QV4::Value &o, QV4::Scope scope(v4); QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), QV4::Compiler::ContextType::Eval, functionSource); - program.inheritContext = true; + program.setInheritContext(); QV4::ScopedFunctionObject function(scope, program.run()); if (scope.hasException()) { @@ -2845,7 +2845,7 @@ static inline bool evaluate_value(QV4::ExecutionEngine *v4, const QV4::Value &o, QV4::Scope scope(v4); QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), QV4::Compiler::ContextType::Eval, functionSource); - program.inheritContext = true; + program.setInheritContext(); QV4::ScopedFunctionObject function(scope, program.run()); if (scope.hasException()) { @@ -2876,7 +2876,7 @@ static inline QV4::ReturnedValue evaluate(QV4::ExecutionEngine *v4, const QV4::V QV4::Scope scope(v4); QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), QV4::Compiler::ContextType::Eval, functionSource); - program.inheritContext = true; + program.setInheritContext(); QV4::ScopedFunctionObject function(scope, program.run()); if (scope.hasException()) { diff --git a/tests/auto/qml/v4misc/tst_v4misc.cpp b/tests/auto/qml/v4misc/tst_v4misc.cpp index 956b87d5f2..f01c248033 100644 --- a/tests/auto/qml/v4misc/tst_v4misc.cpp +++ b/tests/auto/qml/v4misc/tst_v4misc.cpp @@ -40,7 +40,7 @@ void tst_v4misc::tdzOptimizations() script.parse(); QVERIFY(!v4.hasException); - const auto function = script.compilationUnit->unitData()->functionAt(0); + const auto function = script.compilationUnit()->unitData()->functionAt(0); const auto *code = function->code(); const auto len = function->codeSize; const char *end = code + len; diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp index bb96da15b2..728aa00cda 100644 --- a/tools/qmljs/qmljs.cpp +++ b/tools/qmljs/qmljs.cpp @@ -133,11 +133,11 @@ int main(int argc, char *argv[]) file.close(); script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, fn)); - script->parseAsBinding = runAsQml; + script->setParseAsBinding(runAsQml); script->parse(); } if (!scope.hasException()) { - const auto unit = script->compilationUnit; + const auto unit = script->compilationUnit(); if (useCache && unit && !(unit->unitData()->flags & QV4::CompiledData::Unit::StaticData)) { if (unit->unitData()->sourceTimeStamp == 0) { const_cast<QV4::CompiledData::Unit*>(unit->unitData())->sourceTimeStamp = QFileInfo(fn).lastModified().toMSecsSinceEpoch(); |
