diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-03-25 19:14:23 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-02 14:17:03 +0000 |
commit | 1e974dd01c074ae9f32a5a1210f2fc55dba8dd3c (patch) | |
tree | 08d93f9278cfcab33d7ad4c1309737d45f1270ad /src/qml/parser/qqmljsast.cpp | |
parent | 3f82c8131fed248c24ed8c8be7449b4732afcd0b (diff) |
Properly set names of most anonymous functions
In ES6, anonymous functions assigned to a variable/property with
a known name, inherit the name of that variable/property.
Change-Id: I79479b9358b24d610e3e696eb19fe0ec4aee15d1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljsast.cpp')
-rw-r--r-- | src/qml/parser/qqmljsast.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp index 762eb9536a..eef7a33f26 100644 --- a/src/qml/parser/qqmljsast.cpp +++ b/src/qml/parser/qqmljsast.cpp @@ -45,6 +45,17 @@ QT_QML_BEGIN_NAMESPACE namespace QQmlJS { namespace AST { +FunctionExpression *asAnonymousFunctionDefinition(Node *n) +{ + if (!n) + return nullptr; + FunctionExpression *f = n->asFunctionDefinition(); + if (!f || !f->name.isNull()) + return nullptr; + return f; +} + + void Node::accept(Visitor *visitor) { if (visitor->preVisit(this)) { @@ -89,6 +100,11 @@ Pattern *Node::patternCast() return nullptr; } +FunctionExpression *Node::asFunctionDefinition() +{ + return nullptr; +} + ExpressionNode *ExpressionNode::expressionCast() { return this; @@ -117,6 +133,11 @@ void NestedExpression::accept0(Visitor *visitor) visitor->endVisit(this); } +FunctionExpression *NestedExpression::asFunctionDefinition() +{ + return expression->asFunctionDefinition(); +} + void ThisExpression::accept0(Visitor *visitor) { if (visitor->visit(this)) { @@ -909,6 +930,11 @@ void FunctionExpression::accept0(Visitor *visitor) visitor->endVisit(this); } +FunctionExpression *FunctionExpression::asFunctionDefinition() +{ + return this; +} + QStringList FormalParameterList::formals() const { QStringList formals; |