aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser/qqmljsast.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-08-08 17:49:59 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-10 20:33:59 +0000
commite839129b6020795483d1f9ba0b3bcfde9f881bab (patch)
tree6b04478a2077d939635e70971720bcc0643ddbb1 /src/qml/parser/qqmljsast.cpp
parent0bd3c9cda678b7e158c6142c1567ac927fde18b9 (diff)
Fix support for default exports in modules
Default export declarations require a binding setup step at run-time, so we hook it into the ESModule's statement list to make it visible to the code gen visitor. We also reserve local slot zero for the default export. Change-Id: Ie064caad0422b92cfdadbd7d94db72a05e95c0cc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljsast.cpp')
-rw-r--r--src/qml/parser/qqmljsast.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp
index 6b315c9140..0b1b97a41a 100644
--- a/src/qml/parser/qqmljsast.cpp
+++ b/src/qml/parser/qqmljsast.cpp
@@ -1166,10 +1166,17 @@ void ModuleItemList::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
for (ModuleItemList *it = this; it; it = it->next) {
- // The statement list is concatenated together between module list
- // items and stored in the ESModule, thus not visited from there.
- if (it->item && it->item->kind == Kind_StatementList)
- continue;
+ if (it->item) {
+ // The statement list is concatenated together between module list
+ // items and stored in the ESModule, thus not visited from there.
+ if (it->item->kind == Kind_StatementList)
+ continue;
+ // Export declaration are also injected into the statement list for
+ // processing of declarations an variable statements, so don't visit
+ // it here to avoid double visits.
+ if (it->item->kind == Kind_ExportDeclaration)
+ continue;
+ }
accept(it->item, visitor);
}
}
@@ -1177,13 +1184,17 @@ void ModuleItemList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-StatementList *ModuleItemList::buildStatementList() const
+StatementList *ModuleItemList::buildStatementList(MemoryPool *pool) const
{
StatementList *statements = nullptr;
for (const ModuleItemList *item = this; item; item = item->next) {
AST::StatementList *listItem = AST::cast<AST::StatementList*>(item->item);
- if (!listItem)
- continue;
+ if (!listItem) {
+ if (AST::ExportDeclaration *exportDecl = AST::cast<AST::ExportDeclaration*>(item->item))
+ listItem = new (pool) AST::StatementList(exportDecl);
+ else
+ continue;
+ }
if (statements)
statements = statements->append(listItem);
else