|
| 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, 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_virtual_method_call_code (const std::string &reference_code, const std::string &method_name, 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::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_constructor_call_code (const std::string &reference_code, std::shared_ptr< bpp_class > assumed_class) |
| |
| code_segment | generate_destructor_call_code (const std::string &reference_code, std::shared_ptr< bpp_class > assumed_class, bool force_static_reference, std::shared_ptr< bpp::bpp_program > program) |
| |
| 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 | generate_new_code (const std::string &new_address, std::shared_ptr< bpp::bpp_class > new_class, bool inline_new) |
| | Generate the assignments necessary to create a new object of a given class.
|
| |
| std::shared_ptr< bpp::bpp_method > | generate_copy_method (std::shared_ptr< bpp::bpp_class > containing_class, std::shared_ptr< bpp::bpp_program > program) |
| | Generates a copy method for a class.
|
| |
| std::shared_ptr< bpp::bpp_method > | generate_new_method (std::shared_ptr< bpp::bpp_class > containing_class) |
| |
| std::shared_ptr< bpp::bpp_method > | generate_delete_method (std::shared_ptr< bpp::bpp_class > containing_class) |
| |
| std::string | get_encased_ref (const std::string &ref, uint8_t indirection_level) |
| | Encases a temporary variable reference with the appropriate level of indirection.
|
| |
| entity_reference | resolve_reference_impl (const std::string &file, std::shared_ptr< bpp::bpp_entity > context, std::deque< AST::Token< std::string > > *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, auto 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 Licensed under the GNU General Public License v3.0 or later (GPL-3.0-or-later)
Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes Licensed under the GNU General Public License v3.0 or later (GPL-3.0-or-later)
Generates a copy method for a class.
The generated method will be named "__copy" and will be public and virtual. It takes, of course, the '@this' pointer as its implicit first parameter (as do all methods), and one explicit parameter: the address to copy from.
The copy-from address is dynamically cast to the containing class type, and therefore must point to an object which is convertible to the containing class type.
TODO(@rail5): This method duplicates some code from other portions of the compiler.
- Parameters
-
| containing_class | The class for which to generate the copy method |
| program | The program in which the class resides |
- Returns
- std::shared_ptr<bpp::bpp_method> The generated copy method
| code_segment bpp::generate_new_code |
( |
const std::string & |
new_address, |
|
|
std::shared_ptr< bpp::bpp_class > |
new_class, |
|
|
bool |
inline_new |
|
) |
| |
Generate the assignments necessary to create a new object of a given class.
This is used when generating the code for the __new method of a class, and also when inlining object creation in other contexts.
In the latter cases, inline_new is set to true to ensure that the created object's data members are local variables.
- Parameters
-
| new_address | Where to store the new object |
| new_class | The class of the new object |
| inline_new | Whether to inline this new operation (make data members local variables) |
- Returns
- code_segment The code segment to create the new object
| std::string bpp::get_encased_ref |
( |
const std::string & |
ref, |
|
|
uint8_t |
indirection_level |
|
) |
| |
Encases a temporary variable reference with the appropriate level of indirection.
This function takes a std::string which is the name of a shell variable we would like to use, (for example, a temporary variable created during reference resolution), and an indirection level (0, 1, or 2), and returns the variable name encased in the appropriate amount of indirection.
0: Returns 'var' (as-is, no encasing) 1: Returns '${var}' 2: Returns '${!var}'
Any other indirection level is treated as 0.
- Parameters
-
| ref | The reference string |
| indirection_level | The level of indirection (0, 1, or 2) |
- Returns
- std::string The encased reference string
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.