|
Bash++
Bash++ compiler internal documentation
|
An entity which can contain code. More...
#include <bpp.h>


Public Member Functions | |
| bpp_code_entity () | |
| virtual void | add_code (const std::string &code, bool add_newline=true) |
| Add code to the code entity. | |
| virtual void | add_code_to_previous_line (const std::string &code) |
| Add code to the code entity's pre-code buffer. | |
| virtual void | add_code_to_next_line (const std::string &code) |
| Add code to the code entity's post-code buffer. | |
| bool | add_object (std::shared_ptr< bpp_object > object, bool make_local=false) override |
| Add an object to the code entity. | |
| 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. | |
| virtual std::string | get_pre_code () const |
| Return the contents of the pre-code buffer as a string. | |
| virtual std::string | get_post_code () const |
| Return the contents of the post-code buffer as a string. | |
Public Member Functions inherited from bpp::bpp_entity | |
| virtual | ~bpp_entity ()=default |
| virtual bool | add_class (std::shared_ptr< bpp_class > class_) |
| Add a class to this entity's list of classes. | |
| virtual std::shared_ptr< bpp_class > | get_class () |
| virtual std::string | get_address () const |
| virtual void | set_name (const std::string &name) |
| virtual std::string | get_name () const |
| virtual std::weak_ptr< bpp::bpp_class > | get_containing_class () |
| Get the class which contains this entity. | |
| 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. | |
| virtual void | inherit (std::shared_ptr< bpp_class > parent) |
| void | set_definition_position (const std::string &file, uint64_t line, uint64_t column) |
| void | add_reference (const std::string &file, uint64_t line, uint64_t column) |
| bpp::SymbolPosition | get_initial_definition () const |
| std::list< bpp::SymbolPosition > | get_references () const |
| std::unordered_map< std::string, std::shared_ptr< bpp_class > > | get_classes () const |
| std::unordered_map< std::string, std::shared_ptr< bpp_object > > | get_objects () const |
| std::shared_ptr< bpp_class > | get_class (const std::string &name) |
| std::shared_ptr< bpp_object > | get_object (const std::string &name) |
| std::shared_ptr< bpp_class > | get_parent () const |
Protected Attributes | |
| std::shared_ptr< std::ostream > | code = std::make_shared<std::ostringstream>() |
| std::string | nextline_buffer = "" |
| std::string | postline_buffer = "" |
| bool | buffers_flushed = false |
Protected Attributes inherited from bpp::bpp_entity | |
| std::string | name = "" |
| std::unordered_map< std::string, std::shared_ptr< bpp_class > > | classes |
| A map of class names to class objects within this entity. | |
| std::unordered_map< std::string, std::shared_ptr< bpp_object > > | objects |
| A map of object names to bpp_objects within this entity. | |
| 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. | |
| std::shared_ptr< bpp_class > | type = nullptr |
| std::weak_ptr< bpp_class > | containing_class |
| std::vector< std::shared_ptr< bpp_class > > | parents |
| bpp::SymbolPosition | initial_definition |
| std::list< bpp::SymbolPosition > | references |
An entity which can contain code.
Such as a method, a supershell, or the program itself
This class provides the basic functionality for entities which can contain code Including 3 distinct code buffers:
Generally, the pre_code and post_code are used to set up and clean up the environment
This class also provides the ability to add code to the pre_code, code, and post_code buffers And to flush those buffers when necessary
| bpp::bpp_code_entity::bpp_code_entity | ( | ) |
|
virtual |
Add code to the code entity.
This function adds code to the code entity's primary buffer. If the code contains a newline character, all code buffers are flushed. This ensures that the pre- and post- code relevant to each particular line of code is placed before and after the relevant line of code.
| code | The code to add |
| add_newline | Whether to add a newline character after the code (default: true) |
Reimplemented in bpp::bpp_string.
|
virtual |
Add code to the code entity's post-code buffer.
Reimplemented in bpp::bpp_string.
|
virtual |
Add code to the code entity's pre-code buffer.
Reimplemented in bpp::bpp_string.
|
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_entity.
Reimplemented in bpp::bpp_method.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Return the contents of the main code buffer as a string.
Reimplemented in bpp::bpp_string, bpp::bash_while_loop, and bpp::bash_if_branch.
|
virtual |
Return the contents of the post-code buffer as a string.
Reimplemented in bpp::bpp_string, bpp::bash_while_loop, and bpp::bash_if_branch.
|
virtual |
Return the contents of the pre-code buffer as a string.
Reimplemented in bpp::bpp_string, bpp::bash_while_loop, and bpp::bash_if_branch.
|
protected |
|
protected |
|
protected |
|
protected |