diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-11-16 10:08:49 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-11-16 10:08:50 +0100 |
commit | e7c316504770ce357b2c73be485cdd8c1da9c4c1 (patch) | |
tree | b49032420022617396a83da310ebe01b38cda8f9 /src/qml/compiler/qv4compileddata.cpp | |
parent | 87265c7ab8743ece92262cd6b79bbba9dddd1fe1 (diff) | |
parent | e3948955c961972d34483e7da9c2908f5cb84420 (diff) |
Merge remote-tracking branch 'origin/5.12.0' into 5.12
Change-Id: I7623438dde316ae1e97802f91991f2e7ccc205a5
Diffstat (limited to 'src/qml/compiler/qv4compileddata.cpp')
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 3b2d6e0a48..b8497937c1 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -415,13 +415,20 @@ QStringList CompilationUnit::moduleRequests() const Heap::Module *CompilationUnit::instantiate(ExecutionEngine *engine) { - if (m_module) + if (isESModule() && m_module) return m_module; + if (data->indexOfRootFunction < 0) + return nullptr; + if (!this->engine) linkToEngine(engine); - m_module = engine->memoryManager->allocate<Module>(engine, this); + Scope scope(engine); + Scoped<Module> module(scope, engine->memoryManager->allocate<Module>(engine, this)); + + if (isESModule()) + m_module = module->d(); for (const QString &request: moduleRequests()) { auto dependentModuleUnit = engine->loadModule(QUrl(request), this); @@ -430,7 +437,6 @@ Heap::Module *CompilationUnit::instantiate(ExecutionEngine *engine) dependentModuleUnit->instantiate(engine); } - Scope scope(engine); ScopedString importName(scope); const uint importCount = data->importEntryTableSize; @@ -465,7 +471,7 @@ Heap::Module *CompilationUnit::instantiate(ExecutionEngine *engine) } } - return m_module; + return module->d(); } const Value *CompilationUnit::resolveExport(QV4::String *exportName) @@ -590,10 +596,13 @@ void CompilationUnit::getExportedNamesRecursively(QStringList *names, QVector<co void CompilationUnit::evaluate() { - if (m_moduleEvaluated) - return; - m_moduleEvaluated = true; + QV4::Scope scope(engine); + QV4::Scoped<Module> module(scope, m_module); + module->evaluate(); +} +void CompilationUnit::evaluateModuleRequests() +{ for (const QString &request: moduleRequests()) { auto dependentModuleUnit = engine->loadModule(QUrl(request), this); if (engine->hasException) @@ -602,19 +611,6 @@ void CompilationUnit::evaluate() if (engine->hasException) return; } - - QV4::Function *moduleFunction = runtimeFunctions[data->indexOfRootFunction]; - CppStackFrame frame; - frame.init(engine, moduleFunction, nullptr, 0); - frame.setupJSFrame(engine->jsStackTop, Value::undefinedValue(), m_module->scope, - Value::undefinedValue(), Value::undefinedValue()); - - frame.push(); - engine->jsStackTop += frame.requiredJSStackFrameSize(); - auto frameCleanup = qScopeGuard([&frame]() { - frame.pop(); - }); - Moth::VME::exec(&frame, engine); } bool CompilationUnit::loadFromDisk(const QUrl &url, const QDateTime &sourceTimeStamp, QString *errorString) @@ -768,7 +764,7 @@ QString Binding::valueAsString(const CompilationUnit *unit) const case Type_Translation: { const TranslationData &translation = unit->unitData()->translations()[value.translationDataIndex]; // This code must match that in the qsTr() implementation - const QString &path = unit->stringAt(unit->unitData()->sourceFileIndex); + const QString &path = unit->fileName(); int lastSlash = path.lastIndexOf(QLatin1Char('/')); QStringRef context = (lastSlash > -1) ? path.midRef(lastSlash + 1, path.length() - lastSlash - 5) : QStringRef(); |