41#ifndef COMPILER_HIR_LOWERING_MVP_H
42#define COMPILER_HIR_LOWERING_MVP_H
61 if (
typed ==
nullptr or expr ==
nullptr)
70 if (
typed ==
nullptr or function ==
nullptr)
128 node->bool_value ?
"true" :
"false",
159 for (
size_t i = 0; i < node->arguments.size(); ++i)
186 if (
typed !=
nullptr)
194 node->initializer !=
nullptr
212 for (
size_t i = 0; i < node->statements.size(); ++i)
213 block->statements.append(
lower_stmt(node->statements.access(i)));
214 block->
span = node->span;
260 if (function ==
nullptr)
265 for (
size_t i = 0; i < function->
parameters.size(); ++i)
269 if (
typed !=
nullptr)
289 if (module ==
nullptr)
293 for (
size_t i = 0; i <
module->functions.size(); ++i)
295 for (
size_t i = 0; i <
module->statements.size(); ++i)
Reusable typed high-level IR model independent from any concrete frontend.
Typed semantic pass connecting the AST, the name pass, and type constraints.
Arena-backed ownership context for HIR nodes.
T * make(Args &&...args)
Allocates and constructs one HIR object.
Lowers the MVP typed AST into HIR.
Compiler_HIR_Function * lower_function(const Compiler_Function_Decl *function)
Lowers one function declaration into HIR.
Compiler_HIR_Stmt * lower_stmt(const Compiler_Stmt *stmt)
Compiler_HIR_Module * lower_module(const Compiler_Module *module)
Lowers one module into HIR.
Compiler_HIR_Lowering(Compiler_HIR_Context &context, const Compiler_Typed_Semantic_Analyzer &analysis) noexcept
Constructs a lowering helper.
Compiler_Type_Id invalid_type() const noexcept
Compiler_HIR_Expr * lower_expr(const Compiler_Expr *expr)
const Compiler_Typed_Semantic_Analyzer * typed
Compiler_Type_Id function_type(const Compiler_Function_Decl *function) const noexcept
Compiler_Type_Id expr_type(const Compiler_Expr *expr) const noexcept
Compiler_HIR_Context * hir
Compiler_Type_Id invalid_type() const noexcept
Returns the preloaded Invalid type id.
Inference-oriented semantic pass for the MVP compiler front-end.
Compiler_Type_Id let_type(const Compiler_Let_Stmt *stmt) const noexcept
Returns the inferred type of one let binding, or 0 if unknown.
Compiler_Type_Id inferred_type(const Compiler_Expr *expr) const noexcept
Returns the inferred type of one expression, or 0 if unknown.
Compiler_Type_Id function_type(const Compiler_Function_Decl *function) const noexcept
Returns the inferred type of one function, or 0 if unknown.
Compiler_Type_Id parameter_type(const Compiler_Function_Decl *function, const size_t index) const noexcept
Returns the inferred type of one parameter, or 0 if unknown.
const Compiler_Type_Context & type_context() const noexcept
Returns the internal type context.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
@ Grouping
Parenthesized expression.
@ Unary
Prefix unary operation (e.g., -x, !p).
@ Identifier
Variable or function name reference.
@ Integer_Literal
Numeric integer constant.
@ Invalid
Placeholder for malformed expressions.
@ Char_Literal
Character constant.
@ Binary
Infix binary operation (e.g., x + y).
@ Call
Function or method call.
@ String_Literal
String constant.
@ Bool_Literal
Boolean constant (true/false).
@ While
Loop while a condition is true.
@ Invalid
Placeholder for malformed statements.
@ Expr
Expression evaluated for side effects (e.g., assignment, call).
@ If
Conditional execution.
@ Return
Exit current function with an optional value.
@ Continue
Skip to the next iteration of the innermost loop.
@ Let
Variable declaration and optional initialization.
@ Block
Scoped sequence of statements.
@ Break
Immediate exit from the innermost loop.
and
Check uniqueness with explicit hash + equality functors.
Compiler_Operator_Kind compiler_operator_from_token_kind(const Compiler_Token_Kind kind) noexcept
Maps one reference-frontend token kind into a reusable operator kind.
Source_Span span
Source region covered by this node.
Node representing an infix binary operation.
Node representing a braced sequence of statements.
Node representing a function or method call.
Node representing an expression evaluated as a statement.
Abstract base class for expression nodes.
Compiler_Expr_Kind kind
Specific expression type.
Node representing a top-level function declaration.
Source_Span name_span
Location of the function name token.
std::string name
Function name.
DynArray< Compiler_Param > parameters
Ordered list of parameters.
Compiler_Block_Stmt * body
Scoped body of the function.
Node representing an expression explicitly wrapped in parentheses.
Structured block statement.
Typed function call expression.
DynArray< Compiler_HIR_Expr * > arguments
Call arguments.
Typed constant expression.
continue statement in HIR.
Expression statement in HIR.
Base class for HIR expressions.
Structured conditional statement.
Invalid HIR expression placeholder.
Invalid HIR statement placeholder.
Typed lexical binding statement.
Source_Span span
Source region associated with the HIR node.
Base class for HIR statements.
Typed variable reference expression.
Structured while-loop statement.
Node representing a named identifier reference.
Node representing a conditional branch.
Node representing a local variable binding.
Node representing a literal value.
Node representing a complete translation unit or module.
DynArray< Compiler_Stmt * > statements
Optional top-level code.
DynArray< Compiler_Function_Decl * > functions
Top-level function definitions.
Node representing a return from the current function.
Source_Span span
Aggregate source span.
Abstract base class for statement nodes.
Compiler_Stmt_Kind kind
Specific statement type.
Node representing a prefix unary operation.
Node representing a while-loop.