31 enum class BasicTypeKind {
40 enum class TypeQualifier {
95 virtual std::string
as_str()
const = 0;
215 std::shared_ptr<Type> m_base_type;
222 HasBaseType(
const std::shared_ptr<Type> &base_type);
231 const std::string m_name;
232 std::shared_ptr<Type> m_type;
237 Member(
const std::string &name,
const std::shared_ptr<Type> &type);
241 const std::string &
get_name()
const;
244 std::shared_ptr<Type>
get_type()
const;
251 std::vector<Member> m_members;
261 virtual std::string
as_str()
const;
272 TypeQualifier m_type_qualifier;
279 QualifiedType(
const std::shared_ptr<Type> &delegate, TypeQualifier type_qualifier);
283 virtual std::string
as_str()
const;
306 BasicTypeKind m_kind;
318 virtual std::string
as_str()
const;
332 mutable unsigned m_storage_size, m_alignment;
342 std::string get_name()
const {
return m_name; }
345 virtual std::string
as_str()
const;
353 void calculate_storage()
const;
370 virtual std::string
as_str()
const;
385 PointerType(
const std::shared_ptr<Type> &base_type);
389 virtual std::string
as_str()
const;
406 ArrayType(
const std::shared_ptr<Type> &base_type,
unsigned size);
410 virtual std::string
as_str()
const;
ArrayType represents an array type.
Definition: type.h:397
virtual unsigned get_storage_size() const
Get the number of bytes required to store an instance of this type.
Definition: type.cpp:614
virtual unsigned get_alignment() const
Get the storage alignment multiple in bytes for an instance of this type.
Definition: type.cpp:618
virtual bool is_array() const
Check whether the type is an ArrayType.
Definition: type.cpp:606
virtual unsigned get_array_size() const
Get the array size (number of elements).
Definition: type.cpp:610
virtual bool is_same(const Type *other) const
Equality comparison.
Definition: type.cpp:581
virtual std::string as_str() const
Convert to a readable string representation of this type.
Definition: type.cpp:595
A BasicType represents a basic type (int, char, etc.)
Definition: type.h:304
virtual bool is_void() const
Check whether the type represents void.
Definition: type.cpp:348
virtual bool is_signed() const
Check whether the BasicType is a signed type.
Definition: type.cpp:356
virtual bool is_same(const Type *other) const
Equality comparison.
Definition: type.cpp:314
virtual unsigned get_storage_size() const
Get the number of bytes required to store an instance of this type.
Definition: type.cpp:360
virtual unsigned get_alignment() const
Get the storage alignment multiple in bytes for an instance of this type.
Definition: type.cpp:372
virtual bool is_basic() const
Check whether the type is a BasicType.
Definition: type.cpp:344
virtual BasicTypeKind get_basic_type_kind() const
Get the BasicTypeKind of a BasicType.
Definition: type.cpp:352
virtual std::string as_str() const
Convert to a readable string representation of this type.
Definition: type.cpp:321
A FunctionType represents the type of a function.
Definition: type.h:359
virtual unsigned get_alignment() const
Get the storage alignment multiple in bytes for an instance of this type.
Definition: type.cpp:526
virtual unsigned get_storage_size() const
Get the number of bytes required to store an instance of this type.
Definition: type.cpp:522
virtual bool is_same(const Type *other) const
Equality comparison.
Definition: type.cpp:486
virtual std::string as_str() const
Convert to a readable string representation of this type.
Definition: type.cpp:507
virtual bool is_function() const
Check whether the type is a FunctionType.
Definition: type.cpp:518
Common base class for QualifiedType, FunctionType, PointerType, and ArrayType.
Definition: type.h:213
virtual std::shared_ptr< Type > get_base_type() const
Get the base type.
Definition: type.cpp:125
Common base class for StructType and FunctionType, which both have "members" (fields or parameters).
Definition: type.h:249
virtual std::string as_str() const
Convert to a readable string representation of this type.
Definition: type.cpp:159
virtual void add_member(const Member &member)
Add a member.
Definition: type.cpp:190
virtual const Member & get_member(unsigned index) const
Get the Member with the position indicated by the given index.
Definition: type.cpp:198
virtual unsigned get_num_members() const
Get the number of members (fields or parameters).
Definition: type.cpp:194
A parameter of a FunctionType or a field of a StructType.
Definition: type.h:229
const std::string & get_name() const
Definition: type.cpp:141
std::shared_ptr< Type > get_type() const
Definition: type.cpp:145
PointerType represents a pointer type.
Definition: type.h:378
virtual unsigned get_storage_size() const
Get the number of bytes required to store an instance of this type.
Definition: type.cpp:561
virtual std::string as_str() const
Convert to a readable string representation of this type.
Definition: type.cpp:548
virtual bool is_same(const Type *other) const
Equality comparison.
Definition: type.cpp:541
virtual unsigned get_alignment() const
Get the storage alignment multiple in bytes for an instance of this type.
Definition: type.cpp:565
virtual bool is_pointer() const
Check whether the type is a PointerType.
Definition: type.cpp:557
A QualifiedType modifies a "delegate" type with a TypeQualifier (const or volatile).
Definition: type.h:270
virtual bool is_pointer() const
Check whether the type is a PointerType.
Definition: type.cpp:250
virtual BasicTypeKind get_basic_type_kind() const
Get the BasicTypeKind of a BasicType.
Definition: type.cpp:270
virtual bool is_basic() const
Check whether the type is a BasicType.
Definition: type.cpp:238
virtual void add_member(const Member &member)
Add a member.
Definition: type.cpp:278
virtual bool is_void() const
Check whether the type represents void.
Definition: type.cpp:242
virtual bool is_volatile() const
Check whether the type is qualified as volatile.
Definition: type.cpp:262
virtual bool is_struct() const
Check whether the type is a StructType.
Definition: type.cpp:246
virtual unsigned get_alignment() const
Get the storage alignment multiple in bytes for an instance of this type.
Definition: type.cpp:298
virtual unsigned get_num_members() const
Get the number of members (fields or parameters).
Definition: type.cpp:282
virtual unsigned get_array_size() const
Get the array size (number of elements).
Definition: type.cpp:290
virtual bool is_same(const Type *other) const
Equality comparison.
Definition: type.cpp:215
virtual unsigned get_storage_size() const
Get the number of bytes required to store an instance of this type.
Definition: type.cpp:294
virtual bool is_function() const
Check whether the type is a FunctionType.
Definition: type.cpp:258
virtual bool is_signed() const
Check whether the BasicType is a signed type.
Definition: type.cpp:274
virtual std::string as_str() const
Convert to a readable string representation of this type.
Definition: type.cpp:226
virtual const Member & get_member(unsigned index) const
Get the Member with the position indicated by the given index.
Definition: type.cpp:286
virtual bool is_array() const
Check whether the type is an ArrayType.
Definition: type.cpp:254
virtual const Type * get_unqualified_type() const
Get unqualified type (strip off type qualifiers, if any).
Definition: type.cpp:234
virtual bool is_const() const
Check whether the type is qualified as const.
Definition: type.cpp:266
StructType represents a struct type.
Definition: type.h:329
virtual bool is_struct() const
Check whether the type is a StructType.
Definition: type.cpp:437
virtual unsigned get_field_offset(const std::string &name) const
Get the offset of the named field.
Definition: type.cpp:453
virtual std::string as_str() const
Convert to a readable string representation of this type.
Definition: type.cpp:425
virtual bool is_same(const Type *other) const
Equality comparison.
Definition: type.cpp:389
virtual unsigned get_alignment() const
Get the storage alignment multiple in bytes for an instance of this type.
Definition: type.cpp:447
virtual unsigned get_storage_size() const
Get the number of bytes required to store an instance of this type.
Definition: type.cpp:441
Representation of a C data type.
Definition: type.h:60
virtual const Member & get_member(unsigned index) const
Get the Member with the position indicated by the given index.
Definition: type.cpp:98
virtual bool is_const() const
Check whether the type is qualified as const.
Definition: type.cpp:78
virtual bool is_signed() const
Check whether the BasicType is a signed type.
Definition: type.cpp:86
virtual std::string as_str() const =0
Convert to a readable string representation of this type.
virtual bool is_void() const
Check whether the type represents void.
Definition: type.cpp:54
virtual unsigned get_field_offset(const std::string &name) const
Get the offset of the named field.
Definition: type.cpp:102
virtual unsigned get_storage_size() const =0
Get the number of bytes required to store an instance of this type.
virtual bool is_array() const
Check whether the type is an ArrayType.
Definition: type.cpp:66
virtual bool is_pointer() const
Check whether the type is a PointerType.
Definition: type.cpp:62
virtual unsigned get_array_size() const
Get the array size (number of elements).
Definition: type.cpp:110
bool is_integral() const
Return true if the type is an integral (integer) type.
Definition: type.h:75
virtual const Type * get_unqualified_type() const
Get unqualified type (strip off type qualifiers, if any).
Definition: type.cpp:45
virtual std::shared_ptr< Type > get_base_type() const
Get the base type.
Definition: type.cpp:106
virtual bool is_basic() const
Check whether the type is a BasicType.
Definition: type.cpp:50
virtual bool is_function() const
Check whether the type is a FunctionType.
Definition: type.cpp:70
virtual bool is_same(const Type *other) const =0
Equality comparison.
const Member * find_member(const std::string &name) const
Find named member.
Definition: type.cpp:36
virtual bool is_volatile() const
Check whether the type is qualified as volatile.
Definition: type.cpp:74
virtual unsigned get_alignment() const =0
Get the storage alignment multiple in bytes for an instance of this type.
virtual void add_member(const Member &member)
Add a member.
Definition: type.cpp:90
virtual BasicTypeKind get_basic_type_kind() const
Get the BasicTypeKind of a BasicType.
Definition: type.cpp:82
virtual unsigned get_num_members() const
Get the number of members (fields or parameters).
Definition: type.cpp:94
virtual bool is_struct() const
Check whether the type is a StructType.
Definition: type.cpp:58