Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

sueNode Class Reference

Struct/Union/Enum type node. More...

#include <ast.h>

Inheritance diagram for sueNode::

typeNode Node enumNode structNode unionNode List of all members.

Public Methods

 sueNode (NodeType typ, const Coord coord)
 Create a new struct/union/enum type. More...

virtual ~sueNode ()
 Destroy a sueNode. More...

bool qualified_equal_to (typeNode *node2, bool strict_toplevel, bool strict_recursive)
 Virtual type comparison routine. More...

virtual void output_type (output_context &ct, Node *par, Assoc context, Type_qualifiers q)
 Output a type. More...

Accessors
Methods to get and set fields in the class.

bool elaborated () const
void elaborated (bool elab)
suespecNodespec () const
void spec (suespecNode *s)
Parser methods
void set_name_fields (idNode *id, decl_list *fields, const Coord left_coord, const Coord the_right_coord)
sueNode * set_name_fields_and (idNode *id, decl_list *fields, const Coord left_coord, const Coord the_right_coord)
void set_name (idNode *id, const Coord coord)
sueNode * set_name_and (idNode *id, const Coord coord)
void force_new (const Coord coord)
sueNode * force_new_and (const Coord coord)
bool same_tag_as (sueNode *other)
void tag_conflict (sueNode *new_sue)

Private Attributes

REF suespecNode_spec
 The contents of the aggregate. More...

bool _elaborated
 Is elaborated. More...


Detailed Description

Struct/Union/Enum type node.

This class provides a common base class for the aggregate types struct and union, and enum. A significant design decision for these types was to completely remove the definition of the contents from this part of the AST. To see the problem, consider the following code:

     struct A * head;
     struct A {
        struct A * next;
        int data;
     }

There are three uses of the "struct A" type: the first is a forward reference and does not include the contents of the struct (it doesn't need to); the second defines the contents; the third is a self-reference within the struct definition.

This is represented as follows. All struct/union/enum contents are defined in a class called suespecNode. These objects are removed from the main AST and placed in the list at the unitNode. All uses of the type refer to those objects. In order to remember which declarations originally contained the contents, we mark them as "elaborated".

The NodeType is determined by the subclass (either Struct, Union, or Enum).

See also:
suespecNode , unitNode::_suespecs


Constructor & Destructor Documentation

sueNode::sueNode NodeType    typ,
const Coord    coord
 

Create a new struct/union/enum type.

The new type is of the given kind (struct, union or enum) and is not elaborated, by default.

Parameters:
typ  the kind of sue (struct, union, enum)
coord  the location of the construct in the source file.

sueNode::~sueNode   [virtual]
 

Destroy a sueNode.

Warning:
Do not use the destructors to delete AST nodes. Instead, rely on the node garbage collector.


Member Function Documentation

void sueNode::elaborated bool    elab [inline]
 

bool sueNode::elaborated   const [inline]
 

void sueNode::force_new const Coord    the_coord
 

sueNode * sueNode::force_new_and const Coord    the_coord
 

void sueNode::output_type output_context   ct,
Node   parent,
Assoc    context,
Type_qualifiers    q
[virtual]
 

Output a type.

Reimplemented from typeNode.

bool sueNode::qualified_equal_to typeNode   node2,
bool    strict_toplevel,
bool    strict_recursive
[virtual]
 

Virtual type comparison routine.

Each typeNode subclass overrides this routine to provide its specific type comparison. This is used by the static equal_to() method to perform general deep type comparison.

See also:
equal_to()
Parameters:
other  the type to compare against
strict_toplevel  pass true to require strict comparison of top-level types
strict_recursive  pass true to require strict comparson of sub-types
Returns:
true, if the types pass the equality test

Reimplemented from typeNode.

bool sueNode::same_tag_as sueNode *    other
 

void sueNode::set_name idNode   id,
const Coord    the_coord
 

sueNode * sueNode::set_name_and idNode   id,
const Coord    the_coord
 

void sueNode::set_name_fields idNode   id,
decl_list   fields,
const Coord    left_coord,
const Coord    the_right_coord
 

sueNode * sueNode::set_name_fields_and idNode   id,
decl_list   fields,
const Coord    left_coord,
const Coord    the_right_coord
 

void sueNode::spec suespecNode   s [inline]
 

suespecNode* sueNode::spec   const [inline]
 

void sueNode::tag_conflict sueNode *    new_sue
 


Member Data Documentation

bool sueNode::_elaborated [private]
 

Is elaborated.

True if the original declaration contained the contents of the struct/union/enum

REF suespecNode* sueNode::_spec [private]
 

The contents of the aggregate.

This field refers to the type declaration of the contents of the struct/union/enum type.


The documentation for this class was generated from the following files:
Generated on Thu Jan 10 12:06:34 2002 for C-Breeze by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001