#include <ast.h>
Inheritance diagram for suespecNode::
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... | |
declNode * | find_field (const string &name) |
Find a field by name. More... | |
virtual Node * | clone () 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_list & | fields () |
const decl_list & | fields () const |
NodeType | owner () const |
AST Traversal | |
virtual void | visit (Visitor *the_visitor) |
Dispatch a Visitor. More... | |
virtual void | walk (Walker &the_walker) |
Dispatch a Walker. More... | |
virtual Node * | change (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... |
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).
|
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.
|
|
Destroy a suespecNode.
|
|
|
|
|
|
|
|
|
|
Dispatch a Changer. This abstract method works much the walker, but allows the tree to be changed.
Reimplemented from Node. |
|
Clone the input node. This is not a "deep" clone, so be careful. For a deep clone, use the clone_changer class.
Reimplemented from Node. |
|
|
|
|
|
|
|
|
|
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).
|
|
|
|
|
|
Output a type.
Reimplemented from typeNode. |
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
Update the s/u/e with fields. This method is used to add fields to an s/u/e during parsing.
|
|
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.
Reimplemented from Node. |
|
|
|
|
|
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.
Reimplemented from Node. |
|
Alignment in memory. The alignment information for an s/u/e is currently not computed. |
|
Output marker. Like the _visited flag, this one controls generation of C code. Again, I think there could be some bugs here.
|
|
struct/union/enum complete. This boolean is used primarily during parsing to indicate when a struct or union has it's fields defined.
|
|
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. |
|
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 |
|
Owner type. This field indicates which kind of s/u/e owns this definition. It is always one of Struct, Union, or Enum. |
|
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.
|
|
Size in bytes. This size information for an s/u/e is currently not computed. |
|
visited flag. This flag seems to be obsolete (it is always false). However, it may be causing some problems in the output algorithm.
|