[Qt-creator] parser ?error? + SymbolVisitor

Roberto Raggi roberto.raggi at trolltech.com
Tue Mar 17 12:03:15 CET 2009


Hi,

On 17.03.2009, at 11:54, Marek Jasovsky wrote:
>
>>
>> btw. if I have Block as result from SymbolVisitor pass... how can I  
>> analyze code which is found deeper than the Block?
>
> what do you mean with analyze code?
>
> so far with current code I can find all functions, and their  
> respective parameters. for function body there is CPlusPlus::Block.
> question now is: how can I find local variables declarations within  
> this Block? how can I visit AST of this Block? (there always is body  
> as compound statement or similar.)

you can do this

for (unsigned i = 0; i < block->memberCount(); ++i) {
	Symbol *member = block->memberAt(i);
        // ### do something with `member' here
}


> How can I retrieve this compound statement within Block? I know you  
> are somehow doing this in checks / code completion but I could not  
> find this in the code

if you have an CompoundStatementAST you can get the Block symbol with  
the following code

virtual bool visit(CompoundStatementAST *ast) {
    Block *block = ast->symbol->asBlock();
    // ...
}

but, at least for now, you can get the CompoundStatementAST back from  
a Block symbol. But you can easily write a new pass that will create a  
map from Block* to CompoundStatementAST*

ciao robe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-creator-old/attachments/20090317/34711e8e/attachment.html 


More information about the Qt-creator-old mailing list