Gyoji Compiler
|
This represents a typed member variable of a class. More...
#include <types.hpp>
Public Member Functions | |
TypeMember (std::string _member_name, size_t _index, const Type *_member_type, const Gyoji::context::SourceReference &_source_ref) | |
TypeMember (const TypeMember &other) | |
~TypeMember () | |
Move along, nothing to see here. | |
const std::string & | get_name () const |
size_t | get_index () const |
const Type * | get_type () const |
const Gyoji::context::SourceReference & | get_source_ref () const |
This represents a typed member variable of a class.
A member variable for a class consists of a name and a type. The name is the alias that is used when referring to this memory and the type is the type of that data. This also contains a source reference so that errors can be correctly attributed to their origin.
TypeMember::TypeMember | ( | std::string | _member_name, |
size_t | _index, | ||
const Type * | _member_type, | ||
const Gyoji::context::SourceReference & | _source_ref | ||
) |
This is a named member of a class or structure. It is created with a name, the type of that member which may be another type, and a reference to the source location where it was declared.
TypeMember::TypeMember | ( | const TypeMember & | other | ) |
This makes a copy of the member. It is provided so that the type class may use a map or array to store the members rather than storing them by pointer, so a copy and assignment is required.
TypeMember::~TypeMember | ( | ) |
Move along, nothing to see here.
Move along, nothing to see here.
size_t TypeMember::get_index | ( | ) | const |
Returns the index into the underlying structure representing the composite type. Indices start at 0 and run through the number of elements in the composite data type. This is technically redundant with the name, but it is convenient in the code-generation layer to have direct access to the index at a small cost of storing one index per memeber.
Specifically for LLVM, this makes it easy to use 'CreateGEP' and pass the correct index.
const std::string & TypeMember::get_name | ( | ) | const |
Returns the name of the member.
const Gyoji::context::SourceReference & TypeMember::get_source_ref | ( | ) | const |
Returns a reference to the source location where the member was declared.
const Type * TypeMember::get_type | ( | ) | const |
Returns the type fo the member.