From 2377a02afe8d8b4237b703e88ef3423242ec7cf8 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 22 Jan 2019 16:03:28 +0100 Subject: Collect type information for function parameters Change-Id: Ia9ba819ce77eee7e582cf90aacf5baa4813d9fca Reviewed-by: Ulf Hermann Reviewed-by: Fabian Kosmale --- src/qml/parser/qqmljsast.cpp | 8 ++++---- src/qml/parser/qqmljsast_p.h | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/qml/parser') diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp index f68381ce44..4f70bf0004 100644 --- a/src/qml/parser/qqmljsast.cpp +++ b/src/qml/parser/qqmljsast.cpp @@ -984,9 +984,9 @@ FunctionExpression *FunctionExpression::asFunctionDefinition() return this; } -QStringList FormalParameterList::formals() const +BoundNames FormalParameterList::formals() const { - QStringList formals; + BoundNames formals; int i = 0; for (const FormalParameterList *it = this; it; it = it->next) { if (it->element) { @@ -994,9 +994,9 @@ QStringList FormalParameterList::formals() const int duplicateIndex = formals.indexOf(name); if (duplicateIndex >= 0) { // change the name of the earlier argument to enforce the lookup semantics from the spec - formals[duplicateIndex] += QLatin1String("#") + QString::number(i); + formals[duplicateIndex].id += QLatin1String("#") + QString::number(i); } - formals += name; + formals += {name, it->element->typeAnnotation}; } ++i; } diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index cdee4843b0..da8d0bcd8d 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -850,6 +850,11 @@ struct BoundNames : public QVector return -1; return found - constBegin(); } + + bool contains(const QString &name) const + { + return indexOf(name) != -1; + } }; class QML_PARSER_EXPORT PatternElement : public Node @@ -2410,7 +2415,7 @@ public: return false; } - QStringList formals() const; + BoundNames formals() const; BoundNames boundNames() const; -- cgit v1.2.3