4#include <private/qqmlengine_p.h>
5#include <private/qqmlirbuilder_p.h>
6#include <private/qqmlscriptblob_p.h>
7#include <private/qqmlscriptdata_p.h>
8#include <private/qqmlsourcecoordinate_p.h>
9#include <private/qqmlcontextdata_p.h>
10#include <private/qv4runtimecodegen_p.h>
11#include <private/qv4script_p.h>
13#include <QtCore/qloggingcategory.h>
37 return m_scriptData && !m_scriptData->m_value.
isEmpty();
43 auto unit = QQml::makeRefPointer<QV4::CompiledData::CompilationUnit>();
45 if (unit->loadFromDisk(
url(),
data.sourceTimeStamp(), &
error)) {
46 initializeFromCompilationUnit(std::move(unit));
55 setError(QQmlTypeLoader::tr(
"File was compiled ahead of time with an incompatible version of Qt and the original file cannot be found. Please recompile"));
57 setError(QQmlTypeLoader::tr(
"No such file or directory"));
63 if (!
error.isEmpty()) {
68 QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit;
71 QList<QQmlJS::DiagnosticMessage> diagnostics;
73 data.sourceTimeStamp(), &diagnostics);
82 irUnit.jsModule.sourceTimeStamp =
data.sourceTimeStamp();
85 irUnit.jsParserEngine.setDirectives(&collector);
100 unit = std::move(irUnit.javaScriptCompilationUnit);
105 if (unit->saveToDisk(
url(), &errorString)) {
107 if (!unit->loadFromDisk(
url(),
data.sourceTimeStamp(), &
error)) {
111 qCDebug(DBG_DISK_CACHE()) <<
"Error saving cached version of"
112 << unit->fileName() <<
"to disk:" << errorString;
116 initializeFromCompilationUnit(std::move(unit));
121 initializeFromCompilationUnit(QQml::makeRefPointer<QV4::CompiledData::CompilationUnit>(
131 for (
int ii = 0; ii < m_scripts.size(); ++ii) {
152 for (
int scriptIndex = 0; scriptIndex < m_scripts.size(); ++scriptIndex) {
181 ref.qualifier = qualifier;
182 ref.nameSpace = nameSpace;
187void QQmlScriptBlob::initializeFromCompilationUnit(
188 QQmlRefPointer<QV4::CompiledData::CompilationUnit> &&unit)
196 m_scriptData->m_precompiledScript = unit;
208 error.setLine(import->location.line());
209 error.setColumn(import->location.column());
217 const QStringList moduleRequests = unit->moduleRequests();
223 const QUrl absoluteRequest = unit->finalUrl().
resolved(relativeRequest);
225 if (absoluteBlob->m_scriptData && absoluteBlob->m_scriptData->m_precompiledScript)
250 m_scriptData->m_loaded =
true;
qsizetype size() const noexcept
bool isEmpty() const noexcept
void prepend(rvalue_ref t)
bool isError() const
Returns true if the status is Error.
bool isCompleteOrError() const
Returns true if the status is Complete or Error.
void addDependency(QQmlDataBlob *)
Wait for blob to become complete or to error.
QList< QQmlError > errors() const
Return the errors on this blob.
QUrl url() const
Returns the physical url of the data.
QQmlTypeLoader * typeLoader() const
QUrl finalUrl() const
Returns the logical URL to be used for resolving further URLs referred to in the code.
QString finalUrlString() const
Returns the finalUrl() as a string.
void setError(const QQmlError &)
Mark this blob as having errors.
QString urlString() const
QQmlTypeLoader * m_typeLoader
static QList< QQmlError > qmlErrorFromDiagnostics(const QString &fileName, const QList< QQmlJS::DiagnosticMessage > &diagnosticMessages)
static QV4::ExecutionEngine * getV4Engine(QQmlEngine *e)
The QQmlError class encapsulates a QML error.
void populateCache(QQmlTypeNameCache *cache) const
void setBaseUrl(const QUrl &url, const QString &urlString=QString())
Sets the base URL to be used for all relative file imports added.
QQmlRefPointer< T > & adopt(T *)
Takes ownership of other.
void scriptImported(const QQmlRefPointer< QQmlScriptBlob > &blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace) override
QQmlRefPointer< QQmlScriptData > scriptData() const
~QQmlScriptBlob() override
void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) override
void dataReceived(const SourceCodeData &) override
Invoked when data for the blob is received.
QString stringAt(int index) const override
void done() override
Invoked once data has either been received or a network error occurred, and all dependencies are comp...
QVector< QQmlRefPointer< QQmlScriptBlob > > scripts
QQmlRefPointer< QQmlTypeNameCache > typeNameCache
bool readCacheFile() const
bool addImport(const QV4::CompiledData::Import *import, QQmlImports::ImportFlags, QList< QQmlError > *errors)
bool writeCacheFile() const
QQmlMetaType::CachedUnitLookupError m_cachedUnitStatus
QQmlRefPointer< QQmlImports > m_importCache
The QQmlTypeLoader class abstracts loading files and their dependencies over the network.
QQmlRefPointer< QQmlScriptBlob > injectedScript(const QUrl &relativeUrl)
QQmlRefPointer< QQmlScriptBlob > getScript(const QUrl &unNormalizedUrl)
Return a QQmlScriptBlob for url.
void add(const QHashedString &name, int sciptIndex=-1, const QHashedString &nameSpace=QHashedString())
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isNull() const
Returns true if this string is null; otherwise returns false.
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
static QQmlRefPointer< QV4::CompiledData::CompilationUnit > compileModule(bool debugMode, const QString &url, const QString &sourceCode, const QDateTime &sourceTimeStamp, QList< QQmlJS::DiagnosticMessage > *diagnostics)
void set(ExecutionEngine *engine, const Value &value)
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei GLsizei GLchar * source
GLsizei const GLchar *const * path
QUrl url("example.com")
[constructor-url-reference]
QNetworkRequest request(url)
QQmlRefPointer< QQmlScriptBlob > script
QV4::CompiledData::Location location
QString stringAt(uint index) const
static QQmlRefPointer< 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)
void generate(Document &output, const QV4::CompiledData::DependentTypesHasher &dependencyHasher=QV4::CompiledData::DependentTypesHasher())