Bash++
Bash++ compiler internal documentation
|
A method in a class. More...
#include <bpp.h>
Public Member Functions | |
bpp_method () | |
bpp_method (const std::string &name) | |
bpp_method (const std::string &name, bool is_virtual) | |
virtual bool | add_parameter (std::shared_ptr< bpp_method_parameter > parameter) |
Add a parameter to the method. More... | |
void | set_name (const std::string &name) |
void | set_scope (bpp_scope scope) |
void | set_virtual (bool is_virtual) |
void | set_inherited (bool is_inherited) |
bool | add_object (std::shared_ptr< bpp_object > object, bool make_local) override |
Add an object to the code entity. More... | |
std::string | get_name () const override |
std::vector< std::shared_ptr< bpp_method_parameter > > | get_parameters () const |
bpp_scope | get_scope () const |
bool | is_virtual () const |
bool | is_inherited () const |
void | destruct_local_objects (std::shared_ptr< bpp_program > program) |
Destruct all local objects. More... | |
![]() | |
bpp_code_entity () | |
virtual void | add_code (const std::string &code, bool add_newline=true) |
Add code to the code entity. More... | |
virtual void | add_code_to_previous_line (const std::string &code) |
Add code to the code entity's pre-code buffer. More... | |
virtual void | add_code_to_next_line (const std::string &code) |
Add code to the code entity's post-code buffer. More... | |
virtual void | flush_nextline_buffer () |
virtual void | flush_postline_buffer () |
virtual void | flush_code_buffers () |
virtual void | clear_all_buffers () |
virtual std::string | get_code () const |
Return the contents of the main code buffer as a string. More... | |
virtual std::string | get_pre_code () const |
Return the contents of the pre-code buffer as a string. More... | |
virtual std::string | get_post_code () const |
Return the contents of the post-code buffer as a string. More... | |
![]() | |
virtual | ~bpp_entity ()=default |
virtual bool | add_class (std::shared_ptr< bpp_class > class_) |
Add a class to this entity's list of classes. More... | |
virtual std::shared_ptr< bpp_class > | get_class () const |
virtual std::string | get_address () const |
virtual std::weak_ptr< bpp::bpp_class > | get_containing_class () const |
Get the class which contains this entity. More... | |
virtual bool | set_containing_class (std::weak_ptr< bpp::bpp_class > containing_class) |
virtual void | inherit (std::shared_ptr< bpp_entity > parent) |
Inherit from a parent entity. More... | |
virtual void | inherit (std::shared_ptr< bpp_class > parent) |
virtual std::unordered_map< std::string, std::shared_ptr< bpp_class > > | get_classes () const |
virtual std::unordered_map< std::string, std::shared_ptr< bpp_object > > | get_objects () const |
virtual std::shared_ptr< bpp_class > | get_class (const std::string &name) |
virtual std::shared_ptr< bpp_object > | get_object (const std::string &name) |
Private Member Functions | |
bool | add_object_as_parameter (std::shared_ptr< bpp_object > object) |
Add a pointer to a non-primitive object as a parameter to the method. More... | |
Private Attributes | |
std::string | name |
std::vector< std::shared_ptr< bpp_method_parameter > > | parameters |
bpp_scope | scope = SCOPE_PUBLIC |
bool | m_is_virtual = false |
bool | inherited = false |
Additional Inherited Members | |
![]() | |
std::shared_ptr< std::ostream > | code = std::make_shared<std::ostringstream>() |
std::string | nextline_buffer = "" |
std::string | postline_buffer = "" |
bool | buffers_flushed = false |
![]() | |
std::unordered_map< std::string, std::shared_ptr< bpp_class > > | classes |
A map of class names to class objects within this entity. More... | |
std::unordered_map< std::string, std::shared_ptr< bpp_object > > | objects |
A map of object names to bpp_objects within this entity. More... | |
std::unordered_map< std::string, std::shared_ptr< bpp_object > > | local_objects |
Like objects, but only for objects whose scope is local to this entity. More... | |
std::shared_ptr< bpp_class > | type = nullptr |
std::weak_ptr< bpp_class > | containing_class |
std::vector< std::shared_ptr< bpp_class > > | parents |
A method in a class.
bpp::bpp_method::bpp_method | ( | ) |
|
explicit |
bpp::bpp_method::bpp_method | ( | const std::string & | name, |
bool | is_virtual | ||
) |
|
overridevirtual |
Add an object to the code entity.
Adding an object to a code entity involves adding the necessary code to create the object. Unlike in the case where we add an object to a non-code entity, where we only need to update the object map.
This function generates the code necessary to create the object, including calling its constructor if it exists.
object | The object to add |
Reimplemented from bpp::bpp_code_entity.
|
private |
Add a pointer to a non-primitive object as a parameter to the method.
This function ensures that code within the scope of the method is able to access an object passed as an argument to the method, by adding the object to the local_objects map.
|
virtual |
Add a parameter to the method.
This function adds a parameter to the method. If the passed bpp_method_parameter is not a primitive type, it will also add the object to the local_objects map by calling add_object_as_parameter.
void bpp::bpp_method::destruct_local_objects | ( | std::shared_ptr< bpp_program > | program | ) |
Destruct all local objects.
This function destructs all local objects in the method by calling their destructors (if they exist) and then deleting them.
This is called as we exit the method, to ensure that all local objects are cleaned up.
|
overridevirtual |
Reimplemented from bpp::bpp_entity.
std::vector< std::shared_ptr< bpp_method_parameter > > bpp::bpp_method::get_parameters | ( | ) | const |
bpp_scope bpp::bpp_method::get_scope | ( | ) | const |
bool bpp::bpp_method::is_inherited | ( | ) | const |
bool bpp::bpp_method::is_virtual | ( | ) | const |
void bpp::bpp_method::set_inherited | ( | bool | is_inherited | ) |
void bpp::bpp_method::set_name | ( | const std::string & | name | ) |
void bpp::bpp_method::set_scope | ( | bpp_scope | scope | ) |
void bpp::bpp_method::set_virtual | ( | bool | is_virtual | ) |
|
private |
|
private |
|
private |
|
private |
|
private |