ASTVisitor - Function Call binding is returning null [message #181746] |
Tue, 02 January 2007 17:14  |
Eclipse User |
|
|
|
Originally posted by: bgarcia.dextratech.com
I'm parsing c++ source files through an ASTVisitor over an
IASTTranslationUnit object in order to detect Function Calls expressions:
IASTTranslationUnit asttu = serviceProvider.getTranslationUnit( file);
asttu.accept(new ASTVisitor() {
{
shouldVisitStatements = true;
shouldVisitExpressions = true;
}
public int visit(IASTStatement statement) {
try {
// Perform the visit
} catch (Exception e) {
e.printStackTrace();
}
return PROCESS_CONTINUE;
}
When I get a CPPASTFunctionCallExpression node and go through nodes
hierarchy, I was getting a getBinding() method which was giving me the
class
|
|
|
|
Re: ASTVisitor - Function Call binding is returning null [message #182852 is a reply to message #182777] |
Wed, 24 January 2007 05:38  |
Eclipse User |
|
|
|
By the way, if you want to mainapulate the AST, the static analyzer for C++
is a good example. It can be downloaded from
http://www.eclipse.org/tptp/home/downloads/
"Andrew Niefer" <aniefer@ca.ibm.com>
??????:ep62vt$2tg$1@utils.eclipse.org...
> Use IASTName.resolveBinding() instead.
>
> Binding resolution is on demand, if nobody has resolved that particular
> binding yet, getBinding will return null. Notice the javadoc on
> IASTName.getBinding(): "Get the semantic object attached to this name.
> May be null if this name
> has not yet been semantically resolved (@see resolveBinding)"
>
> As a general rule, you should be using the interfaces instead of the
> implementing methods. On the syntactic side there are other names that
> implement IASTName but aren't CPPASTName (ie qualified names and template
> ids).
> Similarily on the semantic side, there are bindings that implement
> ICPPMethod but aren't CPPMethod.
>
> -Andrew
>
> cdt1 wrote:
>> I'm parsing c++ source files through an ASTVisitor over an
>> IASTTranslationUnit object in order to detect Function Calls expressions:
>>
>>
>>
>> IASTTranslationUnit asttu = serviceProvider.getTranslationUnit( file);
>>
>> asttu.accept(new ASTVisitor() {
>>
>> {
>>
>> shouldVisitStatements = true;
>>
>> shouldVisitExpressions = true;
>>
>> }
>>
>> public int visit(IASTStatement statement) {
>>
>> try {
>>
>> // Perform the visit
>>
>> } catch (Exception e) {
>>
>>
>> e.printStackTrace();
>>
>> }
>>
>> return PROCESS_CONTINUE;
>>
>> }
>>
>>
>>
>> When I get a CPPASTFunctionCallExpression node and go through nodes
>> hierarchy, I was getting a getBinding() method which was giving me the
>> class
|
|
|
Powered by
FUDForum. Page generated in 0.03521 seconds