#include <ast.h>
Inheritance diagram for sueNode::
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) |
suespecNode * | spec () 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... |
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).
|
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.
|
|
Destroy a sueNode.
|
|
|
|
|
|
|
|
|
|
Output a type.
Reimplemented from typeNode. |
|
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.
Reimplemented from typeNode. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Is elaborated. True if the original declaration contained the contents of the struct/union/enum |
|
The contents of the aggregate. This field refers to the type declaration of the contents of the struct/union/enum type. |