aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser/qqmljs.g
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/qqmljs.g
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/qqmljs.g')
-rw-r--r--src/qml/parser/qqmljs.g10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 4c5748f818..faf465e7b9 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -3991,7 +3991,7 @@ ScriptBody: StatementList;
Module: ModuleBodyOpt;
/. case $rule_number: {
- sym(1).Node = new (pool) AST::ESModule(sym(1).ModuleItemList);
+ sym(1).Node = new (pool) AST::ESModule(sym(1).ModuleItemList, pool);
} break;
./
@@ -4233,6 +4233,14 @@ ExportDeclaration: T_EXPORT T_DEFAULT ExportDeclarationLookahead T_FORCE_DECLARA
ExportDeclaration: T_EXPORT T_DEFAULT ExportDeclarationLookahead AssignmentExpression_In; -- [lookahead ∉ { function, class }]
/.
case $rule_number: {
+ // if lhs is an identifier expression and rhs is an anonymous function expression, we need to assign the name of lhs to the function
+ if (auto *f = asAnonymousFunctionDefinition(sym(4).Node)) {
+ f->name = stringRef(2);
+ }
+ if (auto *c = asAnonymousClassDefinition(sym(4).Expression)) {
+ c->name = stringRef(2);
+ }
+
auto exportDeclaration = new (pool) AST::ExportDeclaration(/*exportDefault=*/true, sym(4).Node);
exportDeclaration->exportToken = loc(1);
sym(1).ExportDeclaration = exportDeclaration;