aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-03-21 10:37:27 +0100
committerLars Knoll <lars.knoll@qt.io>2018-04-27 08:10:48 +0000
commit602073631e73f8be3933e9500cb81170b2f4c1c0 (patch)
treead2cb9ef72116335e90f25db5db03531d1602874 /src
parent228d7458bae704fdb8fc0fce987d5d57eced9b5d (diff)
Add support for '...' in arguments lists to the AST
No support in the codegen yet. Change-Id: I9998d7abae086660fc0457c65b6d9050933a428f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qv4codegen.cpp7
-rw-r--r--src/qml/parser/qqmljs.g17
-rw-r--r--src/qml/parser/qqmljsast_p.h1
3 files changed, 22 insertions, 3 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index ff6396b27d..0033383189 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -1407,8 +1407,13 @@ void Codegen::handleCall(Reference &base, Arguments calldata)
Codegen::Arguments Codegen::pushArgs(ArgumentList *args)
{
int argc = 0;
- for (ArgumentList *it = args; it; it = it->next)
+ for (ArgumentList *it = args; it; it = it->next) {
+ if (it->isSpreadElement) {
+ throwSyntaxError(it->firstSourceLocation(), QLatin1String("'...' in argument lists is unimplemented."));
+ return { 0, 0 };
+ }
++argc;
+ }
if (!argc)
return { 0, 0 };
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index acd0bdb0cc..f1d62badc3 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -2083,7 +2083,13 @@ ArgumentList: AssignmentExpression_In;
./
ArgumentList: T_ELLIPSIS AssignmentExpression_In;
-/. case $rule_number: { UNIMPLEMENTED; } ./
+/.
+ case $rule_number: {
+ AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(2).Expression);
+ node->isSpreadElement = true;
+ sym(1).Node = node;
+ } break;
+./
ArgumentList: ArgumentList T_COMMA AssignmentExpression_In;
/.
@@ -2095,7 +2101,14 @@ ArgumentList: ArgumentList T_COMMA AssignmentExpression_In;
./
ArgumentList: ArgumentList T_COMMA T_ELLIPSIS AssignmentExpression_In;
-/. case $rule_number: { UNIMPLEMENTED; } ./
+/.
+ case $rule_number: {
+ AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(4).Expression);
+ node->commaToken = loc(2);
+ node->isSpreadElement = true;
+ sym(1).Node = node;
+ } break;
+./
LeftHandSideExpression: NewExpression;
LeftHandSideExpression: CallExpression;
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index f07d4f88bc..8e25924a8d 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -1029,6 +1029,7 @@ public:
ExpressionNode *expression;
ArgumentList *next;
SourceLocation commaToken;
+ bool isSpreadElement = false;
};
class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode