Difference: GccInternals (2 vs. 3)

Revision 32008-03-22 - ChenDing

Line: 1 to 1
 
META TOPICPARENT name="ProjectHome"
Changed:
<
<

Data structures in Gcc

>
>
Please expand the notes to include examples you find useful.

Code tree representation

Gcc maintains a single-node representation for many code components. For example the same identifier name is always represented by the same node. This is done through the tree interfaces (implemented) in tree.c. To get the unique node for an identifier, use tree id = get_identifier (name), where name is a character string.

 
Changed:
<
<
Please expand the notes to include examples you find useful.
>
>
If you want to print out the string representation of the node type, you can use the following trick due to TongxinBai. As an example cute code trick in Gcc, while the tree types are defined in enum tree_code in tree.h, the actual definition is not in tree.h but in tree.def, which includes a list of all node types and their (string) symbols. Looking at the code you'll quickly see how the trick works, and borrowing it you can easily construct an array of type strings (in your program file) as follows:

#define DEFTREECODE(SYM, STRING, TYPE, NARGS)   STRING,
char *type_names[] = {
#include "tree.def"
};

During debugging, you can use the node type as the index into the type_names array and pull up the string name that you so often crave for under the circumstance.

Data structures in Gcc

  Vector
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback