Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members

node Class Reference

Base class for the node type, which is the building block for the IR trees. More...

#include <trees.h>

Inheritance diagram for node:

Inheritance graph
[legend]
Collaboration diagram for node:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 node ()
void * operator new (unsigned int num_bytes)
void * operator new (unsigned int num_bytes, pool *mem_pool)
void set_name (node_name n)
node_name get_name (void)
void set_kid (node *kid)
nodeget_kid (void)
void set_sib (node *s)
nodeget_sib (void)
uint is_leaf (void)
uint is_nonleaf (void)
nodefirst_kid (void)
nodesecond_kid (void)
nodethird_kid (void)
nodefourth_kid (void)
nodefifth_kid (void)
virtual uint get_kind (void)
virtual void set_const (pConst c)
virtual const pConst get_const (void)
virtual void set_type (pType t)
virtual const pType get_type (void)
virtual void set_sym (pSym s)
virtual const pSym get_sym (void)

Private Attributes

nodekids
nodesib
uint kid_cnt
 number of nodes down the "kids" chain

uint name: 16
uint td_rmark: 1
uint td_rdonly: 1
uint unused: 14
SRC_REF sref

Detailed Description

Base class for the node type, which is the building block for the IR trees.

This tree node is based on the trees developed by Peter Donovan and used in the Quickturn Verilog compiler. They have proven to be fast and easy to manage, but they take some getting used to.

The "kids" pointer points to the first child of the current node. The "sib" pointer points to the next "sibling" child. For example, in the tree shown below, the kids pointer would point to "A". Since "+" has no siblings in the tree shown, the "sib" node of "+" would be NULL. The sibling node of "A" would point to "B".

+ / \ / \ A B

+ / \ / kids NULL \ A / sib / \ B NULL

A call like "foo( a, b + c, d, e)" would have the structure shown below (here the right pointer is the "kids" pointer and the left pointer is the "sib" pointer).

foo / \ NULL a / \ + / \ d b / / e c

This scheme for representing trees has several advantages: children can be easily added by simply inserting them into the sibling list; trees with more than two children can be easily represented and a field that reflects the number of children is not required.

Notes:

Definition at line 105 of file trees.h.


Constructor & Destructor Documentation

node::node  )  [inline]
 

Definition at line 120 of file trees.h.

References FALSE, kids, name, NULL, sib, td_rdonly, and td_rmark.

00121     {
00122         kids = NULL;
00123         sib = NULL;
00124         name = n_bad_name;
00125         td_rmark = FALSE;
00126         td_rdonly = FALSE;
00127     }


Member Function Documentation

node* node::fifth_kid void   )  [inline]
 

Definition at line 158 of file trees.h.

References get_sib(), and kids.

00158 { return kids->get_sib()->get_sib()->get_sib()->get_sib(); }

node* node::first_kid void   )  [inline]
 

Definition at line 154 of file trees.h.

References kids.

00154 { return kids; }

node* node::fourth_kid void   )  [inline]
 

Definition at line 157 of file trees.h.

References get_sib(), and kids.

00157 { return kids->get_sib()->get_sib()->get_sib(); }

virtual const pConst node::get_const void   )  [inline, virtual]
 

Reimplemented in node_const.

Definition at line 170 of file trees.h.

References NULL.

00171     {
00172         return NULL;
00173     }

node* node::get_kid void   )  [inline]
 

Definition at line 145 of file trees.h.

References kids.

00145 { return kids; }

virtual uint node::get_kind void   )  [inline, virtual]
 

Reimplemented in node_const, node_type, and node_sym.

Definition at line 161 of file trees.h.

References nd_bad_node, and uint.

00161 { return nd_bad_node; }

node_name node::get_name void   )  [inline]
 

Definition at line 142 of file trees.h.

References name.

00142 { return name; }

node* node::get_sib void   )  [inline]
 

Definition at line 148 of file trees.h.

References sib.

Referenced by fifth_kid(), fourth_kid(), second_kid(), and third_kid().

00148 { return sib; }

virtual const pSym node::get_sym void   )  [inline, virtual]
 

Reimplemented in node_sym.

Definition at line 192 of file trees.h.

References NULL.

00193     {
00194         return NULL;
00195     }

virtual const pType node::get_type void   )  [inline, virtual]
 

Reimplemented in node_type.

Definition at line 181 of file trees.h.

References NULL.

00182     {
00183         return NULL;
00184     }

uint node::is_leaf void   )  [inline]
 

Definition at line 151 of file trees.h.

References kids, NULL, and uint.

00151 { return kids == NULL; }

uint node::is_nonleaf void   )  [inline]
 

Definition at line 152 of file trees.h.

References kids, NULL, and uint.

00152 { return kids != NULL; }

void* node::operator new unsigned int  num_bytes,
pool mem_pool
[inline]
 

Definition at line 136 of file trees.h.

References pool::GetMem().

00137     {
00138         return mem_pool->GetMem( num_bytes );
00139     }

void* node::operator new unsigned int  num_bytes  )  [inline]
 

Definition at line 130 of file trees.h.

References FALSE, and NULL.

00131     {
00132         assert( FALSE );
00133         return NULL;
00134     }

node* node::second_kid void   )  [inline]
 

Definition at line 155 of file trees.h.

References get_sib(), and kids.

00155 { return kids->get_sib(); }

virtual void node::set_const pConst  c  )  [inline, virtual]
 

Reimplemented in node_const.

Definition at line 166 of file trees.h.

References FALSE.

00167     {
00168         assert( FALSE );
00169     }

void node::set_kid node kid  )  [inline]
 

Definition at line 144 of file trees.h.

References kids.

00144 { kids = kid; }

void node::set_name node_name  n  )  [inline]
 

Definition at line 141 of file trees.h.

References name.

00141 { name = n; }

void node::set_sib node s  )  [inline]
 

Definition at line 147 of file trees.h.

References sib.

00147 { sib = s; };

virtual void node::set_sym pSym  s  )  [inline, virtual]
 

Reimplemented in node_sym.

Definition at line 188 of file trees.h.

References FALSE.

00189     {
00190         assert( FALSE );
00191     }

virtual void node::set_type pType  t  )  [inline, virtual]
 

Reimplemented in node_type.

Definition at line 177 of file trees.h.

References FALSE.

00178     {
00179         assert( FALSE );
00180     }

node* node::third_kid void   )  [inline]
 

Definition at line 156 of file trees.h.

References get_sib(), and kids.

00156 { return kids->get_sib()->get_sib(); }


Member Data Documentation

uint node::kid_cnt [private]
 

number of nodes down the "kids" chain

Definition at line 110 of file trees.h.

node* node::kids [private]
 

Definition at line 107 of file trees.h.

Referenced by fifth_kid(), first_kid(), fourth_kid(), get_kid(), is_leaf(), is_nonleaf(), node(), second_kid(), set_kid(), and third_kid().

uint node::name [private]
 

Definition at line 112 of file trees.h.

Referenced by get_name(), node(), and set_name().

node* node::sib [private]
 

Definition at line 108 of file trees.h.

Referenced by get_sib(), node(), and set_sib().

SRC_REF node::sref [private]
 

Definition at line 117 of file trees.h.

uint node::td_rdonly [private]
 

Definition at line 112 of file trees.h.

Referenced by node().

uint node::td_rmark [private]
 

Definition at line 112 of file trees.h.

Referenced by node().

uint node::unused [private]
 

Definition at line 112 of file trees.h.


The documentation for this class was generated from the following file:
Generated on Wed Mar 31 21:16:07 2004 for Data Structures for a VHDL Compiler by doxygen 1.3.3