|
bool | is_protected_keyword (const std::string &keyword) |
| Check if a string matches any of our protected keywords.
|
|
bool | is_valid_identifier (const std::string &identifier) |
| Check if a string is a valid identifier in Bash++.
|
|
code_segment | generate_supershell_code (const std::string &code_to_run, bool in_while_condition, std::shared_ptr< bash_while_condition > current_while_condition, std::shared_ptr< bpp::bpp_program > program) |
| Generates a supershell code segment for executing a bash command.
|
|
code_segment | generate_delete_code (std::shared_ptr< bpp::bpp_object > object, const std::string &object_ref, std::shared_ptr< bpp::bpp_program > program) |
| Generates a code segment for deleting an object.
|
|
code_segment | generate_method_call_code (const std::string &reference_code, const std::string &method_name, std::shared_ptr< bpp::bpp_class > assumed_class, bool force_static_reference, std::shared_ptr< bpp::bpp_program > program) |
| Generates a code segment for calling a method.
|
|
code_segment | generate_dynamic_cast_code (const std::string &reference_code, const std::string &class_name, std::shared_ptr< bpp::bpp_program > program) |
| Generates a code segment for performing a dynamic cast.
|
|
code_segment | generate_typeof_code (const std::string &reference_code, std::shared_ptr< bpp::bpp_program > program) |
|
code_segment | inline_new (const std::string &new_address, std::shared_ptr< bpp::bpp_class > new_class) |
| Generates a code segment to INLINE class's "new" function within a method.
|
|
entity_reference | resolve_reference_impl (const std::string &file, std::shared_ptr< bpp::bpp_entity > context, std::deque< antlr4::tree::TerminalNode * > *nodes, std::deque< std::string > *identifiers, bool declare_local, std::shared_ptr< bpp::bpp_program > program) |
| Resolves a reference to an entity in a particular context.
|
|
code_segment | generate_delete_code (std::shared_ptr< bpp_object > object, const std::string &object_ref, std::shared_ptr< bpp::bpp_program > program) |
|
code_segment | generate_method_call_code (const std::string &reference_code, const std::string &method_name, std::shared_ptr< bpp_class > assumed_class, bool force_static_reference, std::shared_ptr< bpp::bpp_program > program) |
|
entity_reference | resolve_reference (const std::string &file, std::shared_ptr< bpp::bpp_entity > context, std::deque< std::string > *identifiers, bool declare_local, std::shared_ptr< bpp::bpp_program > program) |
|
entity_reference | resolve_reference (const std::string &file, std::shared_ptr< bpp::bpp_entity > context, std::deque< antlr4::tree::TerminalNode * > *identifiers, bool declare_local, std::shared_ptr< bpp::bpp_program > program) |
|
template<typename T > |
void | printValue (std::ostream &os, const T &value) |
|
template<typename... Ts> |
void | printValue (std::ostream &os, const std::variant< Ts... > &v) |
|
Copyright (C) 2025 rail5 Bash++: Bash with classes
Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes
Generates a code segment to INLINE class's "new" function within a method.
This is only to be used inside a method.
Rather than calling the class's "new" function, by inlining it, we can ensure that all instantiated objects are purely local to the method. This eliminates any issues with scope and recursion.
However, this change has resulted in some significant code duplication:
- This function duplicates code in bpp_program::add_class, with the difference that the created variables are declared 'local'
- bpp_method now has an override for add_object which is identical to that in its parent class bpp_code_entity, with the difference that rather than adding code which will call the class's "new" function at runtime, it adds the code generated by this function.
This will have to be handled soon.
- Parameters
-
new_address | The address of the new object |
new_class | The class of the new object |
- Returns
- A code segment structure containing the complete new code:
- pre_code: All of the code necessary to create the object
- post_code: Empty
- code: Empty
entity_reference bpp::resolve_reference_impl |
( |
const std::string & |
file, |
|
|
std::shared_ptr< bpp::bpp_entity > |
context, |
|
|
std::deque< antlr4::tree::TerminalNode * > * |
nodes, |
|
|
std::deque< std::string > * |
identifiers, |
|
|
bool |
declare_local, |
|
|
std::shared_ptr< bpp::bpp_program > |
program |
|
) |
| |
Resolves a reference to an entity in a particular context.
This function resolves a reference to an entity (object, method, or data member) based on a sequence of identifiers.
It does this by recursively scanning the current context for the requested identifier, and then setting a new context based on the resolution of that identifier. I.e., for {object, method}, it will first scan the current context for 'object', and then scan the 'object' context for 'method'.
If passing a self-reference (@this.... or @super....), The self-referential keyword should be the first node in the identifiers deque.
- Parameters
-
file | The source file in which the reference is being resolved. |
context | The context (code_entity) in which to resolve the reference. |
nodes | A deque of TerminalNode pointers representing the identifiers in the reference. |
identifiers | A deque of strings representing the identifiers in the reference. |
program | The program in which the reference is being resolved. |
- Returns
- An entity_reference structure containing:
- entity: A shared pointer to the resolved entity (object, method, or data member).
- reference_code: A code_segment containing the code to access the entity.
- created_first_temporary_variable: Whether a first temporary variable was necessary in the compiled code
- created_second_temporary_variable: Whether a second temporary variable was necessary in the compiled code
- class_containing_the_method: The class containing the method, if applicable.
- error: An optional reference_error structure containing an error message and relevant token if the reference could not be resolved.