1 #ifndef FORBCC_VARIABLE_H 2 #define FORBCC_VARIABLE_H 5 #include <types/type.hpp> 6 #include <templates/shareable.hpp> 15 std::shared_ptr<const type> _var_type;
28 _var_type(var_type) {};
50 const std::shared_ptr<const type> &
var_type()
const {
65 _var_type->print_var_definition(out,
name(), force_stack);
70 _var_type->print_var_lvalue(out,
name(), force_stack);
76 _var_type->print_var_reference(out,
name());
82 _var_type->print_var_marshal(out,
name(), do_undo, force_stack);
88 _var_type->print_var_serialize(out,
name(), do_undo, force_stack);
95 #endif //FORBCC_VARIABLE_H 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...
Definition: variable.hpp:64
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 functio...
Definition: variable.hpp:81
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 funct...
Definition: variable.hpp:87
variable(const std::shared_ptr< const type > &var_type, const std::string &name)
Constructs a variable with a given type.
Definition: variable.hpp:26
void print_reference(code_ostream &out) const
Prints the variable declaration, proxy to forbcc::type::print_var_reference, which is a virtual funct...
Definition: variable.hpp:75
void print_declaration(code_ostream &out) const override
Prints the variable declaration, proxy to forbcc::type::print_var_declaration, which is a virtual fun...
Definition: variable.hpp:56
void print_lvalue(code_ostream &out, bool force_stack=true) const
Prints the lvalue of the given variable.
Definition: variable.hpp:69
A template that can be used to ease the declaration of a shared_pointer of a given type...
Definition: shareable.hpp:13
std::string name() const
Returns the name of the given entity.
Definition: entity.hpp:68
variable()
Empty variable, used to preallocate variables in arrays or to use later assignment operator...
Definition: variable.hpp:21
void print_definition(code_ostream &) const override
Does nothing, variables do not require definition.
Definition: variable.hpp:61
This output stream supports indentation of code lines, which are formatted at each std::endl...
Definition: code_ostream.hpp:14
~variable() override=default
This class is virtual, so it requires a virtual destructor.
Definition: code_ostream.hpp:11
const std::shared_ptr< const type > & var_type() const
Returns a pointer to the type of the variable.
Definition: variable.hpp:50
Any code entity that should be generated by the compiler: namespaces, classes, structures, methods, variables.
Definition: entity.hpp:18
Represents either an attribute of a forbcc::type_struct class or an automatic variable declared withi...
Definition: variable.hpp:13
variable & operator=(variable &&)=default
This class supports moving.