This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Manipulating the tree Structure


Great! thank you! I tested with your code and it works... but I'm
still a bit confused.
Could you help me with this simple example?
Suppose that I obtained a tree structure with the following command:

tree stmt = bsi_stmt (si);

and suppose I want to execute the following task:

For each tree statement t:
 IF t is an assignment, then output variable name
 ELSE IF t is an IF statement then output the IF condition
 ELSE ...

how can I do this task?
Can you give me some reference?
Thanks to all,

Andrea

On 3/12/07, Tehila Meyzels <TEHILA@il.ibm.com> wrote:

The key is whether the tree_code is "MODIFY_EXPR", which is (copied from tree.def): /* Assignment expression. Operand 0 is the what to set; 1, the new value. */ DEFTREECODE (MODIFY_EXPR, "modify_expr", tcc_expression, 2)

So, I think you should do something like:
enum tree_code code = TREE_CODE (stmt);
switch (code)
{
      case MODIFY_EXPR:
...
}

Good luck,
Tehila.





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]