summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-11-10 14:24:32 +0100
committerRoberto Raggi <roberto.raggi@nokia.com>2009-11-10 16:20:12 +0100
commita7219736b6081888a35aa5f58fcec4abc8dfad44 (patch)
tree9dda3b2b6ac4f393fd6ec2b6afc9e1df773fc030 /src/shared/cplusplus
parentaff9a743668575898d5eafe30e8e240e4a53342a (diff)
downloadqt-creator-a7219736b6081888a35aa5f58fcec4abc8dfad44.tar.gz
Cleanup Postfix operators.
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r--src/shared/cplusplus/AST.cpp6
-rw-r--r--src/shared/cplusplus/AST.h10
-rw-r--r--src/shared/cplusplus/ASTVisit.cpp3
-rw-r--r--src/shared/cplusplus/ASTfwd.h1
-rw-r--r--src/shared/cplusplus/CheckExpression.cpp4
-rw-r--r--src/shared/cplusplus/Parser.cpp10
6 files changed, 16 insertions, 18 deletions
diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp
index 987c6a1664..035f5dae37 100644
--- a/src/shared/cplusplus/AST.cpp
+++ b/src/shared/cplusplus/AST.cpp
@@ -1331,10 +1331,8 @@ unsigned PostfixExpressionAST::firstToken() const
unsigned PostfixExpressionAST::lastToken() const
{
- for (PostfixAST *it = postfix_expressions; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (postfix_expressions)
+ return postfix_expressions->lastToken();
return base_expression->lastToken();
}
diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h
index 310b3d39e2..bd5b91f4ad 100644
--- a/src/shared/cplusplus/AST.h
+++ b/src/shared/cplusplus/AST.h
@@ -66,6 +66,10 @@ public:
: value(_Tp()), next(0)
{ }
+ List(const _Tp &value)
+ : value(value), next(0)
+ { }
+
unsigned firstToken() const
{
if (value)
@@ -1460,11 +1464,7 @@ protected:
class CPLUSPLUS_EXPORT PostfixAST: public AST
{
public:
- PostfixAST *next;
-
-public:
virtual PostfixAST *asPostfix() { return this; }
-
};
class CPLUSPLUS_EXPORT CallAST: public PostfixAST
@@ -1592,7 +1592,7 @@ class CPLUSPLUS_EXPORT PostfixExpressionAST: public ExpressionAST
{
public:
ExpressionAST *base_expression;
- PostfixAST *postfix_expressions;
+ PostfixListAST *postfix_expressions;
public:
virtual PostfixExpressionAST *asPostfixExpression() { return this; }
diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp
index c9e86fb07f..5345471140 100644
--- a/src/shared/cplusplus/ASTVisit.cpp
+++ b/src/shared/cplusplus/ASTVisit.cpp
@@ -662,8 +662,7 @@ void PostfixExpressionAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
accept(base_expression, visitor);
- for (PostfixAST *it = postfix_expressions; it; it = it->next)
- accept(it, visitor);
+ accept(postfix_expressions, visitor);
}
visitor->endVisit(this);
}
diff --git a/src/shared/cplusplus/ASTfwd.h b/src/shared/cplusplus/ASTfwd.h
index 1eae7c3fff..9bbf9681f0 100644
--- a/src/shared/cplusplus/ASTfwd.h
+++ b/src/shared/cplusplus/ASTfwd.h
@@ -199,6 +199,7 @@ typedef List<BaseSpecifierAST *> BaseSpecifierListAST;
typedef List<EnumeratorAST *> EnumeratorListAST;
typedef List<MemInitializerAST *> MemInitializerListAST;
typedef List<NewArrayDeclaratorAST *> NewArrayDeclaratorListAST;
+typedef List<PostfixAST *> PostfixListAST;
typedef List<NameAST *> ObjCIdentifierListAST;
typedef List<ObjCMessageArgumentAST *> ObjCMessageArgumentListAST;
diff --git a/src/shared/cplusplus/CheckExpression.cpp b/src/shared/cplusplus/CheckExpression.cpp
index 763258dfda..25de7e62c6 100644
--- a/src/shared/cplusplus/CheckExpression.cpp
+++ b/src/shared/cplusplus/CheckExpression.cpp
@@ -251,8 +251,8 @@ bool CheckExpression::visit(TypeConstructorCallAST *ast)
bool CheckExpression::visit(PostfixExpressionAST *ast)
{
FullySpecifiedType exprTy = semantic()->check(ast->base_expression, _scope);
- for (PostfixAST *fx = ast->postfix_expressions; fx; fx = fx->next) {
- accept(fx); // ### not exactly.
+ for (PostfixListAST *it = ast->postfix_expressions; it; it = it->next) {
+ accept(it->value); // ### not exactly.
}
return false;
}
diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp
index 9179f21db1..f951973616 100644
--- a/src/shared/cplusplus/Parser.cpp
+++ b/src/shared/cplusplus/Parser.cpp
@@ -3599,7 +3599,7 @@ bool Parser::parsePostfixExpression(ExpressionAST *&node)
{
DEBUG_THIS_RULE();
if (parseCorePostfixExpression(node)) {
- PostfixAST *postfix_expressions = 0,
+ PostfixListAST *postfix_expressions = 0,
**postfix_ptr = &postfix_expressions;
while (LA()) {
if (LA() == T_LPAREN) {
@@ -3607,19 +3607,19 @@ bool Parser::parsePostfixExpression(ExpressionAST *&node)
ast->lparen_token = consumeToken();
parseExpressionList(ast->expression_list);
match(T_RPAREN, &ast->rparen_token);
- *postfix_ptr = ast;
+ *postfix_ptr = new (_pool) PostfixListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else if (LA() == T_LBRACKET) {
ArrayAccessAST *ast = new (_pool) ArrayAccessAST;
ast->lbracket_token = consumeToken();
parseExpression(ast->expression);
match(T_RBRACKET, &ast->rbracket_token);
- *postfix_ptr = ast;
+ *postfix_ptr = new (_pool) PostfixListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else if (LA() == T_PLUS_PLUS || LA() == T_MINUS_MINUS) {
PostIncrDecrAST *ast = new (_pool) PostIncrDecrAST;
ast->incr_decr_token = consumeToken();
- *postfix_ptr = ast;
+ *postfix_ptr = new (_pool) PostfixListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else if (LA() == T_DOT || LA() == T_ARROW) {
MemberAccessAST *ast = new (_pool) MemberAccessAST;
@@ -3629,7 +3629,7 @@ bool Parser::parsePostfixExpression(ExpressionAST *&node)
if (! parseNameId(ast->member_name))
_translationUnit->error(cursor(), "expected unqualified-id before token `%s'",
tok().spell());
- *postfix_ptr = ast;
+ *postfix_ptr = new (_pool) PostfixListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else break;
} // while