#include <ast.h>
Inheritance diagram for typeNode::
Public Types | |
enum | Type_qualifiers { NONE = 0x0, CONST = 0x1, VOLATILE = 0x2, INLINE = 0x4, COMPATIBLE = 0x3 } |
Type qualifiers. More... | |
Public Methods | |
typeNode (NodeType typ, Type_qualifiers tq, typeNode *subtype, const Coord coord) | |
Create a new type. More... | |
virtual | ~typeNode () |
Destroy a typeNode. More... | |
virtual bool | qualified_equal_to (typeNode *other, bool strict_toplevel, bool strict_recursive) |
Virtual type comparison routine. More... | |
typeNode * | unwind_tdefs (Type_qualifiers &the_tq) |
Unwind typedefs. More... | |
typeNode * | no_tdef_type () |
typeNode * | follow_tdefs () |
Follow typedefs. More... | |
virtual typeNode * | usual_unary_conversion_type () |
Usual unary conversion type. More... | |
virtual typeNode * | base_type (bool TdefIndir) const |
Return the base data type of a node. More... | |
typeNode * | deep_base_type () |
virtual void | dataflow (FlowVal *v, FlowProblem &fp) |
Run the dataflow analyzer. More... | |
virtual void | output (output_context &ct, Node *par) |
Generate C code. More... | |
virtual void | output_type (output_context &ct, Node *par, Assoc context, Type_qualifiers q)=0 |
Output a type. More... | |
Accessors | |
Methods to get and set fields in the class. | |
typeNode * | type () const |
Return this typeNode's subtype. More... | |
typeNode * | get_type () |
Return this typeNode's subtype, and set it to be empty. More... | |
void | type (typeNode *the_type) |
Set this typeNode's subtype. More... | |
Type_qualifiers | type_qualifiers () const |
Return this typeNode's type qualifiers. More... | |
void | type_qualifiers (Type_qualifiers the_tq) |
Set this typeNode's type qualifiers. More... | |
string | type_qualifiers_name () |
Return a string representation of this typeNode's type qualifiers. More... | |
void | add_type_qualifiers (Type_qualifiers the_tq) |
Add a new type qualifier to this typeNode. More... | |
typeNode * | add_type_qualifiers_and (Type_qualifiers the_tq) |
Add a new type qualifier to this typeNode, and return the typeNode. More... | |
void | remove_type_qualifiers (Type_qualifiers the_tq) |
Remove a type qualifier from this typeNode. More... | |
Parser methods | |
void | finish () |
typeNode * | finish_and () |
void | set_base_type (typeNode *base) |
typeNode * | set_base_type_and (typeNode *base) |
void | verify_sue_complete () |
Type comparison operators | |
These operators are used to compare types. They recursively descend the compound types and verify the structure. There are several different variations, depending on the level of strictness. In all cases, typedefs are followed so they don't interfere with the comparison. All operators use the static equal_to() method.
| |
bool | operator== (typeNode &second) |
Strict type comparison. More... | |
bool | operator<= (typeNode &second) |
Weaker type comparison. More... | |
bool | operator!= (typeNode &second) |
Strict type inequality. More... | |
Type predicates | |
These methods support a variety of useful type predicates, most of which are self-explanatory. Each typeNode subclass overrides the methods for which it returns true. | |
virtual bool | is_int () const |
virtual bool | is_char () const |
virtual bool | is_float () const |
virtual bool | is_void () const |
virtual bool | is_ellipsis () const |
virtual bool | is_integer () const |
virtual bool | is_arithmetic () const |
virtual bool | is_scalar () const |
virtual bool | is_aggregate () const |
virtual bool | is_derived () const |
virtual bool | is_pointer () const |
Static Public Methods | |
string | type_qualifiers_name (Type_qualifiers tq) |
Convert type qualifiers to string. More... | |
typeNode * | integral_promotions (typeNode *old_type) |
Integral promotions. More... | |
pair< typeNode *, typeNode *> | usual_arithmetic_conversions (typeNode *left, typeNode *right) |
Usual arithmetic conversions. More... | |
bool | equal_to (typeNode *first, typeNode *second, bool strict_toplevel, bool strict_recursive) |
Type comparison. More... | |
Private Attributes | |
TREE typeNode * | _type |
The sub-type. More... | |
Type_qualifiers | _type_qualifiers |
Type qualifiers. More... |
This class provides a base class for all nodes that represent C data types. Types are represented in the tree with the outer-most type specifier at the top and the primitive base type at the bottom. For example, "int * a[3]" is translated into a structure like this: arrayNode --> ptrNode -->primNode (int).
The NodeType is determined by the subclass.
|
Type qualifiers.
This enum holds the possible type qualifiers. The special |
|
Create a new type. Create a type node of the appropriate node type. This constructor is only used by the subclasses, which represent specific types.
|
|
Destroy a typeNode.
|
|
Add a new type qualifier to this typeNode.
|
|
Add a new type qualifier to this typeNode, and return the typeNode.
|
|
Return the base data type of a node. This method differs from the Node::type() method in two respects. First, it follows some of the simple type inferences. For example, calling it on an idNode will return the type of its declaration. Second, the boolean argument indicates whether or not to follow typedef links.
Reimplemented from Node. Reimplemented in tdefNode. |
|
Run the dataflow analyzer. Each subclass overrides this method to define it's semantics for dataflow analysis. It alters the input flow value to reflect the effect of the node within the given flow problem, calling dataflow() on it's subtrees as necessary. See the dataflow analysis documentation for more information.
Reimplemented from Node. |
|
|
|
Type comparison. This static method compares two types, descending into the subtypes and following typedefs as necessary. The two boolean arguments control how strict the algorithm is with respect to type qualifiers. Passing true requires all type qualifiers to be the same. Passing false only requires those type qualifiers that affect compatibility to be the same. (Was TypeEqualQualified in type.c) This routine relies on the qualified_equal_to() methods on each kind of typeNode to perform the appropriate comparison and dispatch to the sub-type when necessary.
|
|
Reimplemented in primNode. |
|
Reimplemented in primNode. |
|
Follow typedefs. Follow the chain of typedefs from this type, returning the underlying (non-typedef) type.
|
|
Return this typeNode's subtype, and set it to be empty.
|
|
Integral promotions.
This method is used during parsing to convert smaller types (
|
|
Reimplemented in arrayNode, and structNode. |
|
|
|
Reimplemented in primNode. |
|
|
|
Reimplemented in primNode. |
|
Reimplemented in primNode. |
|
|
|
|
|
|
|
Reimplemented in primNode, ptrNode, arrayNode, and enumNode. |
|
Reimplemented in primNode. |
|
|
|
Strict type inequality. This is just a negation of the operator==
|
|
Weaker type comparison. Compare this type to the given type, masking off type qualifiers that don't affect compatibility of types.
|
|
Strict type comparison. Compare this type to the given type, requiring all type qualifiers to be the same.
|
|
Generate C code. Each subclass overrides this method to define how to produce the output C code. To use this method, pass an output_context and a null parent.
Reimplemented from Node. |
|
Output a type.
Reimplemented in primNode, tdefNode, ptrNode, arrayNode, funcNode, sueNode, and suespecNode. |
|
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 in primNode, ptrNode, arrayNode, funcNode, and sueNode. |
|
Remove a type qualifier from this typeNode.
|
|
|
|
|
|
Set this typeNode's subtype. To set the subtype to be empty, call this method with a value of NULL. |
|
Return this typeNode's subtype.
Reimplemented from Node. |
|
Set this typeNode's type qualifiers.
|
|
Return this typeNode's type qualifiers.
|
|
Return a string representation of this typeNode's type qualifiers.
|
|
Convert type qualifiers to string. This method is used when generating C code to convert the type qualifiers into string form.
|
|
Unwind typedefs.
|
|
Usual arithmetic conversions. From ANSI 6.2.1.5: Many binary operators that expect operands of arithmetic type cause conversions and yield result types in a similar way. The purpose is to yield a common type, which is also the type of the result. This method takes the types of the left and right operands and returns a pair of types indicating the conversions of the two operands, respectively. When necessary, these conversion include the integral promotions.
|
|
Usual unary conversion type. The purpose of this method escapes me. The constNode class seems to use it, but all it does is return itself. No other typeNode overrides it. |
|
|
|
The sub-type. This field holds the sub-type for compound types such as array, pointer, and function declaration. |
|
Type qualifiers. The type qualifiers for this type |