forb
Public Member Functions | List of all members
forbcc::variable Class Reference

Represents either an attribute of a forbcc::type_struct class or an automatic variable declared within a function. More...

#include <variable.hpp>

Inheritance diagram for forbcc::variable:
forbcc::entity forbcc::shareable< variable >

Public Member Functions

 variable ()
 Empty variable, used to preallocate variables in arrays or to use later assignment operator.
 
 variable (const std::shared_ptr< const type > &var_type, const std::string &name)
 Constructs a variable with a given type. More...
 
 ~variable () override=default
 This class is virtual, so it requires a virtual destructor.
 
 variable (variable &&)=default
 This class supports moving.
 
variableoperator= (variable &&)=default
 This class supports moving.
 
 variable (const variable &)=default
 This class supports copying.
 
variableoperator= (const variable &)=default
 This class supports copying.
 
const std::shared_ptr< const type > & var_type () const
 Returns a pointer to the type of the variable.
 
void print_declaration (code_ostream &out) const override
 Prints the variable declaration, proxy to forbcc::type::print_var_declaration, which is a virtual function, so the actual type of the variable will handle its print. More...
 
void print_definition (code_ostream &) const override
 Does nothing, variables do not require definition.
 
void print_declaration (code_ostream &out, bool force_stack) const
 Prints the declaration of a variable that might be allocated on the stack or on the heap.
 
void print_lvalue (code_ostream &out, bool force_stack=true) const
 Prints the lvalue of the given variable.
 
void print_reference (code_ostream &out) const
 Prints the variable declaration, proxy to forbcc::type::print_var_reference, which is a virtual function, so the actual type of the variable will handle its print. More...
 
void print_marshal (code_ostream &out, const marshal &do_undo, bool force_stack=true) const
 Prints the variable declaration, proxy to forbcc::type::print_var_marshal, which is a virtual function, so the actual type of the variable will handle its print. More...
 
void print_serialize (code_ostream &out, const serialize &do_undo, bool force_stack=true) const
 Prints the variable declaration, proxy to forbcc::type::print_var_serialize, which is a virtual function, so the actual type of the variable will handle its print. More...
 
- Public Member Functions inherited from forbcc::entity
 entity ()
 Constructs an empty entity, used to preallocate entity variables (like in arrays) and to later use the assignment operator to overwrite its content.
 
 entity (const std::shared_ptr< entity > &parent, const std::string &name)
 Constructs an entity within a given parent.
 
virtual ~entity ()=default
 Does nothing because the destructor of the shared_ptr handles all the stuff It's necessary for the destructor to be virtual because share_ptrs to subclasses shall be able to correctly destruct objects of the subclasses. More...
 
 entity (entity &&)=default
 This class supports moving.
 
entityoperator= (entity &&)=default
 This class supports moving.
 
 entity (const entity &)=default
 This class supports copying.
 
entityoperator= (const entity &)=default
 This class supports copying.
 
std::shared_ptr< entityparent () const
 Returns the parent of the given entity.
 
std::string name () const
 Returns the name of the given entity.
 
virtual std::string codename () const
 Returns the codename of the given entity, which is the name of the entity as seen from the global scope. More...
 

Additional Inherited Members

- Public Types inherited from forbcc::shareable< variable >
using const_T = typename std::add_const< variable >::type
 Alias to the same type T, but with const qualifier.
 
using ptr_t = std::shared_ptr< variable >
 Alias to std::shared_ptr<T>
 
using ptr_const_t = std::shared_ptr< const_T >
 Alias to std::shared_ptr<const T>
 
- Static Public Member Functions inherited from forbcc::shareable< variable >
static ptr_t new_ptr (Args &&... args)
 Calls the constructor of the class with the given arguments to create a shared_pointer to T. More...
 
static ptr_const_t new_ptr_const (Args &&... args)
 Calls the constructor of the class with the given arguments to create a shared_pointer to a const T. More...
 

Detailed Description

Represents either an attribute of a forbcc::type_struct class or an automatic variable declared within a function.

Constructor & Destructor Documentation

§ variable()

forbcc::variable::variable ( const std::shared_ptr< const type > &  var_type,
const std::string &  name 
)
inline

Constructs a variable with a given type.

Variables don't care about the scope, since they are never referred with their fully qualified name in any context.

Member Function Documentation

§ print_declaration()

void forbcc::variable::print_declaration ( code_ostream out) const
inlineoverridevirtual

Prints the variable declaration, proxy to forbcc::type::print_var_declaration, which is a virtual function, so the actual type of the variable will handle its print.

Implements forbcc::entity.

§ print_marshal()

void forbcc::variable::print_marshal ( code_ostream out,
const marshal &  do_undo,
bool  force_stack = true 
) const
inline

Prints the variable declaration, proxy to forbcc::type::print_var_marshal, which is a virtual function, so the actual type of the variable will handle its print.

§ print_reference()

void forbcc::variable::print_reference ( code_ostream out) const
inline

Prints the variable declaration, proxy to forbcc::type::print_var_reference, which is a virtual function, so the actual type of the variable will handle its print.

§ print_serialize()

void forbcc::variable::print_serialize ( code_ostream out,
const serialize &  do_undo,
bool  force_stack = true 
) const
inline

Prints the variable declaration, proxy to forbcc::type::print_var_serialize, which is a virtual function, so the actual type of the variable will handle its print.


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