aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compileddata.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-08-13 13:27:11 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-14 17:45:37 +0000
commitc671211390b1fd9fe19e04f531817c58d3616c19 (patch)
tree2d33bfdacba11ee960a3725b1be3cd3ede99479d /src/qml/compiler/qv4compileddata.cpp
parente9f41fdf19749dda82c8005515c9941b757750c5 (diff)
Implement star re-exports
An export such as export * from "./foo.js" allows re-directing imports. Change-Id: I359ce7d4516ed4a7b95e6fcefb4725d854f9c2ce Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compileddata.cpp')
-rw-r--r--src/qml/compiler/qv4compileddata.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index 33e463c76a..10799f70da 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -394,6 +394,11 @@ QStringList CompilationUnit::moduleRequests() const
requests << stringAt(entry.moduleRequest);
}
+ for (uint i = 0; i < data->starExportEntryTableSize; ++i) {
+ const ExportEntry &entry = data->starExportEntryTable()[i];
+ requests << stringAt(entry.moduleRequest);
+ }
+
return requests;
}
@@ -490,7 +495,31 @@ const Value *CompilationUnit::resolveExportRecursively(QV4::String *exportName,
return dependentModuleUnit->resolveExportRecursively(importName, resolveSet);
}
- return nullptr;
+
+ if (exportName->toQString() == QLatin1String("default"))
+ return nullptr;
+
+ const Value *starResolution = nullptr;
+
+ for (uint i = 0; i < data->starExportEntryTableSize; ++i) {
+ const CompiledData::ExportEntry &entry = data->starExportEntryTable()[i];
+ auto dependentModuleUnit = engine->loadModule(QUrl(stringAt(entry.moduleRequest)), this);
+ if (!dependentModuleUnit)
+ return nullptr;
+
+ const Value *resolution = dependentModuleUnit->resolveExportRecursively(exportName, resolveSet);
+ // ### handle ambiguous
+ if (resolution) {
+ if (!starResolution) {
+ starResolution = resolution;
+ continue;
+ }
+ if (resolution != starResolution)
+ return nullptr;
+ }
+ }
+
+ return starResolution;
}
const ExportEntry *CompilationUnit::lookupNameInExportTable(const ExportEntry *firstExportEntry, int tableSize, QV4::String *name) const