Go to the previous, next section.

Types

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
These operators, along with TYPE_ENUM below, define the base types. They use the base_type derived class.

TYPE_PTR
A pointer operator defines a type for pointers to an existing type. The ptr_type derived class holds this kind of type node.

TYPE_ARRAY
The array operator uses the array_type class and defines a type that is an array with elements of another type.

TYPE_FUNC
The function operator defines a type for a SUIF procedure in terms of the return type and the types of the arguments. The func_type derived class is used with this operator.

TYPE_STRUCT
TYPE_UNION
These operators are for named structure and union types and both use the struct_type derived class. Both combine fields of different types into a single record.

TYPE_ENUM
The enumerated type operator defines an integer type where each value may have a name. Like the ordinary integer types, enumerated types are also base types. Thus, the enum_type class is derived from the base_type class.

TYPE_CONST
TYPE_VOLATILE
TYPE_CALL_BY_REF
TYPE_NULL
These operators are modifiers for other types. They use the 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.

Go to the previous, next section.