diff options
author | Roberto Raggi <roberto.raggi@trolltech.com> | 2009-02-10 14:43:19 +0100 |
---|---|---|
committer | Roberto Raggi <qtc-committer@nokia.com> | 2009-02-10 14:44:03 +0100 |
commit | 2d80acbe763e1cd1f872e4d49ba653d09bca8c6e (patch) | |
tree | fa98b1339f78093ce5bd5d80751252af765650bb /src/shared/cplusplus/PrettyPrinter.cpp | |
parent | 885d908ea336de72e7fce2141c1060e425f2af0a (diff) | |
download | qt-creator-2d80acbe763e1cd1f872e4d49ba653d09bca8c6e.tar.gz |
Improved the implementation of new-expressions.
Diffstat (limited to 'src/shared/cplusplus/PrettyPrinter.cpp')
-rw-r--r-- | src/shared/cplusplus/PrettyPrinter.cpp | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/src/shared/cplusplus/PrettyPrinter.cpp b/src/shared/cplusplus/PrettyPrinter.cpp index d6c604c3ab..8c00791ade 100644 --- a/src/shared/cplusplus/PrettyPrinter.cpp +++ b/src/shared/cplusplus/PrettyPrinter.cpp @@ -764,15 +764,11 @@ bool PrettyPrinter::visit(NestedNameSpecifierAST *ast) return false; } -bool PrettyPrinter::visit(NewDeclaratorAST *ast) +bool PrettyPrinter::visit(NewArrayDeclaratorAST *ast) { - for (PtrOperatorAST *it = ast->ptr_operators; it; it = it->next) { - accept(it); - if (it->next) - out << ' '; - } - if (ast->declarator) - accept(ast->declarator); + out << '['; + accept(ast->expression); + out << ']'; return false; } @@ -782,25 +778,32 @@ bool PrettyPrinter::visit(NewExpressionAST *ast) out << "::"; out << "new"; out << ' '; - if (ast->expression) { - accept(ast->expression); - if (ast->type_id) - out << ' '; - } - if (ast->type_id) { + accept(ast->new_placement); + if (ast->new_placement) + out << ' '; + if (ast->lparen_token) { + out << '('; accept(ast->type_id); - if (ast->new_type_id) - out << ' '; - } - if (ast->new_type_id) { + out << ')'; + } else { accept(ast->new_type_id); - if (ast->new_initializer) - out << ' '; } accept(ast->new_initializer); return false; } +bool PrettyPrinter::visit(NewPlacementAST *ast) +{ + out << '('; + for (ExpressionListAST *it = ast->expression_list; it; it = it->next) { + accept(it->expression); + if (it->next) + out << ", "; + } + out << ')'; + return false; +} + bool PrettyPrinter::visit(NewInitializerAST *ast) { out << '('; @@ -812,18 +815,16 @@ bool PrettyPrinter::visit(NewInitializerAST *ast) bool PrettyPrinter::visit(NewTypeIdAST *ast) { for (SpecifierAST *it = ast->type_specifier; it; it = it->next) { - accept(it); - if (it->next) + if (it != ast->type_specifier) out << ' '; + accept(it); } - if (ast->type_specifier) - out << ' '; - if (ast->new_initializer) { - accept(ast->new_initializer); - if (ast->new_declarator) - out << ' '; + for (PtrOperatorAST *it = ast->ptr_operators; it; it = it->next) { + accept(it); + } + for (NewArrayDeclaratorAST *it = ast->new_array_declarators; it; it = it->next) { + accept(it); } - accept(ast->new_declarator); return false; } |