diff options
author | Roberto Raggi <qtc-committer@nokia.com> | 2009-01-13 14:58:29 +0100 |
---|---|---|
committer | Roberto Raggi <qtc-committer@nokia.com> | 2009-01-13 15:04:01 +0100 |
commit | 248480b7c952b2b981e3ec9c40bf0f0761c12ac5 (patch) | |
tree | 3278da759fff46c1d93491fd5c4d0bad52577c34 /shared/cplusplus/AST.cpp | |
parent | dd235e2b4827ce76c7dff86a1c3e35400161a33b (diff) | |
download | qt-creator-248480b7c952b2b981e3ec9c40bf0f0761c12ac5.tar.gz |
Added support for C99 compound literals.
Diffstat (limited to 'shared/cplusplus/AST.cpp')
-rw-r--r-- | shared/cplusplus/AST.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/shared/cplusplus/AST.cpp b/shared/cplusplus/AST.cpp index 11be99ea48..6889ba6fa8 100644 --- a/shared/cplusplus/AST.cpp +++ b/shared/cplusplus/AST.cpp @@ -117,6 +117,9 @@ CatchClauseAST *AST::asCatchClause() ClassSpecifierAST *AST::asClassSpecifier() { return dynamic_cast<ClassSpecifierAST *>(this); } +CompoundLiteralAST *AST::asCompoundLiteral() +{ return dynamic_cast<CompoundLiteralAST *>(this); } + CompoundStatementAST *AST::asCompoundStatement() { return dynamic_cast<CompoundStatementAST *>(this); } @@ -774,6 +777,42 @@ unsigned BoolLiteralAST::lastToken() const return token + 1; } +CompoundLiteralAST *CompoundLiteralAST::clone(MemoryPool *pool) const +{ + CompoundLiteralAST *ast = new (pool) CompoundLiteralAST; + ast->lparen_token = lparen_token; + if (type_id) + ast->type_id = type_id->clone(pool); + ast->rparen_token = rparen_token; + if (initializer) + ast->initializer = initializer->clone(pool); + return ast; +} + +void CompoundLiteralAST::accept0(ASTVisitor *visitor) +{ + if (visitor->visit(this)) { + accept(type_id, visitor); + accept(initializer, visitor); + } +} + +unsigned CompoundLiteralAST::firstToken() const +{ + return lparen_token; +} + +unsigned CompoundLiteralAST::lastToken() const +{ + if (initializer) + return initializer->lastToken(); + else if (rparen_token) + return rparen_token + 1; + else if (type_id) + return type_id->lastToken(); + return lparen_token + 1; +} + BreakStatementAST *BreakStatementAST::clone(MemoryPool *pool) const { BreakStatementAST *ast = new (pool) BreakStatementAST; |