Modifier types are used to add various attributes to other types. Each attribute is represented by a different type operator:
TYPE_CONST
TYPE_VOLATILE
TYPE_CALL_BY_REF
TYPE_NULL
All of these modifier types use the modifier_type
derived class.
The base
method returns a pointer to the type that is modified,
and the set_base
method changes that field. More than one
modifier can be applied to the same type. The order of the modifiers
does not matter, but no modifier should be used more than once with the
same type (for example, a constant constant integer is illegal, but a
constant pointer to a constant integer is OK).
The base type_node
class includes several methods to deal with
modifiers. The is_const
, is_volatile
, and
is_call_by_ref
methods check for the corresponding modifiers on a
type. The unqual
method skips over any modifier types and
returns the unqualified type. This is used frequently when checking for
particular kinds of types. Finally, the find_modifier
method
checks if a type is modified by a particular modifier type operator. If
so, it returns a pointer to that modifier type; otherwise it returns
NULL
.