forb
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
forbcc::type_array Class Reference

Identifies an array of a given type, to be used in forbcc::method or in forbcc::type_struct definitions. More...

#include <type_array.hpp>

Inheritance diagram for forbcc::type_array:
forbcc::type forbcc::shareable< type_array > forbcc::entity

Public Types

using length_t = long
 The type of the length attribute (which is a signed type, but values less than zero are considered invalid)
 
using type_array_list = ordered_unique_list< std::shared_ptr< const type_array >>
 The type of the global list of all known type_array pointers.
 
- Public Types inherited from forbcc::shareable< type_array >
using const_T = typename std::add_const< type_array >::type
 Alias to the same type T, but with const qualifier.
 
using ptr_t = std::shared_ptr< type_array >
 Alias to std::shared_ptr<T>
 
using ptr_const_t = std::shared_ptr< const_T >
 Alias to std::shared_ptr<const T>
 

Public Member Functions

 type_array ()
 Empty array type, used to preallocate variables in arrays or to use later assignment operator.
 
 type_array (const std::shared_ptr< const type > &item_type, const length_t length)
 Any trivially copyable type can be accepted as an array item type (except another array_type), while the length of the array must be a strictly positive integer. More...
 
 type_array (const type_array *item_type, const int length)=delete
 Arrays of arrays cannot be declared.
 
 ~type_array () override=default
 This class is virtual, so it requires a virtual destructor.
 
 type_array (type_array &&)=default
 This class supports moving.
 
type_arrayoperator= (type_array &&)=default
 This class supports moving.
 
 type_array (const type_array &)=default
 This class supports copying.
 
type_arrayoperator= (const type_array &)=default
 This class supports copying.
 
void print_declaration (code_ostream &) const override
 Does nothing, primitive types do not need to be declared.
 
void print_definition (code_ostream &) const override
 Does nothing, primitive types do not need to be defined.
 
std::shared_ptr< const typeitem_type () const
 Returns the type of the items of the given array.
 
length_t length () const
 Returns the length of the array.
 
void print_var_declaration (code_ostream &out, const std::string &var_name) const override
 Prints the declaration of a variable of the given type (no semicolon).
 
void print_var_definition (code_ostream &out, const std::string &var_name, bool force_stack) const override
 Print the definition of a variable of this type.
 
void print_var_lvalue (code_ostream &out, const std::string &var_name, bool is_stack) const override
 Print the acquisition of the value of a variable of this type.
 
void print_var_reference (code_ostream &out, const std::string &var_name) const override
 Prints the declaration of a reference variable of the given type (no semicolon).
 
void print_var_marshal (code_ostream &out, const std::string &var_name, const marshal &do_undo, bool force_stack) const override
 Prints the marshalling/unmarshalling operation of a variable of the given type.
 
void print_var_serialize (code_ostream &out, const std::string &var_name, const serialize &do_undo, bool force_stack) const override
 Prints the serialization/deserialization of a variable of the given type.
 
size_t size_of () const override
 Returns the size of the given type.
 
size_t alignment () const override
 Returns the alignment of the given type.
 
- Public Member Functions inherited from forbcc::type
 type ()
 Empty type, used to preallocate types in arrays or to use later assignment operator.
 
 type (const std::shared_ptr< module > &parent, const std::string &name)
 Using constructors from superclass.
 
 ~type () override=default
 This class is virtual, so it requires a virtual destructor.
 
 type (type &&)=default
 This class supports moving.
 
typeoperator= (type &&)=default
 This class supports moving.
 
 type (const type &)=default
 This class supports copying.
 
typeoperator= (const type &)=default
 This class supports copying.
 
void print_var_lvalue (code_ostream &out, const std::string &var_name) const
 Print the acquisition of the value of a variable of this type.
 
void print_var_marshal (code_ostream &out, const std::string &var_name, const marshal &do_undo) const
 Print the actions needed to either marshal or unmarshal a variable of this type.
 
void print_var_serialize (code_ostream &out, const std::string &var_name, const serialize &do_undo) const
 Print the actions needed to either serialize or deserialize a variable of this type.
 
- 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...
 

Static Public Member Functions

static std::string to_identifier (const std::shared_ptr< const type > &item_type, const length_t length)
 Converts a pair of item_type and length to an unique identifier, to be used when storing known array types.
 
- Static Public Member Functions inherited from forbcc::shareable< type_array >
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...
 

Static Public Attributes

static type_array_list arrays
 The list of all known arrays. More...
 

Detailed Description

Identifies an array of a given type, to be used in forbcc::method or in forbcc::type_struct definitions.

Constructor & Destructor Documentation

§ type_array()

forbcc::type_array::type_array ( const std::shared_ptr< const type > &  item_type,
const length_t  length 
)
inline

Any trivially copyable type can be accepted as an array item type (except another array_type), while the length of the array must be a strictly positive integer.

NOTICE that no checking is done to ensure that item_type is not an array.

Member Data Documentation

§ arrays

forbcc::type_array::type_array_list forbcc::type_array::arrays
static

The list of all known arrays.

Basically it's a dictionary of all known array types, to avoid re-declaration of already-defined types. Each type is characterized both by its item type and its length.


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