SUIF types are used to describe the results of instructions and the
contents of variables. Each symbol table (see section Symbol Tables)
contains a list of types that are visible within the scope of that
table. All SUIF types are derived from the type_node
base class,
which is defined in the files `types.h' and `types.cc'. The
type_node_list
class is provided for lists of pointers to types.
Different kinds of type nodes are distinguished by their type operators.
The op
method returns the operator for a particular
type_node
. Some type operators define complete types by
themselves while others build upon existing types. The type_ops
enumeration lists the type operators:
TYPE_VOID
TYPE_INT
TYPE_FLOAT
TYPE_ENUM
below, define the base
types. They use the base_type
derived class.
TYPE_PTR
ptr_type
derived class holds this kind of type node.
TYPE_ARRAY
array_type
class and defines a type
that is an array with elements of another type.
TYPE_FUNC
func_type
derived class is used with this operator.
TYPE_STRUCT
TYPE_UNION
struct_type
derived class. Both combine fields of different
types into a single record.
TYPE_ENUM
enum_type
class is derived from the
base_type
class.
TYPE_CONST
TYPE_VOLATILE
TYPE_CALL_BY_REF
TYPE_NULL
modifier_type
derived class.
The integer, floating-point, pointer, and enumerated types are all
classified as scalar types, and the is_scalar
method checks
if a type is one of these. The array, structure, and union types
are all aggregate types.
The type_node
base class defines several methods that are
applicable to all types, and those are described in the first section
below along with some other comments about types in general. The bulk
of this chapter is devoted to the various kinds of types and the
corresponding derived classes. The last section describes the common
types that are predefined in the global symbol table.