[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [cdt-dev] pulling in extern definitions with CDT parser
|
Peter,
while the parser corresponds to a compiler, the index corresponds to a
linker.
So definitions can be found via
IIndex.findDefinitions(IBinding binding)
Markus.
> -----Original Message-----
> From: cdt-dev-bounces@xxxxxxxxxxx
> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Peter Kim
> Sent: Thursday, July 02, 2009 6:59 PM
> To: cdt-dev@xxxxxxxxxxx
> Subject: [cdt-dev] pulling in extern definitions with CDT parser
> Importance: Low
>
> I am currently working on developing a simple
> source-to-source transformation tool using CDT. I've managed
> to pull the parser component out of CDT as a standalone tool
> (so that we don't have to rely on Eclipse). Namely, whereas
> before the AST had to be retrieved in the following way:
>
> ITranslationUnit tu = (ITranslationUnit)selected;
> IASTTranslationUnit ast = tu.getAST();
>
> Now, the AST is retrieved through a standalone parser, whose
> getAST() is a slightly modified, almost identical version, of
> ITranslationUnit.getAST():
>
> StandaloneCParser parser = new StandaloneCParser("c:\\foo.c",
> tu); IASTTranslationUnit astTu = parser.getAST();
>
> The parser is able to resolve bindings to definitions in
> header files (e.g. foo.h), but isn't able to do so for
> "extern" declarations, whose actual definitions are located
> in other .c files (e.g. bar.c). For example, if foo.c calls
> a method called "barMethod()" that is declared as "extern
> void barMethod();" in foo.h and actually defined in bar.c,
> calling IASTName.resolveBinding() on "barMethod()" name
> returns a CFunction whose CFunction.getDefinition() returns null.
>
> Does CDT provide a mechanism for linking, so that these
> external definitions can be pulled in automatically? If not,
> what do you recommend for connecting these various files
> together? I know CDT is more of an IDE tool than a
> traditional parser/compiler, but I've found it very useful
> and I'd like to keep using it if possible.
>
>
> --
> Peter Kim
> Ph.D. Student
> Automated Software Design Group
> Department of Computer Sciences
> The University of Texas at Austin, USA
>
> http://www.cs.utexas.edu/~chpkim
> Phone: +1-512-461-9381
> Office: ACES 5.246
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>