This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: using GCC internal tree representation.
- From: "Alexandre E. Kopilovitch" <aek at vib dot usr dot pu dot ru>
- To: gcc at gcc dot gnu dot org
- Cc: goli at lucent dot com, goli at optonline dot net
- Date: Thu, 6 Dec 2001 17:34:32 +0300 (MSK)
- Subject: Re: using GCC internal tree representation.
- Organization: h w c employees, b f
>I am planning to use the gcc to parse my initial file and later walk through the
>internal TREE to dump the output as I need.
>
>I looked at the GCC manual (TREEs usage), but I am not quite sure how can I
>get access to the internal TREE from my own program any pointers in this regard
>will be appreciated.
If you can build GCC 3.0 then it is quite simple to get access to the tree.
Put the following lines into your module:
void your_program(tree t);
void (*back_end_hook) PARAMS ((tree)) = &your_program;
That your_program starts after the GCC parse phase is completed. GCC calls
your_program automatically as back_end_hook function (from cp/decl2.c/finish_file
function) and passes the syntax tree root to it. No change in the GCC is needed
for the call (linking of that module is sufficient).
It works for GCC 3.0, but I didn't look into GCC 3.0.1 and 3.0.2 .
Alexander Kopilovitch aek@vib.usr.pu.ru
Saint-Petersburg
Russia