Gyoji Compiler
|
Represents the declaration of a variable inside the scope of a function or block. More...
#include <tree.hpp>
Public Member Functions | |
StatementVariableDeclaration (Gyoji::owned< TypeSpecifier > _type_specifier, Gyoji::owned< Terminal > _identifier_token, Gyoji::owned< InitializerExpression > _initializer, Gyoji::owned< Terminal > _semicolon_token) | |
~StatementVariableDeclaration () | |
const TypeSpecifier & | get_type_specifier () const |
const Terminal & | get_identifier () const |
const InitializerExpression & | get_initializer_expression () const |
![]() | |
SyntaxNode (Gyoji::context::TokenID _type, specific_type_t _data, const Gyoji::context::SourceReference &_source_ref) | |
const std::vector< std::reference_wrapper< const SyntaxNode > > & | get_children () const |
const Gyoji::context::TokenID & | get_type () const |
template<class T > | |
bool | has_data () const |
template<class T > | |
const T & | get_data () const |
const SyntaxNode & | get_syntax_node () const |
const Gyoji::context::SourceReference & | get_source_ref () const |
Represents the declaration of a variable inside the scope of a function or block.
This specifies the declaration of a variable inside the body of a function or other block. For example, the following shows the declaration of a variable of type 'u32' to the variable 'x' as being constant and initializes the value to '0' and also defines a buffer of 32 character (u8) values.
void foo() { const u32 x = 0; u8 buffer[32]; }
StatementVariableDeclaration::StatementVariableDeclaration | ( | Gyoji::owned< TypeSpecifier > | _type_specifier, |
Gyoji::owned< Terminal > | _identifier_token, | ||
Gyoji::owned< InitializerExpression > | _initializer, | ||
Gyoji::owned< Terminal > | _semicolon_token | ||
) |
Used to create a variable declaration during the parse stage, consuming the parse tokens.
StatementVariableDeclaration::~StatementVariableDeclaration | ( | ) |
Destructor, nothing special.
const Terminal & StatementVariableDeclaration::get_identifier | ( | ) | const |
Returns the name of the variable being declared.
const InitializerExpression & StatementVariableDeclaration::get_initializer_expression | ( | ) | const |
Returns the initializer expression, usually a literal, that is used to populate the variable with known values.
const TypeSpecifier & StatementVariableDeclaration::get_type_specifier | ( | ) | const |
Returns the type of the variable being declared.