aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/parser')
-rw-r--r--src/qml/parser/qqmljsast.cpp32
-rw-r--r--src/qml/parser/qqmljsast_p.h4
-rw-r--r--src/qml/parser/qqmljsastvisitor_p.h3
3 files changed, 13 insertions, 26 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);
}
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index e344dd4a28..1429d784c6 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -2539,7 +2539,7 @@ public:
QStringRef moduleSpecifier;
};
-class QML_PARSER_EXPORT ImportDeclaration: public Node
+class QML_PARSER_EXPORT ImportDeclaration: public Statement
{
public:
QQMLJS_DECLARE_AST_NODE(ImportDeclaration)
@@ -2755,7 +2755,7 @@ public:
StatementList *buildStatementList(MemoryPool *pool) const;
- void accept0(Visitor *visitor) override;
+ void accept0(Visitor *) override;
SourceLocation firstSourceLocation() const override
{ return item->firstSourceLocation(); }
diff --git a/src/qml/parser/qqmljsastvisitor_p.h b/src/qml/parser/qqmljsastvisitor_p.h
index 3162bb1630..c925096de6 100644
--- a/src/qml/parser/qqmljsastvisitor_p.h
+++ b/src/qml/parser/qqmljsastvisitor_p.h
@@ -369,9 +369,6 @@ public:
virtual bool visit(ModuleItem *) { return true; }
virtual void endVisit(ModuleItem *) {}
- virtual bool visit(ModuleItemList *) { return true; }
- virtual void endVisit(ModuleItemList *) {}
-
virtual bool visit(ESModule *) { return true; }
virtual void endVisit(ESModule *) {}