Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
fd90c350
Commit
fd90c350
authored
Feb 04, 2010
by
Erik Verbruggen
Browse files
Added AST nodes for compound expressions (a GNU extension).
parent
7cdb15e7
Changes
14
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/ResolveExpression.cpp
View file @
fd90c350
...
...
@@ -293,6 +293,11 @@ bool ResolveExpression::visit(ThisExpressionAST *)
return
false
;
}
bool
ResolveExpression
::
visit
(
CompoundExpressionAST
*
ast
)
{
return
true
;
// ###
}
bool
ResolveExpression
::
visit
(
NestedExpressionAST
*
ast
)
{
accept
(
ast
->
expression
);
...
...
src/libs/cplusplus/ResolveExpression.h
View file @
fd90c350
...
...
@@ -93,6 +93,7 @@ protected:
virtual
bool
visit
(
TypeIdAST
*
ast
);
virtual
bool
visit
(
UnaryExpressionAST
*
ast
);
virtual
bool
visit
(
CompoundLiteralAST
*
ast
);
virtual
bool
visit
(
CompoundExpressionAST
*
ast
);
//names
virtual
bool
visit
(
QualifiedNameAST
*
ast
);
...
...
src/shared/cplusplus/AST.cpp
View file @
fd90c350
...
...
@@ -326,6 +326,20 @@ unsigned BoolLiteralAST::lastToken() const
return
literal_token
+
1
;
}
unsigned
CompoundExpressionAST
::
firstToken
()
const
{
return
lparen_token
;
}
unsigned
CompoundExpressionAST
::
lastToken
()
const
{
if
(
rparen_token
)
return
rparen_token
+
1
;
else
if
(
compoundStatement
)
return
compoundStatement
->
lastToken
();
else
return
lparen_token
+
1
;
}
unsigned
CompoundLiteralAST
::
firstToken
()
const
{
...
...
@@ -2300,5 +2314,3 @@ unsigned ObjCSynchronizedStatementAST::lastToken() const
if
(
lparen_token
)
return
lparen_token
+
1
;
return
synchronized_token
+
1
;
}
src/shared/cplusplus/AST.h
View file @
fd90c350
...
...
@@ -161,6 +161,7 @@ public:
virtual
CastExpressionAST
*
asCastExpression
()
{
return
0
;
}
virtual
CatchClauseAST
*
asCatchClause
()
{
return
0
;
}
virtual
ClassSpecifierAST
*
asClassSpecifier
()
{
return
0
;
}
virtual
CompoundExpressionAST
*
asCompoundExpression
()
{
return
0
;
}
virtual
CompoundLiteralAST
*
asCompoundLiteral
()
{
return
0
;
}
virtual
CompoundStatementAST
*
asCompoundStatement
()
{
return
0
;
}
virtual
ConditionAST
*
asCondition
()
{
return
0
;
}
...
...
@@ -700,6 +701,26 @@ protected:
virtual
bool
match0
(
AST
*
,
ASTMatcher
*
);
};
class
CPLUSPLUS_EXPORT
CompoundExpressionAST
:
public
ExpressionAST
{
public:
unsigned
lparen_token
;
CompoundStatementAST
*
compoundStatement
;
unsigned
rparen_token
;
public:
virtual
CompoundExpressionAST
*
asCompoundExpression
()
{
return
this
;
}
virtual
unsigned
firstToken
()
const
;
virtual
unsigned
lastToken
()
const
;
virtual
CompoundExpressionAST
*
clone
(
MemoryPool
*
pool
)
const
;
protected:
virtual
void
accept0
(
ASTVisitor
*
visitor
);
virtual
bool
match0
(
AST
*
,
ASTMatcher
*
);
};
class
CPLUSPLUS_EXPORT
CompoundLiteralAST
:
public
ExpressionAST
{
public:
...
...
src/shared/cplusplus/ASTClone.cpp
View file @
fd90c350
...
...
@@ -213,6 +213,16 @@ BaseSpecifierAST *BaseSpecifierAST::clone(MemoryPool *pool) const
return
ast
;
}
CompoundExpressionAST
*
CompoundExpressionAST
::
clone
(
MemoryPool
*
pool
)
const
{
CompoundExpressionAST
*
ast
=
new
(
pool
)
CompoundExpressionAST
;
ast
->
lparen_token
=
lparen_token
;
if
(
compoundStatement
)
ast
->
compoundStatement
=
compoundStatement
->
clone
(
pool
);
ast
->
rparen_token
=
rparen_token
;
return
ast
;
}
CompoundLiteralAST
*
CompoundLiteralAST
::
clone
(
MemoryPool
*
pool
)
const
{
CompoundLiteralAST
*
ast
=
new
(
pool
)
CompoundLiteralAST
;
...
...
src/shared/cplusplus/ASTMatch0.cpp
View file @
fd90c350
...
...
@@ -153,6 +153,14 @@ bool BaseSpecifierAST::match0(AST *pattern, ASTMatcher *matcher)
return
false
;
}
bool
CompoundExpressionAST
::
match0
(
AST
*
pattern
,
ASTMatcher
*
matcher
)
{
if
(
CompoundExpressionAST
*
_other
=
pattern
->
asCompoundExpression
())
return
matcher
->
match
(
this
,
_other
);
return
false
;
}
bool
CompoundLiteralAST
::
match0
(
AST
*
pattern
,
ASTMatcher
*
matcher
)
{
if
(
CompoundLiteralAST
*
_other
=
pattern
->
asCompoundLiteral
())
...
...
src/shared/cplusplus/ASTMatcher.cpp
View file @
fd90c350
...
...
@@ -331,6 +331,23 @@ bool ASTMatcher::match(BaseSpecifierAST *node, BaseSpecifierAST *pattern)
return
true
;
}
bool
ASTMatcher
::
match
(
CompoundExpressionAST
*
node
,
CompoundExpressionAST
*
pattern
)
{
(
void
)
node
;
(
void
)
pattern
;
pattern
->
lparen_token
=
node
->
lparen_token
;
if
(
!
pattern
->
compoundStatement
)
pattern
->
compoundStatement
=
node
->
compoundStatement
;
else
if
(
!
AST
::
match
(
node
->
compoundStatement
,
pattern
->
compoundStatement
,
this
))
return
false
;
pattern
->
rparen_token
=
node
->
rparen_token
;
return
true
;
}
bool
ASTMatcher
::
match
(
CompoundLiteralAST
*
node
,
CompoundLiteralAST
*
pattern
)
{
(
void
)
node
;
...
...
src/shared/cplusplus/ASTMatcher.h
View file @
fd90c350
...
...
@@ -59,6 +59,7 @@ public:
virtual
bool
match
(
CastExpressionAST
*
node
,
CastExpressionAST
*
pattern
);
virtual
bool
match
(
CatchClauseAST
*
node
,
CatchClauseAST
*
pattern
);
virtual
bool
match
(
ClassSpecifierAST
*
node
,
ClassSpecifierAST
*
pattern
);
virtual
bool
match
(
CompoundExpressionAST
*
node
,
CompoundExpressionAST
*
pattern
);
virtual
bool
match
(
CompoundLiteralAST
*
node
,
CompoundLiteralAST
*
pattern
);
virtual
bool
match
(
CompoundStatementAST
*
node
,
CompoundStatementAST
*
pattern
);
virtual
bool
match
(
ConditionAST
*
node
,
ConditionAST
*
pattern
);
...
...
src/shared/cplusplus/ASTVisit.cpp
View file @
fd90c350
...
...
@@ -153,6 +153,14 @@ void BaseSpecifierAST::accept0(ASTVisitor *visitor)
visitor
->
endVisit
(
this
);
}
void
CompoundExpressionAST
::
accept0
(
ASTVisitor
*
visitor
)
{
if
(
visitor
->
visit
(
this
))
{
accept
(
compoundStatement
,
visitor
);
}
visitor
->
endVisit
(
this
);
}
void
CompoundLiteralAST
::
accept0
(
ASTVisitor
*
visitor
)
{
if
(
visitor
->
visit
(
this
))
{
...
...
src/shared/cplusplus/ASTVisitor.h
View file @
fd90c350
...
...
@@ -122,6 +122,7 @@ public:
virtual
bool
visit
(
CastExpressionAST
*
)
{
return
true
;
}
virtual
bool
visit
(
CatchClauseAST
*
)
{
return
true
;
}
virtual
bool
visit
(
ClassSpecifierAST
*
)
{
return
true
;
}
virtual
bool
visit
(
CompoundExpressionAST
*
)
{
return
true
;
}
virtual
bool
visit
(
CompoundLiteralAST
*
)
{
return
true
;
}
virtual
bool
visit
(
CompoundStatementAST
*
)
{
return
true
;
}
virtual
bool
visit
(
ConditionAST
*
)
{
return
true
;
}
...
...
@@ -252,6 +253,7 @@ public:
virtual
void
endVisit
(
CastExpressionAST
*
)
{
}
virtual
void
endVisit
(
CatchClauseAST
*
)
{
}
virtual
void
endVisit
(
ClassSpecifierAST
*
)
{
}
virtual
void
endVisit
(
CompoundExpressionAST
*
)
{
}
virtual
void
endVisit
(
CompoundLiteralAST
*
)
{
}
virtual
void
endVisit
(
CompoundStatementAST
*
)
{
}
virtual
void
endVisit
(
ConditionAST
*
)
{
}
...
...
src/shared/cplusplus/ASTfwd.h
View file @
fd90c350
...
...
@@ -75,6 +75,7 @@ class CaseStatementAST;
class
CastExpressionAST
;
class
CatchClauseAST
;
class
ClassSpecifierAST
;
class
CompoundExpressionAST
;
class
CompoundLiteralAST
;
class
CompoundStatementAST
;
class
ConditionAST
;
...
...
src/shared/cplusplus/CheckExpression.cpp
View file @
fd90c350
...
...
@@ -287,6 +287,11 @@ bool CheckExpression::visit(ThisExpressionAST *)
return
false
;
}
bool
CheckExpression
::
visit
(
CompoundExpressionAST
*
ast
)
{
return
true
;
// ###
}
bool
CheckExpression
::
visit
(
NestedExpressionAST
*
ast
)
{
FullySpecifiedType
exprTy
=
semantic
()
->
check
(
ast
->
expression
,
_scope
);
...
...
src/shared/cplusplus/CheckExpression.h
View file @
fd90c350
...
...
@@ -94,6 +94,7 @@ protected:
virtual
bool
visit
(
UnaryExpressionAST
*
ast
);
virtual
bool
visit
(
QtMethodAST
*
ast
);
virtual
bool
visit
(
CompoundLiteralAST
*
ast
);
virtual
bool
visit
(
CompoundExpressionAST
*
ast
);
//names
virtual
bool
visit
(
QualifiedNameAST
*
ast
);
...
...
src/shared/cplusplus/Parser.cpp
View file @
fd90c350
...
...
@@ -3437,7 +3437,19 @@ bool Parser::parsePrimaryExpression(ExpressionAST *&node)
return
parseThisExpression
(
node
);
case
T_LPAREN
:
return
parseNestedExpression
(
node
);
if
(
LA
(
2
)
==
T_LBRACE
)
{
// GNU extension: '(' '{' statement-list '}' ')'
CompoundExpressionAST
*
ast
=
new
(
_pool
)
CompoundExpressionAST
;
ast
->
lparen_token
=
consumeToken
();
StatementAST
*
statement
=
0
;
parseCompoundStatement
(
statement
);
ast
->
compoundStatement
=
statement
->
asCompoundStatement
();
match
(
T_RPAREN
,
&
ast
->
rparen_token
);
node
=
ast
;
return
true
;
}
else
{
return
parseNestedExpression
(
node
);
}
case
T_SIGNAL
:
case
T_SLOT
:
...
...
@@ -3799,19 +3811,6 @@ bool Parser::parseNestedExpression(ExpressionAST *&node)
DEBUG_THIS_RULE
();
if
(
LA
()
==
T_LPAREN
)
{
unsigned
lparen_token
=
consumeToken
();
if
(
LA
()
==
T_LBRACE
)
{
NestedExpressionAST
*
ast
=
new
(
_pool
)
NestedExpressionAST
;
ast
->
lparen_token
=
lparen_token
;
// ### ast
StatementAST
*
statement
=
0
;
parseCompoundStatement
(
statement
);
match
(
T_RPAREN
,
&
ast
->
rparen_token
);
node
=
ast
;
return
true
;
}
bool
previousTemplateArguments
=
switchTemplateArguments
(
false
);
ExpressionAST
*
expression
=
0
;
...
...
@@ -5275,12 +5274,11 @@ bool Parser::parseObjCContextKeyword(int kind, unsigned &in_token)
{
DEBUG_THIS_RULE
();
if
(
peekAtObjCContextKeyword
(
kind
))
{
in_token
=
consumeToken
();
return
true
;
}
else
{
if
(
!
peekAtObjCContextKeyword
(
kind
))
return
false
;
}
in_token
=
consumeToken
();
return
true
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment