Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] pulling in extern definitions with CDT parser

Hi Markus,

Thank you for your help.  Do you think it will be possible for me to
extract code from IIndex-related code so that the linking can work
without running Eclipse (i.e. without classes like IProject and
ITranslationUnit for which the editor needs to be started).  I'm
trying to create a standalone tool that can run from command-line
without running Eclipse.  Please let me know if this is worth the
effort or I should do the linking myself.

Thank you.


On Fri, Jul 3, 2009 at 1:23 AM, Schorn,
Markus<Markus.Schorn@xxxxxxxxxxxxx> wrote:
> 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
>>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>



-- 
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


Back to the top