[Qt-creator] method body in AST
Roberto Raggi
roberto.raggi at trolltech.com
Wed Mar 18 17:22:06 CET 2009
Hi Marek,
On 18.03.2009, at 15:02, Marek Jasovsky wrote:
> Hi Roberto & co
>
> just one short question.
>
> is my assumption correct, that among various statements only
> CompoundStatementAST can be as a Block within method body? (first
> level in method body)
Block symbols are created pretty much for all the control flow
statements. For example, we create a Block around the if-statement
even when the branches are not compound statements.
Think about this C++ code.
void foo(int x)
{
if (int a = x != 0)
printf("a is %d\n", a);
else
printf("a is %d\n", a);
}
As you can see `a' is visible in both the then-branch and else-branch.
In order to implement the correct lookup we create a Block around the
if-statement and that block will contain a symbol for `a'.
ciao robe
More information about the Qt-creator-old
mailing list