aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-05-08 14:34:58 +0200
committerLars Knoll <lars.knoll@qt.io>2018-05-11 07:17:12 +0000
commit01a1ad296c2b8325476abd6d28c8cc2463c42eb6 (patch)
tree4acaaf72782e634615e74c2da52227206cd16a42 /src/qml/parser
parent4cf7e80c5740912804383e4d866ba12b2520d0e6 (diff)
Support destructuring inside catch()
Change-Id: Ib60b56ac6a7111446e01235564a4cf92ad8ad025 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/parser')
-rw-r--r--src/qml/parser/qqmljs.g18
-rw-r--r--src/qml/parser/qqmljsast.cpp1
-rw-r--r--src/qml/parser/qqmljsast_p.h8
3 files changed, 21 insertions, 6 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 8e71b8a42b..f162d123f5 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -3396,7 +3396,7 @@ TryStatement: T_TRY Block Catch Finally;
Catch: T_CATCH T_LPAREN CatchParameter T_RPAREN Block;
/.
case $rule_number: {
- AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block);
+ AST::Catch *node = new (pool) AST::Catch(sym(3).PatternElement, sym(5).Block);
node->catchToken = loc(1);
node->lparenToken = loc(2);
node->identifierToken = loc(3);
@@ -3415,9 +3415,23 @@ Finally: T_FINALLY Block;
./
CatchParameter: BindingIdentifier;
+/.
+ case $rule_number: {
+ AST::PatternElement *node = new (pool) AST::PatternElement(stringRef(1));
+ node->identifierToken = loc(1);
+ node->scope = AST::VariableScope::Let;
+ sym(1).Node = node;
+ } break;
+./
CatchParameter: BindingPattern;
-/. case $rule_number: { UNIMPLEMENTED; } ./
+/.
+ case $rule_number: {
+ AST::PatternElement *node = new (pool) AST::PatternElement(sym(1).Pattern);
+ node->scope = AST::VariableScope::Let;
+ sym(1).Node = node;
+ } break;
+./
DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON; -- automatic semicolon
DebuggerStatement: T_DEBUGGER T_SEMICOLON;
diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp
index 6c0e394a34..cc8b290bc9 100644
--- a/src/qml/parser/qqmljsast.cpp
+++ b/src/qml/parser/qqmljsast.cpp
@@ -938,6 +938,7 @@ void TryStatement::accept0(Visitor *visitor)
void Catch::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
+ accept(patternElement, visitor);
accept(statement, visitor);
}
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index e54d1aea31..36060f7358 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -2063,9 +2063,9 @@ class QML_PARSER_EXPORT Catch: public Node
public:
QQMLJS_DECLARE_AST_NODE(Catch)
- Catch(const QStringRef &n, Block *stmt):
- name (n), statement (stmt)
- { kind = K; }
+ Catch(PatternElement *p, Block *stmt)
+ : patternElement(p), statement(stmt)
+ { kind = K; }
void accept0(Visitor *visitor) override;
@@ -2076,7 +2076,7 @@ public:
{ return statement->lastSourceLocation(); }
// attributes
- QStringRef name;
+ PatternElement *patternElement;
Block *statement;
SourceLocation catchToken;
SourceLocation lparenToken;