diff options
Diffstat (limited to 'src/qml/parser/qqmljsast.cpp')
-rw-r--r-- | src/qml/parser/qqmljsast.cpp | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp index 0b1b97a41a..ca4317a9a6 100644 --- a/src/qml/parser/qqmljsast.cpp +++ b/src/qml/parser/qqmljsast.cpp @@ -1162,26 +1162,10 @@ void ExportDeclaration::accept0(Visitor *visitor) visitor->endVisit(this); } -void ModuleItemList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (ModuleItemList *it = this; it; it = it->next) { - 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); - } - } - - visitor->endVisit(this); +void ModuleItemList::accept0(Visitor *) +{ + // See ESModule::accept0 + Q_UNREACHABLE(); } StatementList *ModuleItemList::buildStatementList(MemoryPool *pool) const @@ -1192,6 +1176,8 @@ StatementList *ModuleItemList::buildStatementList(MemoryPool *pool) const if (!listItem) { if (AST::ExportDeclaration *exportDecl = AST::cast<AST::ExportDeclaration*>(item->item)) listItem = new (pool) AST::StatementList(exportDecl); + else if (AST::ImportDeclaration *importDecl = AST::cast<AST::ImportDeclaration*>(item->item)) + listItem = new (pool) AST::StatementList(importDecl); else continue; } @@ -1209,7 +1195,11 @@ StatementList *ModuleItemList::buildStatementList(MemoryPool *pool) const void ESModule::accept0(Visitor *visitor) { if (visitor->visit(this)) { - accept(body, visitor); + // We don't accept the ModuleItemList (body) as instead the statement list items + // as well as the import/export declarations are linked together in the statement + // list. That way they are processed in correct order and can be used with the codegen's + // defineFunction() that expects a statement list. + // accept(body, visitor); accept(statements, visitor); } |