Gyoji Compiler
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Gyoji::frontend::tree::StatementVariableDeclaration Class Reference

Represents the declaration of a variable inside the scope of a function or block. More...

#include <tree.hpp>

Inheritance diagram for Gyoji::frontend::tree::StatementVariableDeclaration:
Inheritance graph
[legend]
Collaboration diagram for Gyoji::frontend::tree::StatementVariableDeclaration:
Collaboration graph
[legend]

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 TypeSpecifierget_type_specifier () const
 
const Terminalget_identifier () const
 
const InitializerExpression & get_initializer_expression () const
 
- Public Member Functions inherited from Gyoji::frontend::ast::SyntaxNode
 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 SyntaxNodeget_syntax_node () const
 
const Gyoji::context::SourceReferenceget_source_ref () const
 

Detailed Description

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];
}

Constructor & Destructor Documentation

◆ StatementVariableDeclaration()

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::~StatementVariableDeclaration ( )

Destructor, nothing special.

Member Function Documentation

◆ get_identifier()

const Terminal & StatementVariableDeclaration::get_identifier ( ) const

Returns the name of the variable being declared.

◆ get_initializer_expression()

const InitializerExpression & StatementVariableDeclaration::get_initializer_expression ( ) const

Returns the initializer expression, usually a literal, that is used to populate the variable with known values.

◆ get_type_specifier()

const TypeSpecifier & StatementVariableDeclaration::get_type_specifier ( ) const

Returns the type of the variable being declared.


The documentation for this class was generated from the following files: