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

suespecNode Class Reference

Struct/Union/Enum definition. More...

#include <ast.h>

Inheritance diagram for suespecNode::

typeNode Node List of all members.

Public Methods

 suespecNode (const char *name, decl_list *fields, NodeType owner, unitNode *the_unit, const Coord coord)
 Create a new SUE definition. More...

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

bool same_tag_as (suespecNode *other)
 Same tag test. More...

void update (decl_list *fields, sueNode *sue, const Coord right)
 Update the s/u/e with fields. More...

declNodefind_field (const string &name)
 Find a field by name. More...

virtual Nodeclone () const
 Clone the input node. 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 complete () const
void complete (bool comp)
bool visited () const
void visited (bool v)
bool already_output () const
void already_output (bool v)
bool scope_output () const
void scope_output (int v)
int size () const
void size (int size)
int align () const
void align (int align)
string & name ()
void name (string name)
decl_listfields ()
const decl_listfields () const
NodeType owner () const
AST Traversal
Methods to uniformly traverse the AST. See the documentation in the Node class.

virtual void visit (Visitor *the_visitor)
 Dispatch a Visitor. More...

virtual void walk (Walker &the_walker)
 Dispatch a Walker. More...

virtual Nodechange (Changer &the_changer, bool redispatch=false)
 Dispatch a Changer. More...


Private Attributes

string _name
 the struct/union/enum tag. More...

TREE decl_list _fields
 the struct/union/enum fields. More...

bool _complete
 struct/union/enum complete. More...

bool _visited
 visited flag. More...

bool _already_output
 Output marker. More...

int _scope_output
 Output scope control. More...

int _size
 Size in bytes. More...

int _align
 Alignment in memory. More...

NodeType _owner
 Owner type. More...


Detailed Description

Struct/Union/Enum definition.

This class holds the tag and fields for struct/union/enum. Many different sueNodes may point to one suespecNode, but only the one that has is_elaborated equal to true actually "owns" the suespecNode. All suespecNode objects are stored in the unitNode. For a more detailed explanation see the related documentation.

The NodeType is sueSpec. However, there is a special field called _owner that will match that of the refering sueNode (either Struct, Union, or Enum).

See also:
sueNode , unitNode


Constructor & Destructor Documentation

suespecNode::suespecNode const char *    name,
decl_list   fields,
NodeType    owner,
unitNode   u,
const Coord    coord
 

Create a new SUE definition.

The new s/u/e has the given name, set of fields and owner type. In addition, since all suespecNode objects are collected in the unitNode, the unit is passed as an argument.

Parameters:
name  the tag for the s/u/e (copied; not deleted).
fields  the list of field declarations, which are removed and the list deleted.
owner  the NodeType of the s/u/e (either Struct, Union, or Enum)
the_unit  the translation unit
coord  the location of the construct in the source file.

suespecNode::~suespecNode   [virtual]
 

Destroy a suespecNode.

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


Member Function Documentation

void suespecNode::align int    align [inline]
 

int suespecNode::align   const [inline]
 

void suespecNode::already_output bool    v [inline]
 

bool suespecNode::already_output   const [inline]
 

Node * suespecNode::change Changer   the_changer,
bool    redispatch = false
[virtual]
 

Dispatch a Changer.

This abstract method works much the walker, but allows the tree to be changed.

Parameters:
the_changer  the specific Changer object to use.
redispatch  pass true to revisit parts of the tree that have changed.

Reimplemented from Node.

virtual Node* suespecNode::clone   const [inline, virtual]
 

Clone the input node.

This is not a "deep" clone, so be careful. For a deep clone, use the clone_changer class.

Returns:
a shallow copy of the node (no subtrees are copied).

Reimplemented from Node.

void suespecNode::complete bool    comp [inline]
 

bool suespecNode::complete   const [inline]
 

const decl_list& suespecNode::fields   const [inline]
 

