[Qt-creator] method body in AST
Marek Jasovsky
jasovsky.marek at gmail.com
Wed Mar 18 22:10:26 CET 2009
Hi
2009/3/18 Roberto Raggi <roberto.raggi at trolltech.com>
>
> 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'.
Yes, I have already found this that Block is being created for some other
types of AST node, besides compound statement.
btw... is there a ... intention behind the fact, that ast->symbol is created
for all blocks (as mentioned in your answer), also for Function, Namespace,
Argument.. but Declaration(s) which are actually part of symbol tree, do not
have ast->symbol? so that you cannot find these declarations as annotated
nodes in AST?
Grazie
Marek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-creator-old/attachments/20090318/54f2c3ea/attachment.html
More information about the Qt-creator-old
mailing list