|
Nearly CC
An educational compiler skeleton
|
Common base class for StructType and FunctionType, which both have "members" (fields or parameters). More...
#include "type.h"


Public Member Functions | |
| virtual std::string | as_str () const |
| Convert to a readable string representation of this type. More... | |
| virtual void | add_member (const Member &member) |
| Add a member. More... | |
| virtual unsigned | get_num_members () const |
| Get the number of members (fields or parameters). More... | |
| virtual const Member & | get_member (unsigned index) const |
| Get the Member with the position indicated by the given index. More... | |
| bool | is_integral () const |
| Return true if the type is an integral (integer) type. | |
| const Member * | find_member (const std::string &name) const |
| Find named member. More... | |
| virtual bool | is_same (const Type *other) const =0 |
| Equality comparison. More... | |
| virtual const Type * | get_unqualified_type () const |
| Get unqualified type (strip off type qualifiers, if any). More... | |
| virtual bool | is_basic () const |
| Check whether the type is a BasicType. More... | |
| virtual bool | is_void () const |
Check whether the type represents void. More... | |
| virtual bool | is_struct () const |
| Check whether the type is a StructType. More... | |
| virtual bool | is_pointer () const |
| Check whether the type is a PointerType. More... | |
| virtual bool | is_array () const |
| Check whether the type is an ArrayType. More... | |
| virtual bool | is_function () const |
| Check whether the type is a FunctionType. More... | |
| virtual bool | is_volatile () const |
Check whether the type is qualified as volatile. More... | |
| virtual bool | is_const () const |
Check whether the type is qualified as const. More... | |
| virtual BasicTypeKind | get_basic_type_kind () const |
| Get the BasicTypeKind of a BasicType. More... | |
| virtual bool | is_signed () const |
| Check whether the BasicType is a signed type. More... | |
| virtual unsigned | get_field_offset (const std::string &name) const |
| Get the offset of the named field. More... | |
| virtual std::shared_ptr< Type > | get_base_type () const |
| Get the base type. More... | |
| virtual unsigned | get_array_size () const |
| Get the array size (number of elements). More... | |
| virtual unsigned | get_storage_size () const =0 |
| Get the number of bytes required to store an instance of this type. More... | |
| virtual unsigned | get_alignment () const =0 |
| Get the storage alignment multiple in bytes for an instance of this type. More... | |
Common base class for StructType and FunctionType, which both have "members" (fields or parameters).
|
virtual |
Add a member.
This should only be called if the type type is a StructType or FunctionType.
| member | the member (field or parameter) to add |
Reimplemented from Type.
|
virtual |
Convert to a readable string representation of this type.
Implements Type.
Reimplemented in FunctionType, and StructType.
|
inherited |
Find named member.
| name | name of the member to return |
Member (or a null pointer if the named member doesn't exist)
|
pure virtualinherited |
Get the storage alignment multiple in bytes for an instance of this type.
I.e., the start address of an instance of this type in memory must be aligned on a multiple of the returned value. Throws an exception if called on a FunctionType.
Implemented in ArrayType, PointerType, FunctionType, StructType, BasicType, and QualifiedType.
|
virtualinherited |
Get the array size (number of elements).
Throws an exception if the type isn't an ArrayType.
Reimplemented in ArrayType, and QualifiedType.
|
virtualinherited |
Get the base type.
For a FunctionType, the base type is the return type. For a PointerType, the base type is the pointed-to type. For an ArrayType, the base type is the element type.
Reimplemented in HasBaseType.
|
virtualinherited |
Get the BasicTypeKind of a BasicType.
Reimplemented in BasicType, and QualifiedType.
|
virtualinherited |
Get the offset of the named field.
Throws an exception if the type is not a StructType.
| name | the name of a field |
Reimplemented in StructType.
|
virtual |
|
virtual |
Get the number of members (fields or parameters).
Throws an exception if this type isn't a StructType or FunctionType.
Reimplemented from Type.
|
pure virtualinherited |
Get the number of bytes required to store an instance of this type.
Throws an exception if called on a FunctionType.
Implemented in ArrayType, PointerType, FunctionType, StructType, BasicType, and QualifiedType.
|
virtualinherited |
Get unqualified type (strip off type qualifiers, if any).
Reimplemented in QualifiedType.
|
virtualinherited |
Check whether the type is an ArrayType.
Reimplemented in ArrayType, and QualifiedType.
|
virtualinherited |
Check whether the type is a BasicType.
int, char, etc., including qualified variants like const char), false otherwise Reimplemented in BasicType, and QualifiedType.
|
virtualinherited |
Check whether the type is qualified as const.
Reimplemented in QualifiedType.
|
virtualinherited |
Check whether the type is a FunctionType.
Reimplemented in FunctionType, and QualifiedType.
|
virtualinherited |
Check whether the type is a PointerType.
Reimplemented in PointerType, and QualifiedType.
|
pure virtualinherited |
Equality comparison.
Implemented in ArrayType, PointerType, FunctionType, StructType, BasicType, and QualifiedType.
|
virtualinherited |
Check whether the BasicType is a signed type.
Reimplemented in BasicType, and QualifiedType.
|
virtualinherited |
Check whether the type is a StructType.
Reimplemented in StructType, and QualifiedType.
|
virtualinherited |
Check whether the type represents void.
void, false otherwise Reimplemented in BasicType, and QualifiedType.
|
virtualinherited |
Check whether the type is qualified as volatile.
Reimplemented in QualifiedType.