decl_list& suespecNode::fields   [inline]
 

declNode * suespecNode::find_field const string &    name
 

Find a field by name.

Search the _fields list for the given name, returning the declaration, if found, or null if not found. (Was SUE_FindField in sue.c).

Parameters:
name  the field name to look for
Returns:
the declaration, if found, or null

void suespecNode::name string    name [inline]
 

string& suespecNode::name   [inline]
 

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

Output a type.

Reimplemented from typeNode.

NodeType suespecNode::owner   const [inline]
 

bool suespecNode::same_tag_as suespecNode *    other
 

Same tag test.

This methods tests to see if this suespecNode has the same tag as the input one. This can be done by simply comparing the names. However, this code appears to be written to handle empty names (anonymous s/u/e), which never happens.

Parameters:
other  the suespecNode to compare tags with
Returns:
true if they have the same tag

void suespecNode::scope_output int    v [inline]
 

bool suespecNode::scope_output   const [inline]
 

void suespecNode::size int    size [inline]
 

int suespecNode::size   const [inline]
 

void suespecNode::update decl_list   fields,
sueNode   sue,
const Coord    right
 

Update the s/u/e with fields.

This method is used to add fields to an s/u/e during parsing.

Parameters:
fields  the list of field declarations
sue  the owner sueNode
right  the location in the source of the right curly brace

void suespecNode::visit Visitor   the_visitor [virtual]
 

Dispatch a Visitor.

This abstract method is the entry point for the visitor design pattern. Each node subclass defines a visit() method that calls the appropriate at_ method in the visitor. For more information see the Visitor documentation.

Parameters:
the_visitor  the specific Visitor object to use.

Reimplemented from Node.

void suespecNode::visited bool    v [inline]
 

bool suespecNode::visited   const [inline]
 

void suespecNode::walk Walker   the_walker [virtual]
 

Dispatch a Walker.

This abstract method works much like the visitor, but instead walks the entire underlying subtree calling the appropriate at_ method at each node. For more information see the Walker documentation.

Parameters:
the_walker  the specific Walker object to use.

Reimplemented from Node.


Member Data Documentation

int suespecNode::_align [private]
 

Alignment in memory.

The alignment information for an s/u/e is currently not computed.

bool suespecNode::_already_output [private]
 

Output marker.

Like the _visited flag, this one controls generation of C code. Again, I think there could be some bugs here.

Todo:
Check if this flag is causing bugs in the C code generator.

bool suespecNode::_complete [private]
 

struct/union/enum complete.

This boolean is used primarily during parsing to indicate when a struct or union has it's fields defined.

See also:
sue_complete_walker

TREE decl_list suespecNode::_fields [private]
 

the struct/union/enum fields.

This declaration list holds the declarations of the members of the struct/union/enum. For structs and unions the Decl_location will be SU, and for enums the Decl_location will be ENUM.

string suespecNode::_name [private]
 

the struct/union/enum tag.

This field should really be called "tag" according to the ANSI C lingo. Even though tags are optional in s/u/e definitions (anonymoung s/u/e), this field is never empty. The sueNode routine that sets them up will generate unique names automatically

NodeType suespecNode::_owner [private]
 

Owner type.

This field indicates which kind of s/u/e owns this definition. It is always one of Struct, Union, or Enum.

int suespecNode::_scope_output [private]
 

Output scope control.

This value is used during output to control generation of struct and union contents. It represents the depth of scope nesting at which the definition occurs. This helps the algorithm generate struct and union contents in the right places, even if tags are reused in different scopes.

Todo:
Check if this value is causing bugs in the C code generator.

int suespecNode::_size [private]
 

Size in bytes.

This size information for an s/u/e is currently not computed.

bool suespecNode::_visited [private]
 

visited flag.

This flag seems to be obsolete (it is always false). However, it may be causing some problems in the output algorithm.

Todo:
Check if this flag is causing bugs in the C code generator.


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