diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-03-21 15:17:24 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-04-27 08:11:09 +0000 |
commit | 0eeaad2bc8da63779d8659666c9bd99463cbe011 (patch) | |
tree | 9c01c87e60a9992a2bd6a7481303ff87a70f66e6 /src/qml/parser/qqmljsast_p.h | |
parent | c3ad706c6ff19a132bf78501430c850040e967fc (diff) |
Add support for 'class' to the AST
Change-Id: I2a9e8fb847dfa45ca77ee43e14f39f2b2def5792
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljsast_p.h')
-rw-r--r-- | src/qml/parser/qqmljsast_p.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index e88eee4a37..4eb93cc203 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -159,6 +159,7 @@ public: Kind_FunctionBody, Kind_FunctionDeclaration, Kind_FunctionExpression, + Kind_ClassExpression, Kind_IdentifierExpression, Kind_IdentifierPropertyName, Kind_ComputedPropertyName, @@ -212,6 +213,7 @@ public: Kind_BindingElementList, Kind_BindingPropertyList, Kind_BindingRestElement, + Kind_ClassElementList, Kind_UiArrayBinding, Kind_UiImport, @@ -2439,6 +2441,70 @@ public: FormalParameterList *next; }; +class QML_PARSER_EXPORT ClassExpression : public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(ClassExpression) + + ClassExpression(const QStringRef &n, ExpressionNode *heritage, ClassElementList *elements) + : name(n), heritage(heritage), elements(elements) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return classToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + +// attributes + QStringRef name; + ExpressionNode *heritage; + ClassElementList *elements; + SourceLocation classToken; + SourceLocation identifierToken; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT ClassElementList : public Node +{ +public: + QQMLJS_DECLARE_AST_NODE(ClassElementList) + + ClassElementList(PropertyDefinition *property, bool isStatic) + : isStatic(isStatic), property(property) + { + kind = K; + next = this; + } + + ClassElementList *append(ClassElementList *n) { + n->next = next; + next = n; + return n; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return property->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { + if (next) + return next->lastSourceLocation(); + return property->lastSourceLocation(); + } + + ClassElementList *finish(); + + bool isStatic; + ClassElementList *next; + PropertyDefinition *property; +}; + class QML_PARSER_EXPORT Program: public Node { public: |