|
Bash++
Bash++ compiler internal documentation
|
Namespaces | |
| namespace | detail |
| namespace | ErrorHandling |
Classes | |
| class | bash_case |
| A case statement in Bash++. More... | |
| class | bash_case_pattern |
| A pattern for a case statement in Bash++. More... | |
| class | bash_command_sequence |
| A sequence of bash commands connected by '&&' and '||'. More... | |
| class | bash_for_or_select |
| A for loop or select statement in Bash++. More... | |
| class | bash_function |
| A normal Bash function. More... | |
| class | bash_if |
| An if statement in Bash++. More... | |
| class | bash_if_branch |
| A branch of an if statement in Bash++. More... | |
| class | bash_while_or_until_condition |
| The condition for a while/until loop in Bash++. More... | |
| class | bash_while_or_until_loop |
| A while/until loop in Bash++. More... | |
| class | BashppServer |
| The main server class for handling LSP requests and notifications. More... | |
| class | bpp_class |
| A class in Bash++. More... | |
| class | bpp_code_entity |
| An entity which can contain code. More... | |
| class | bpp_datamember |
| A data member in a class. More... | |
| class | bpp_delete_statement |
| A delete statement in Bash++. More... | |
| class | bpp_dynamic_cast_statement |
| A dynamic_cast statement in Bash++. More... | |
| class | bpp_dynamic_cast_target |
| The target of a dynamic_cast in Bash++. More... | |
| class | bpp_entity |
| The base class for all entities in the Bash++ compiler. More... | |
| class | bpp_method |
| A method in a class. More... | |
| class | bpp_method_parameter |
| A parameter in a method. More... | |
| class | bpp_object |
| An object in Bash++. More... | |
| class | bpp_object_assignment |
| An object assignment statement in Bash++. More... | |
| class | bpp_object_reference |
| An object reference in Bash++. More... | |
| class | bpp_program |
| The main program. More... | |
| class | bpp_string |
| The practical difference between bpp_code_entity and bpp_string is how we handle the code buffers. More... | |
| class | bpp_value_assignment |
| A value assignment statement in Bash++. More... | |
| struct | code_segment |
| A struct to hold (compiled) code segments. More... | |
| struct | diagnostic |
| Represents a diagnostic message (error, warning, info, hint) More... | |
| struct | entity_reference |
| Represents the result of resolving a reference to an entity. More... | |
| class | OwnedEntityList |
| struct | SymbolPosition |
Typedefs | |
| using | json = nlohmann::json |
Enumerations | |
| enum class | bpp_scope : uint8_t { SCOPE_PUBLIC , SCOPE_PROTECTED , SCOPE_PRIVATE , SCOPE_INACCESSIBLE } |
| enum class | reference_type : uint8_t { ref_primitive , ref_method , ref_object } |
| enum class | diagnostic_type : uint8_t { DIAGNOSTIC_ERROR , DIAGNOSTIC_WARNING , DIAGNOSTIC_INFO , DIAGNOSTIC_HINT } |
Functions | |
| 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. | |
| static 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_class > new_class, bool inline_new, bool silent) |
| Generates a code segment for creating a new object of a given class. | |
| code_segment | generate_code_for_new_method (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) |
Variables | |
| const std::shared_ptr< bpp_entity > | inaccessible_entity = std::make_shared<bpp_entity>() |
| A placeholder for an inaccessible entity (scope handling) | |
| const std::shared_ptr< bpp_datamember > | inaccessible_datamember = std::make_shared<bpp_datamember>() |
| A placeholder for an inaccessible data member of a class (scope handling) | |
| const std::shared_ptr< bpp_method > | inaccessible_method = std::make_shared<bpp_method>() |
| A placeholder for an inaccessible method of a class (scope handling) | |
| static const char | bpp_nullptr [] = "0" |
| The secret internal value of '@nullptr' in Bash++. | |
| constexpr std::array< std::string_view, 19 > | protected_keywords |
| A list of keywords that are reserved and cannot be used as identifiers in Bash++. | |
| using bpp::json = typedef nlohmann::json |
|
strong |
|
strong |
|
strong |
|
inlinestatic |
| code_segment bpp::generate_code_for_new_method | ( | 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.
| 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) |
| code_segment bpp::generate_constructor_call_code | ( | const std::string & | reference_code, |
| std::shared_ptr< bpp_class > | assumed_class | ||
| ) |
| std::shared_ptr< bpp::bpp_method > bpp::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.
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.
| containing_class | The class for which to generate the copy method |
| program | The program in which the class resides |
| code_segment bpp::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.
This function constructs a code segment to delete an object. The generated code includes:
| object | The object to be deleted. |
| object_ref | The string representing the object's reference in the compiled code. |
| code_segment bpp::generate_delete_code | ( | std::shared_ptr< bpp_object > | object, |
| const std::string & | object_ref, | ||
| std::shared_ptr< bpp::bpp_program > | program | ||
| ) |
| std::shared_ptr< bpp::bpp_method > bpp::generate_delete_method | ( | std::shared_ptr< bpp::bpp_class > | containing_class | ) |
| code_segment bpp::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 bpp::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.
This function constructs a code segment to perform a dynamic cast on an object. The generated code includes:
| reference_code | The code representing the object reference |
| class_name | The type to which we want to cast |
| code_segment bpp::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.
This function constructs a code segment to call a method on an object. The generated code includes:
| reference_code | The code representing the object reference. |
| method_name | The name of the method to be called. |
| assumed_class | The class to which the object is assumed to belong at compile-time. |
| code_segment bpp::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 | ||
| ) |
| code_segment bpp::generate_new_code | ( | const std::string & | new_address, |
| std::shared_ptr< bpp_class > | new_class, | ||
| bool | inline_new, | ||
| bool | silent | ||
| ) |
Generates a code segment for creating a new object of a given class.
This function either generates code to create a new object by calling the class's __new method, or inlines the new operation by directly assigning the data members, depending on the value of inline_new.
| new_address | Where to store the new object (empty string for runtime-determined address) |
| new_class | The class of the new object |
| inline_new | Whether to inline this new operation (make data members local variables) |
| silent | If true, the resulting pointer from a call to __new will not be outputted |
| std::shared_ptr< bpp::bpp_method > bpp::generate_new_method | ( | std::shared_ptr< bpp::bpp_class > | containing_class | ) |
| code_segment bpp::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.
This function constructs a code segment to run a specified command in a supershell. It creates a unique function name and output variable using a global counter. The generated code includes:
| code_to_run | The bash command to be executed within the supershell. |
| code_segment bpp::generate_typeof_code | ( | const std::string & | reference_code, |
| std::shared_ptr< bpp::bpp_program > | program | ||
| ) |
| 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.
| ref | The reference string |
| indirection_level | The level of indirection (0, 1, or 2) |
|
inline |
Check if a string matches any of our protected keywords.
| keyword | The string to check |
|
inline |
Check if a string is a valid identifier in Bash++.
| identifier | The string to check |
| void bpp::printValue | ( | std::ostream & | os, |
| const std::variant< Ts... > & | v | ||
| ) |
| void bpp::printValue | ( | std::ostream & | os, |
| const T & | value | ||
| ) |
|
inline |
| entity_reference bpp::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.
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.
| 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. |
|
static |
The secret internal value of '@nullptr' in Bash++.
|
inline |
A placeholder for an inaccessible data member of a class (scope handling)
|
inline |
A placeholder for an inaccessible entity (scope handling)
|
inline |
A placeholder for an inaccessible method of a class (scope handling)
|
inlineconstexpr |
A list of keywords that are reserved and cannot be used as identifiers in Bash++.