|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Small reusable helper that allocates and connects HIR nodes. More...
#include <Compiler_HIR_Builder.H>
Public Member Functions | |
| Compiler_HIR_Builder (Compiler_HIR_Context &context) noexcept | |
Builds HIR nodes inside context. | |
| Compiler_HIR_Context & | context () const noexcept |
| Returns the underlying ownership context. | |
| Compiler_HIR_Module * | make_module (const Source_Span &span={}) const |
| Allocates one empty module. | |
| Compiler_HIR_Block_Stmt * | make_block (const Source_Span &lbrace={}, const Source_Span &rbrace={}) const |
| Allocates one structured block statement. | |
| Compiler_HIR_Function * | make_function (std::string name, const Compiler_Type_Id type_id=0, const Source_Span &name_span={}, Compiler_HIR_Block_Stmt *body=nullptr, const Source_Span &span={}) const |
| Allocates one function node without inserting it into any module. | |
| Compiler_HIR_Invalid_Expr * | make_invalid_expr (const Compiler_Type_Id type_id=0, const Source_Span &span={}) const |
| Allocates one invalid expression placeholder. | |
| Compiler_HIR_Constant_Expr * | make_constant (const Compiler_HIR_Constant_Kind kind, const Compiler_Type_Id type_id, std::string text, const Source_Span &span={}, const bool bool_value=false) const |
| Allocates one generic constant expression. | |
| Compiler_HIR_Constant_Expr * | make_unit_constant (const Compiler_Type_Id type_id, const Source_Span &span={}) const |
Allocates one unit constant expression. | |
| Compiler_HIR_Constant_Expr * | make_bool_constant (const bool value, const Compiler_Type_Id type_id, const Source_Span &span={}) const |
| Allocates one boolean constant expression. | |
| Compiler_HIR_Constant_Expr * | make_integer_constant (const long long value, const Compiler_Type_Id type_id, const Source_Span &span={}) const |
| Allocates one integer constant expression. | |
| Compiler_HIR_Constant_Expr * | make_string_constant (std::string text, const Compiler_Type_Id type_id, const Source_Span &span={}) const |
| Allocates one string constant expression. | |
| Compiler_HIR_Constant_Expr * | make_character_constant (std::string text, const Compiler_Type_Id type_id, const Source_Span &span={}) const |
| Allocates one character constant expression. | |
| Compiler_HIR_Variable_Expr * | make_variable (std::string name, const Compiler_Type_Id type_id=0, const Source_Span &span={}) const |
| Allocates one variable-reference expression. | |
| Compiler_HIR_Unary_Expr * | make_unary (const Compiler_Operator_Kind op, Compiler_HIR_Expr *operand, const Compiler_Type_Id type_id=0, const Source_Span &operator_span={}) const |
| Allocates one unary expression. | |
| Compiler_HIR_Binary_Expr * | make_binary (Compiler_HIR_Expr *lhs, const Compiler_Operator_Kind op, Compiler_HIR_Expr *rhs, const Compiler_Type_Id type_id=0, const Source_Span &operator_span={}) const |
| Allocates one binary expression. | |
| Compiler_HIR_Call_Expr * | make_call (Compiler_HIR_Expr *callee, const Compiler_Type_Id type_id=0, const Source_Span &lparen_span={}, const Source_Span &rparen_span={}) const |
| Allocates one call expression without arguments. | |
| Compiler_HIR_Invalid_Stmt * | make_invalid_stmt (const Source_Span &span={}) const |
| Allocates one invalid statement placeholder. | |
| Compiler_HIR_Eval_Stmt * | make_eval_stmt (Compiler_HIR_Expr *expr, const Source_Span &span={}) const |
| Allocates one expression statement. | |
| Compiler_HIR_Let_Stmt * | make_let_stmt (std::string name, const Compiler_Type_Id type_id, const Source_Span &name_span={}, Compiler_HIR_Expr *initializer=nullptr, const Source_Span &span={}) const |
| Allocates one lexical binding statement. | |
| Compiler_HIR_Return_Stmt * | make_return_stmt (Compiler_HIR_Expr *value=nullptr, const Source_Span &span={}) const |
| Allocates one return statement. | |
| Compiler_HIR_If_Stmt * | make_if_stmt (Compiler_HIR_Expr *condition, Compiler_HIR_Stmt *then_branch, Compiler_HIR_Stmt *else_branch=nullptr, const Source_Span &if_span={}, const Source_Span &else_span={}) const |
| Allocates one structured conditional statement. | |
| Compiler_HIR_While_Stmt * | make_while_stmt (Compiler_HIR_Expr *condition, Compiler_HIR_Stmt *body, const Source_Span &keyword_span={}) const |
| Allocates one structured while-loop statement. | |
| Compiler_HIR_Break_Stmt * | make_break_stmt (const Source_Span &span={}) const |
Allocates one break statement. | |
| Compiler_HIR_Continue_Stmt * | make_continue_stmt (const Source_Span &span={}) const |
Allocates one continue statement. | |
Static Public Member Functions | |
| static void | append_function (Compiler_HIR_Module &module, Compiler_HIR_Function *function) |
Appends one function to module and updates the module span. | |
| static void | append_top_level_statement (Compiler_HIR_Module &module, Compiler_HIR_Stmt *stmt) |
Appends one top-level statement to module and updates the span. | |
| static void | append_statement (Compiler_HIR_Block_Stmt &block, Compiler_HIR_Stmt *stmt) |
Appends one nested statement to block and updates the span. | |
| static void | set_body (Compiler_HIR_Function &function, Compiler_HIR_Block_Stmt *body) noexcept |
Attaches body to function and refreshes the aggregate span. | |
| static Compiler_HIR_Param & | add_parameter (Compiler_HIR_Function &function, std::string name, const Compiler_Type_Id type_id, const Source_Span &span={}) |
Adds one parameter metadata entry to function. | |
| static void | append_argument (Compiler_HIR_Call_Expr &call, Compiler_HIR_Expr *argument) |
Appends one argument to call and updates the aggregate span. | |
Static Private Member Functions | |
| static void | merge_span (Source_Span &dst, const Source_Span &src) noexcept |
Private Attributes | |
| Compiler_HIR_Context * | hir = nullptr |
Small reusable helper that allocates and connects HIR nodes.
The builder is intentionally lightweight: it owns no memory itself and only wraps a Compiler_HIR_Context. All nodes remain owned by the associated context.
Definition at line 53 of file Compiler_HIR_Builder.H.
|
inlineexplicitnoexcept |
Builds HIR nodes inside context.
Definition at line 71 of file Compiler_HIR_Builder.H.
|
inlinestatic |
Adds one parameter metadata entry to function.
Definition at line 139 of file Compiler_HIR_Builder.H.
Referenced by Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inlinestatic |
Appends one argument to call and updates the aggregate span.
Definition at line 244 of file Compiler_HIR_Builder.H.
References ah_runtime_error_unless, merge_span(), and Aleph::Compiler_HIR_Node::span.
Referenced by Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inlinestatic |
Appends one function to module and updates the module span.
Definition at line 86 of file Compiler_HIR_Builder.H.
References ah_runtime_error_unless, merge_span(), and Aleph::Compiler_HIR_Node::span.
Referenced by Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inlinestatic |
Appends one nested statement to block and updates the span.
Definition at line 111 of file Compiler_HIR_Builder.H.
References ah_runtime_error_unless, merge_span(), Aleph::Compiler_HIR_Node::span, and Aleph::Compiler_SSA_Block::span.
Referenced by Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inlinestatic |
Appends one top-level statement to module and updates the span.
Definition at line 95 of file Compiler_HIR_Builder.H.
References ah_runtime_error_unless, merge_span(), and Aleph::Compiler_HIR_Node::span.
Referenced by Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inlinenoexcept |
Returns the underlying ownership context.
Definition at line 74 of file Compiler_HIR_Builder.H.
References hir.
|
inline |
Allocates one binary expression.
Definition at line 225 of file Compiler_HIR_Builder.H.
Referenced by Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inline |
Allocates one structured block statement.
Definition at line 104 of file Compiler_HIR_Builder.H.
Referenced by Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inline |
Allocates one boolean constant expression.
Definition at line 174 of file Compiler_HIR_Builder.H.
|
inline |
Allocates one break statement.
Definition at line 300 of file Compiler_HIR_Builder.H.
|
inline |
Allocates one call expression without arguments.
Definition at line 235 of file Compiler_HIR_Builder.H.
Referenced by Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inline |
Allocates one character constant expression.
Definition at line 200 of file Compiler_HIR_Builder.H.
|
inline |
Allocates one generic constant expression.
Definition at line 157 of file Compiler_HIR_Builder.H.
|
inline |
Allocates one continue statement.
Definition at line 306 of file Compiler_HIR_Builder.H.
|
inline |
Allocates one expression statement.
Definition at line 259 of file Compiler_HIR_Builder.H.
|
inline |
Allocates one function node without inserting it into any module.
Definition at line 120 of file Compiler_HIR_Builder.H.
Referenced by Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inline |
Allocates one structured conditional statement.
Definition at line 282 of file Compiler_HIR_Builder.H.
|
inline |
Allocates one integer constant expression.
Definition at line 183 of file Compiler_HIR_Builder.H.
Referenced by Aleph::Compiler_Line_Frontend::build_hir_operand(), Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inline |
Allocates one invalid expression placeholder.
Definition at line 150 of file Compiler_HIR_Builder.H.
|
inline |
Allocates one invalid statement placeholder.
Definition at line 253 of file Compiler_HIR_Builder.H.
|
inline |
Allocates one lexical binding statement.
Definition at line 265 of file Compiler_HIR_Builder.H.
Referenced by Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inline |
Allocates one empty module.
Definition at line 80 of file Compiler_HIR_Builder.H.
Referenced by Aleph::Compiler_Line_Frontend::lower_hir(), and main().
|
inline |
Allocates one return statement.
Definition at line 275 of file Compiler_HIR_Builder.H.
Referenced by Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inline |
Allocates one string constant expression.
Definition at line 192 of file Compiler_HIR_Builder.H.
|
inline |
Allocates one unary expression.
Definition at line 216 of file Compiler_HIR_Builder.H.
|
inline |
Allocates one unit constant expression.
Definition at line 167 of file Compiler_HIR_Builder.H.
|
inline |
Allocates one variable-reference expression.
Definition at line 208 of file Compiler_HIR_Builder.H.
Referenced by Aleph::Compiler_Line_Frontend::build_hir_operand(), Aleph::Compiler_Line_Frontend::lower_hir(), main(), and TEST().
|
inline |
Allocates one structured while-loop statement.
Definition at line 292 of file Compiler_HIR_Builder.H.
|
inlinestaticprivatenoexcept |
Definition at line 57 of file Compiler_HIR_Builder.H.
References Aleph::compiler_hir_merge_spans().
Referenced by append_argument(), append_function(), append_statement(), append_top_level_statement(), and set_body().
|
inlinestaticnoexcept |
Attaches body to function and refreshes the aggregate span.
Definition at line 130 of file Compiler_HIR_Builder.H.
References merge_span(), and Aleph::Compiler_HIR_Node::span.
|
private |
Definition at line 55 of file Compiler_HIR_Builder.H.
Referenced by context().