diff options
author | Robin Burchell <robin.burchell@crimson.no> | 2017-01-29 13:00:29 +0100 |
---|---|---|
committer | Robin Burchell <robin.burchell@crimson.no> | 2017-02-03 15:10:25 +0000 |
commit | bc5cdd23f13d9215bd29e133db7844a19e919e2c (patch) | |
tree | 81ccd60ab5342e949384f4e2ea4f20412f5ff7e1 /src/qml/parser/qqmljsast_p.h | |
parent | f36337359cac10036a17ae787a17340744af0785 (diff) |
parser: Add "let" keyword (& T_LET)
We also tie this up to the existing skeletal "const" support so that they
are also checked for duplicate declarations.
While we do that, change from using a boolean to an enum so we make the scope of
a declaration a little more easily comprehensible.
Change-Id: I6a6e08aed4e16a53690d6f6bafb55632807b6024
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 | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index 9b06bf3d31..0de419d697 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -1315,10 +1315,18 @@ class QML_PARSER_EXPORT VariableDeclaration: public Node public: QQMLJS_DECLARE_AST_NODE(VariableDeclaration) - VariableDeclaration(const QStringRef &n, ExpressionNode *e): - name (n), expression (e), readOnly(false) + enum VariableScope { + FunctionScope, + BlockScope, // let + ReadOnlyBlockScope // const + }; + + VariableDeclaration(const QStringRef &n, ExpressionNode *e, VariableScope s): + name (n), expression (e), scope(s) { kind = K; } + bool isLexicallyScoped() const { return scope != FunctionScope; } + void accept0(Visitor *visitor) override; SourceLocation firstSourceLocation() const override @@ -1330,8 +1338,8 @@ public: // attributes QStringRef name; ExpressionNode *expression; - bool readOnly; SourceLocation identifierToken; + VariableScope scope; }; class QML_PARSER_EXPORT VariableDeclarationList: public Node @@ -1363,14 +1371,13 @@ public: return declaration->lastSourceLocation(); } - inline VariableDeclarationList *finish (bool readOnly) + inline VariableDeclarationList *finish(VariableDeclaration::VariableScope s) { VariableDeclarationList *front = next; next = 0; - if (readOnly) { - VariableDeclarationList *vdl; - for (vdl = front; vdl != 0; vdl = vdl->next) - vdl->declaration->readOnly = true; + VariableDeclarationList *vdl; + for (vdl = front; vdl != 0; vdl = vdl->next) { + vdl->declaration->scope = s; } return front; } |