compiler/stage2_l0/src/backend.l0
Module backend
Overview Symbols grouped by source file: compiler/stage2_l0/src/backend.l0
Module: backend
Source: compiler/stage2_l0/src/backend.l0 Language: Dea/L0
Imports / Includes
util.logtypestype_resolvescope_contextstd.assertstd.stringstd.hashmapstd.hashsetc_emitterdriverstd.vectorstd.textastcodegen_optionsname_resolversem_contextsymbolssignatures
Symbols
- be_ice
- be_ice_string
- be_create
- be_free
- be_type_key
- be_type_key_module
- be_type_key_name
- be_current_env
- be_current_unit
- be_current_expr_arena
- be_current_stmt_arena
- be_find_unit
- be_find_env
- be_resolve_type_ref
- be_lookup_symbol
- be_expr_type
- be_type_ptr_vec_temp_free
- be_type_ptr_map_temp_free
- be_resolve_let_type
- be_emit_with_cleanup_header_let_predecl
- be_emit_with_cleanup_header_let_assign
- be_fresh_label
- be_push_scope
- be_pop_scope
- be_push_loop_labels
- be_pop_loop_labels
- be_push_loop_cleanup_scopes
- be_pop_loop_cleanup_scopes
- be_lookup_local_var_type
- be_lookup_owned_local_name
- be_is_place_expr
- be_has_side_effects
- be_pointer_type_or_null
- be_sizeof_expr_for_type
- be_alignof_expr_for_type
- be_emit_checked_pointer_expr
- be_emit_pointer_index_lvalue
- be_is_unwrap_cast_from_place
- be_needs_arc_temp
- be_should_materialize_arc_temp
- be_materialize_arc_temp
- be_scope_chain_has_cleanup
- be_emit_retain_for_copied_value
- be_emit_copy_expr_with_retains
- be_is_int_assignable
- be_int_type_size
- be_convert_expr_with_expected_type
- be_emit_expr_with_expected_type
- be_emit_owned_expr_with_expected_type
- type_free_opt
- be_find_struct_decl
- be_find_enum_decl
- be_find_variant_decl
- be_collect_value_type_dependencies
- be_collect_type_dependencies
- be_dependency_sets_free
- be_collect_type_keys
- be_emit_type_definitions
- be_emit_line_directive
- be_emit_bare_variant_static_initializer
- be_is_static_let_initializer
- be_static_variant_symbol
- be_emit_static_ord_initializer
- be_emit_let_initializer
- be_emit_const_constructor
- be_emit_let_declarations
- be_emit_function_declarations
- be_emit_lvalue
- be_emit_binary_op
- be_emit_condition_expr
- be_emit_constructor_call
- be_emit_call
- be_emit_new_expr
- be_emit_expr
- be_emit_value_cleanup
- be_emit_struct_cleanup
- be_emit_enum_cleanup
- be_emit_cleanup_at_scope_exit
- be_emit_with_cleanup_from_scope
- be_register_inline_with_cleanup
- be_emit_cleanup_for_return
- be_emit_cleanup_for_loop_exit
- be_emit_return_stmt_with_inline_cleanup
- be_emit_pattern_bindings
- be_emit_case_literal
- be_emit_drop_stmt
- be_emit_match_stmt
- be_emit_case_stmt
- be_emit_inline_with_header_item
- be_emit_with_stmt
- be_emit_block_sequence
- be_emit_block_stmt
- be_emit_condition_branch
- be_emit_condition_value
- be_emit_if_branch
- be_emit_stmt
- be_body_reassigns_param
- be_emit_function_definitions
- be_emit_main_wrapper_if_needed
- backend_generate
- Backend
- LoopLabels
- LoopCleanupScopes
Function be_ice
func be_ice(message: string)
Abort on an internal backend error.
Parameters:
message: ICE message to report.
Function be_ice_string
func be_ice_string(message: string) -> string
Abort on an internal backend error from a string-returning helper.
Parameters:
message: ICE message to report.
Returns: Dummy return used only to satisfy control-flow typing.
Function be_create
func be_create(result: AnalysisResult*, opts: CodegenOptions*, cfg: LogConfig*) -> Backend*
Create a backend state for one code-generation pass.
Parameters:
result: Borrowed semantic analysis result.opts: Borrowed codegen options.cfg: Borrowed log configuration.
Returns: New backend state.
Function be_free
func be_free(self: Backend*)
Free a backend state.
Parameters:
self: Backend state to free.
Function be_type_key
func be_type_key(module_name: string, type_name: string) -> string
Build a stable key for one user-defined type.
Parameters:
module_name: Defining module name.type_name: Struct or enum name.
Returns: Key in module::type form.
Function be_type_key_module
func be_type_key_module(key: string) -> string
Return the module portion of a type key.
Parameters:
key: Type key inmodule::typeform.
Returns: Module-name portion of the key.
Function be_type_key_name
func be_type_key_name(key: string) -> string
Return the type-name portion of a type key.
Parameters:
key: Type key inmodule::typeform.
Returns: Type-name portion of the key.
Function be_current_env
func be_current_env(self: Backend*) -> ModuleEnv*
Return the current module environment.
Parameters:
self: Backend state to inspect.
Returns: Borrowed module environment.
Function be_current_unit
func be_current_unit(self: Backend*) -> DriverUnit*
Return the current unit.
Parameters:
self: Backend state to inspect.
Returns: Borrowed driver unit.
Function be_current_expr_arena
func be_current_expr_arena(self: Backend*) -> ExprArena*
Return the current expression arena.
Parameters:
self: Backend state to inspect.
Returns: Borrowed expression arena.
Function be_current_stmt_arena
func be_current_stmt_arena(self: Backend*) -> StmtArena*
Return the current statement arena.
Parameters:
self: Backend state to inspect.
Returns: Borrowed statement arena.
Function be_find_unit
func be_find_unit(self: Backend*, module_name: string) -> DriverUnit*?
Return a loaded driver unit by module name.
Parameters:
Returns: Matching loaded unit, or null if absent.
Function be_find_env
func be_find_env(self: Backend*, module_name: string) -> ModuleEnv*?
Return a module environment by name.
Parameters:
Returns: Matching module environment, or null if absent.
Function be_resolve_type_ref
func be_resolve_type_ref(self: Backend*, tref: TypeRef*) -> Type*?
Resolve one parsed type reference in the current module environment.
Parameters:
self: Backend state to inspect.tref: Parsed type reference.
Returns: Resolved type, or null if resolution fails.
Function be_lookup_symbol
func be_lookup_symbol(self: Backend*, name: string, module_path: StringVector*?, name_qualifier: StringVector*?) -> Symbol*?
Look up a visible symbol from the current module.
Parameters:
self: Backend state to inspect.name: Symbol name.module_path: Optional explicit module path.name_qualifier: Optional enum-name qualifier.
Returns: Matching symbol, or null if absent.
Function be_expr_type
func be_expr_type(self: Backend*, expr_id: ExprId) -> Type*?
Return the inferred type of an expression.
Parameters:
self: Backend state to inspect.expr_id: Expression id to query.
Returns: Cloned inferred type, or null if missing.
Function be_type_ptr_vec_temp_free
func be_type_ptr_vec_temp_free(items: VectorBase*?)
Free a temporary vector of optional owned Type* values.
Parameters:
items: Vector to free. Null entries are ignored.
Function be_type_ptr_map_temp_free
func be_type_ptr_map_temp_free(items: StringPtrMap*?)
Free a temporary map of owned Type* values.
Parameters:
items: Map to free.
Function be_resolve_let_type
func be_resolve_let_type(self: Backend*, stmt: StmtNode*) -> Type*
Resolve the type of one local let declaration.
Parameters:
self: Backend state to inspect.stmt: Parsedletstatement.
Returns: Resolved type.
Function be_emit_with_cleanup_header_let_predecl
func be_emit_with_cleanup_header_let_predecl(self: Backend*, stmt: StmtNode*) -> Type*?
Predeclare a nullable cleanup-block header let to its null literal.
Parameters:
self: Backend state to update.stmt: Parsedletstatement from awithheader.
Returns: Resolved nullable type when predeclared, otherwise null.
Function be_emit_with_cleanup_header_let_assign
func be_emit_with_cleanup_header_let_assign(self: Backend*, stmt: StmtNode*, var_ty: Type*)
Emit the initializer assignment for a predeclared cleanup-block header let.
Parameters:
self: Backend state to update.stmt: Parsedletstatement from awithheader.var_ty: Resolved type of the predeclared variable.
Function be_fresh_label
func be_fresh_label(self: Backend*, prefix: string) -> string
Return a fresh backend label name.
Parameters:
self: Backend state to update.prefix: Label prefix.
Returns: Unique label string.
Function be_push_scope
func be_push_scope(self: Backend*) -> ScopeContext*
Push one lexical scope and make it current.
Parameters:
self: Backend state to update.
Returns: New current scope.
Function be_pop_scope
func be_pop_scope(self: Backend*)
Pop the current lexical scope.
Parameters:
self: Backend state to update.
Function be_push_loop_labels
func be_push_loop_labels(self: Backend*, break_label: string, continue_label: string)
Push one active loop-label frame.
Parameters:
self: Backend state to update.break_label: Break target label.continue_label: Continue target label.
Function be_pop_loop_labels
func be_pop_loop_labels(self: Backend*)
Pop one active loop-label frame.
Parameters:
self: Backend state to update.
Function be_push_loop_cleanup_scopes
func be_push_loop_cleanup_scopes(self: Backend*, continue_scope: ScopeContext*, break_scope: ScopeContext*)
Push one active loop-cleanup frame.
Parameters:
self: Backend state to update.continue_scope: Scope to clean forcontinue.break_scope: Scope to clean forbreak.
Function be_pop_loop_cleanup_scopes
func be_pop_loop_cleanup_scopes(self: Backend*)
Pop one active loop-cleanup frame.
Parameters:
self: Backend state to update.
Function be_lookup_local_var_type
func be_lookup_local_var_type(self: Backend*, var_name: string) -> Type*?
Return the type of a declared local binding when present.
Parameters:
self: Backend state to inspect.var_name: Source-level variable name.
Returns: Borrowed declared type, or null if absent.
Function be_lookup_owned_local_name
func be_lookup_owned_local_name(self: Backend*, expr_id: ExprId) -> string?
Return the mangled name when a local variable is currently tracked as owned.
Parameters:
self: Backend state to inspect.expr_id: Variable-reference expression id.
Returns: Mangled local name, or null when not owned by the current scope chain.
Function be_is_place_expr
func be_is_place_expr(self: Backend*, expr_id: ExprId) -> bool
Report whether an expression refers to an existing place.
Parameters:
self: Backend state to inspect.expr_id: Expression to classify.
Returns: true for local/module places, dereferences, indexes, and fields.
Function be_has_side_effects
func be_has_side_effects(self: Backend*, expr_id: ExprId) -> bool
Report whether an expression may have side effects when evaluated.
Parameters:
self: Backend state to inspect.expr_id: Expression to classify.
Returns: true when the expression should be cached before reuse.
Function be_pointer_type_or_null
func be_pointer_type_or_null(ty: Type*?) -> Type*?
Return the represented pointer type for pointer-shaped values.
Parameters:
ty: Type to inspect.
Returns: Pointer type, or null when not pointer-shaped.
Function be_sizeof_expr_for_type
func be_sizeof_expr_for_type(ty: Type*) -> string
Return a C sizeof expression for the runtime access extent.
Parameters:
ty: Type whose value extent is required.
Returns: C expression string.
Function be_alignof_expr_for_type
func be_alignof_expr_for_type(ty: Type*) -> string
Return a C alignment expression for the runtime access target.
Parameters:
ty: Type whose alignment is required.
Returns: C expression string.
Function be_emit_checked_pointer_expr
func be_emit_checked_pointer_expr(self: Backend*, c_ptr_expr: string, ptr_ty: Type*, access_mode: string) -> string
Emit a pointer expression checked for one pointee-sized access.
Parameters:
self: Backend state to inspect.c_ptr_expr: Pointer expression.ptr_ty: L0 pointer-shaped type.access_mode: Runtime access mode expression.
Returns: Checked pointer expression.
Function be_emit_pointer_index_lvalue
func be_emit_pointer_index_lvalue(self: Backend*, c_base: string, c_index: string, base_ty: Type*, access_mode: string) -> string
Emit a checked pointer-index lvalue expression.
Parameters:
self: Backend state to inspect.c_base: Base pointer expression.c_index: Index expression.base_ty: L0 pointer-shaped base type.access_mode: Runtime access mode expression.
Returns: Checked lvalue expression.
Function be_is_unwrap_cast_from_place
func be_is_unwrap_cast_from_place(self: Backend*, expr_id: ExprId) -> bool
Report whether an expression is a borrowed cast from a place.
Outer parentheses are ignored; owner-producing ARC value-optional wraps are excluded.
Parameters:
self: Backend state to inspect.expr_id: Expression to classify.
Returns: true for a non-owner-producing cast whose source is a place expression.
Function be_needs_arc_temp
func be_needs_arc_temp(self: Backend*, expr_id: ExprId) -> bool
Report whether a non-place ARC rvalue needs temporary materialization.
Parameters:
self: Backend state to inspect.expr_id: Expression to classify.
Returns: true when the expression should be hoisted into a cleanup temp.
Function be_should_materialize_arc_temp
func be_should_materialize_arc_temp(self: Backend*, expr_id: ExprId, expr_type: Type*) -> bool
Report whether an expression should be materialized into a scope-owned temp.
Parameters:
self: Backend state to inspect.expr_id: Expression to classify.expr_type: Inferred type of the expression.
Returns: true when the expression carries ARC data and is not already a place.
Function be_materialize_arc_temp
func be_materialize_arc_temp(self: Backend*, c_expr: string, expr_type: Type*) -> string
Materialize one ARC rvalue into a scope-owned temporary.
Parameters:
self: Backend state to update.c_expr: Lowered expression to store.expr_type: Type of the stored expression.
Returns: Temporary variable name.
Function be_scope_chain_has_cleanup
func be_scope_chain_has_cleanup(self: Backend*) -> bool
Report whether any scope in the current chain has pending cleanup work.
Parameters:
self: Backend state to inspect.
Returns: true when owned values or with cleanup are present.
Function be_emit_retain_for_copied_value
func be_emit_retain_for_copied_value(self: Backend*, c_expr: string, ty: Type*)
Emit retain operations for one copied owned value.
Parameters:
self: Backend state to update.c_expr: Lowered expression containing the copied value.ty: Type of the copied value.
Function be_emit_copy_expr_with_retains
func be_emit_copy_expr_with_retains(self: Backend*, c_expr: string, ty: Type*) -> string
Materialize one copied value into a temp and retain any owned fields.
Parameters:
Returns: Lowered expression or new temp name when retain logic is needed.
Function be_is_int_assignable
func be_is_int_assignable(ty: Type*?) -> bool
Return whether a type behaves like an integer.
Parameters:
ty: Type to inspect.
Returns: true for int and byte.
Function be_int_type_size
func be_int_type_size(ty: Type*) -> int
Return the byte width of an integer builtin.
Parameters:
ty: Type to inspect.
Returns: Byte width for supported integer types.
Function be_convert_expr_with_expected_type
func be_convert_expr_with_expected_type(c_expr: string, natural_ty: Type*?, expected: Type*) -> string
Convert a lowered expression to an expected type when required.
Parameters:
c_expr: Lowered source expression.natural_ty: Natural source type.expected: Expected destination type.
Returns: Lowered expression converted as needed.
Function be_emit_expr_with_expected_type
func be_emit_expr_with_expected_type(self: Backend*, expr_id: ExprId, expected: Type*) -> string
Emit one expression with implicit conversion to an expected type.
Parameters:
self: Backend state to inspect.expr_id: Expression to lower.expected: Expected destination type.
Returns: Lowered expression string.
Function be_emit_owned_expr_with_expected_type
func be_emit_owned_expr_with_expected_type(self: Backend*, expr_id: ExprId, expected: Type*) -> string
Emit one expression for a context that creates a new owner.
Parameters:
self: Backend state to inspect.expr_id: Expression to lower.expected: Expected destination type.
Returns: Lowered expression string, with retain-on-copy when required.
Function type_free_opt
func type_free_opt(ty: Type*?)
Free an optional cloned type.
Parameters:
ty: Optional type to free.
Function be_find_struct_decl
func be_find_struct_decl(self: Backend*, module_name: string, struct_name: string) -> StructDecl*?
Look up a top-level struct declaration.
Parameters:
self: Backend state to inspect.module_name: Defining module name.struct_name: Struct name.
Returns: Matching declaration, or null if absent.
Function be_find_enum_decl
func be_find_enum_decl(self: Backend*, module_name: string, enum_name: string) -> EnumDecl*?
Look up a top-level enum declaration.
Parameters:
self: Backend state to inspect.module_name: Defining module name.enum_name: Enum name.
Returns: Matching declaration, or null if absent.
Function be_find_variant_decl
func be_find_variant_decl(self: Backend*, module_name: string, enum_name: string, variant_name: string) -> EnumVariant*?
Look up an enum variant declaration.
Parameters:
self: Backend state to inspect.module_name: Defining module name.enum_name: Enum name.variant_name: Variant name.
Returns: Matching variant declaration, or null if absent.
Function be_collect_value_type_dependencies
func be_collect_value_type_dependencies(ty: Type*, deps: StringSet*)
Add value-type dependencies for one field type.
Parameters:
ty: Type to inspect.deps: Dependency set to update.
Function be_collect_type_dependencies
func be_collect_type_dependencies(self: Backend*, type_key: string, deps: StringSet*) -> bool
Collect the value-type dependencies for one user-defined type.
Parameters:
Returns: true when the type metadata was found.
Function be_dependency_sets_free
func be_dependency_sets_free(sets: VectorBase*?)
Free a vector of dependency sets.
Parameters:
sets: Optional vector holdingStringSet*entries.
Function be_collect_type_keys
func be_collect_type_keys(self: Backend*) -> StringVector*
Collect all user-defined types in stable source order.
Parameters:
self: Backend state to inspect.
Returns: Ordered vector of type keys.
Function be_emit_type_definitions
func be_emit_type_definitions(self: Backend*)
Emit user-defined types in dependency order.
Parameters:
self: Backend state to update.
Function be_emit_line_directive
func be_emit_line_directive(self: Backend*, span: Span)
Emit a #line directive for a declaration or statement when enabled.
Parameters:
self: Backend state to update.span: Source span to report.
Function be_emit_bare_variant_static_initializer
func be_emit_bare_variant_static_initializer(self: Backend*, expr_id: ExprId, expected_type: Type*) -> string
Emit a bare zero-field enum variant as a static initializer.
Parameters:
self: Backend state to inspect.expr_id: Var-ref expression id.expected_type: Resolved binding type.
Returns: Static enum initializer, or an ICE string when invariants are broken.
Function be_is_static_let_initializer
func be_is_static_let_initializer(self: Backend*, expr_id: ExprId) -> bool
Check whether an expression belongs to the supported static-initializer subset.
Parameters:
self: Backend state to inspect.expr_id: Expression id to inspect.
Returns: true when the expression can be emitted at C file scope.
Function be_static_variant_symbol
func be_static_variant_symbol(self: Backend*, expr_id: ExprId) -> Symbol*?
Resolve the enum-variant symbol named by one static constructor expression.
Parameters:
self: Backend state to inspect.expr_id: Bare or called variant constructor expression.
Returns: Resolved variant symbol, or null when the expression is not a variant constructor.
Function be_emit_static_ord_initializer
func be_emit_static_ord_initializer(self: Backend*, expr_id: ExprId) -> string
Emit a file-scope ord initializer as a direct C enum-tag constant.
Parameters:
self: Backend state to inspect.expr_id: Staticordcall expression.
Returns: C99 constant expression for the resolved variant tag.
Function be_emit_let_initializer
func be_emit_let_initializer(self: Backend*, expr_id: ExprId, expected_type: Type*) -> string
Emit a constant initializer for a top-level let .
Parameters:
self: Backend state to inspect.expr_id: Expression id to lower.expected_type: Resolvedlettype.
Returns: Constant initializer expression.
Function be_emit_const_constructor
func be_emit_const_constructor(self: Backend*, expr_id: ExprId, expected_type: Type*) -> string
Emit a constant constructor initializer for a top-level let .
Parameters:
self: Backend state to inspect.expr_id: Call expression id.expected_type: Expected constructed type.
Returns: Constant initializer expression.
Function be_emit_let_declarations
func be_emit_let_declarations(self: Backend*)
Emit all top-level let declarations.
Parameters:
self: Backend state to update.
Function be_emit_function_declarations
func be_emit_function_declarations(self: Backend*)
Emit all function declarations.
Parameters:
self: Backend state to update.
Function be_emit_lvalue
func be_emit_lvalue(self: Backend*, expr_id: ExprId) -> string
Emit one local or module lvalue.
Parameters:
self: Backend state to inspect.expr_id: Target expression id.
Returns: Lowered lvalue expression.
Function be_emit_binary_op
func be_emit_binary_op(self: Backend*, expr_id: ExprId) -> string
Emit one binary operation.
Parameters:
self: Backend state to inspect.expr_id: Binary expression id.
Returns: Lowered binary expression.
Function be_emit_condition_expr
func be_emit_condition_expr(self: Backend*, expr_id: ExprId) -> string
Emit one top-level condition expression for direct statement headers.
Only the outermost condition operator is unwrapped; child expressions keep the normal expression emitter so precedence-preserving inner parentheses stay intact.
Parameters:
self: Backend state to inspect.expr_id: Expression id to lower.
Returns: Lowered condition expression.
Function be_emit_constructor_call
func be_emit_constructor_call(self: Backend*, expr_id: ExprId, sym: Symbol*, result_ty: Type*) -> string
Emit one struct or enum-variant constructor.
Parameters:
self: Backend state to inspect.expr_id: Call expression id.sym: Resolved constructor symbol.result_ty: Inferred result type of the call.
Returns: Lowered constructor expression.
Function be_emit_call
func be_emit_call(self: Backend*, expr_id: ExprId) -> string
Emit one call expression.
Parameters:
self: Backend state to inspect.expr_id: Call expression id.
Returns: Lowered call expression.
Function be_emit_new_expr
func be_emit_new_expr(self: Backend*, expr_id: ExprId) -> string
Emit one heap-allocation new expression.
Parameters:
self: Backend state to inspect.expr_id: New-expression id.
Returns: Lowered pointer expression.
Function be_emit_expr
func be_emit_expr(self: Backend*, expr_id: ExprId) -> string
Emit one expression.
Parameters:
self: Backend state to inspect.expr_id: Expression id to lower.
Returns: Lowered expression string.
Function be_emit_value_cleanup
func be_emit_value_cleanup(self: Backend*, c_expr: string, ty: Type*)
Emit cleanup for one by-value expression.
Parameters:
Function be_emit_struct_cleanup
func be_emit_struct_cleanup(self: Backend*, c_ptr_expr: string, struct_type: Type*)
Emit cleanup for a pointer-to-struct expression.
Parameters:
self: Backend state to update.c_ptr_expr: Lowered pointer expression.struct_type: Struct type to clean.
Function be_emit_enum_cleanup
func be_emit_enum_cleanup(self: Backend*, c_ptr_expr: string, enum_type: Type*)
Emit cleanup for a pointer-to-enum expression.
Parameters:
self: Backend state to update.c_ptr_expr: Lowered pointer expression.enum_type: Enum type to clean.
Function be_emit_cleanup_at_scope_exit
func be_emit_cleanup_at_scope_exit(self: Backend*, scope: ScopeContext*)
Emit cleanup for owned values declared in one scope.
Parameters:
Function be_emit_with_cleanup_from_scope
func be_emit_with_cleanup_from_scope(self: Backend*, scope: ScopeContext*)
Emit with cleanup recorded on one scope.
Parameters:
Function be_register_inline_with_cleanup
func be_register_inline_with_cleanup(scope: ScopeContext*, item: WithItem*)
Register one inline with cleanup item in LIFO order.
Parameters:
scope: Scope carrying inline cleanup state.item: Parsed with item whose cleanup should be registered.
Function be_emit_cleanup_for_return
func be_emit_cleanup_for_return(self: Backend*, returned_var: string?)
Emit cleanup required before returning from the current function.
Parameters:
self: Backend state to update.returned_var: Optional owned local to keep alive across cleanup.
Function be_emit_cleanup_for_loop_exit
func be_emit_cleanup_for_loop_exit(self: Backend*, is_break: bool)
Emit cleanup required before breaking or continuing out of the innermost loop.
Parameters:
self: Backend state to update.is_break:truefor break,falsefor continue.
Function be_emit_return_stmt_with_inline_cleanup
func be_emit_return_stmt_with_inline_cleanup(self: Backend*, stmt: StmtNode*, inline_scope: ScopeContext*?, inline_cleanup: StmtId)
Emit a return statement, optionally registering one inline with-item cleanup first.
Parameters:
self: Backend state to update.stmt: Parsed return statement.inline_scope: Optional with scope for a committed inline header return.inline_cleanup: Cleanup statement to register when inline_scope is present.
Function be_emit_pattern_bindings
func be_emit_pattern_bindings(self: Backend*, pattern_id: PatternId, enum_type: Type*, arm_scope: ScopeContext*)
Emit one match-pattern payload binding set.
Parameters:
self: Backend state to update.pattern_id: Pattern id to inspect.enum_type: Scrutinee enum type.arm_scope: Arm scope receiving borrowed bindings.
Function be_emit_case_literal
func be_emit_case_literal(self: Backend*, expr_id: ExprId) -> string
Emit one case literal.
Parameters:
self: Backend state to inspect.expr_id: Literal expression id.
Returns: Lowered constant expression.
Function be_emit_drop_stmt
func be_emit_drop_stmt(self: Backend*, stmt: StmtNode*)
Emit a drop statement.
Parameters:
self: Backend state to update.stmt: Parsed drop statement.
Function be_emit_match_stmt
func be_emit_match_stmt(self: Backend*, stmt: StmtNode*)
Emit a match statement.
Parameters:
self: Backend state to update.stmt: Parsed match statement.
Function be_emit_case_stmt
func be_emit_case_stmt(self: Backend*, stmt: StmtNode*)
Emit a case statement.
Parameters:
self: Backend state to update.stmt: Parsed case statement.
Function be_emit_inline_with_header_item
func be_emit_inline_with_header_item(self: Backend*, item: WithItem*, with_scope: ScopeContext*)
Emit one inline with header item and register cleanup at the committed point.
Parameters:
self: Backend state to update.item: Parsed inline with item.with_scope: Scope carrying inline cleanup state.
Function be_emit_with_stmt
func be_emit_with_stmt(self: Backend*, stmt: StmtNode*)
Emit a with statement.
Parameters:
self: Backend state to update.stmt: Parsed with statement.
Function be_emit_block_sequence
func be_emit_block_sequence(self: Backend*, block_id: StmtId)
Emit one block body sequence without outer braces.
Parameters:
self: Backend state to update.block_id: Block statement id.
Function be_emit_block_stmt
func be_emit_block_stmt(self: Backend*, stmt_id: StmtId)
Emit one lexical block statement.
Parameters:
self: Backend state to update.stmt_id: Block statement id.
Function be_emit_condition_branch
func be_emit_condition_branch(self: Backend*, expr_id: ExprId, true_label: string, false_label: string)
Emit control flow for one statement condition with short-circuit semantics.
ARC temps produced while lowering condition leaves stay inside the emitted condition block instead of being hoisted into an enclosing control-flow header.
Parameters:
self: Backend state to update.expr_id: Condition expression to lower.true_label: Jump target when the condition is true.false_label: Jump target when the condition is false.
Function be_emit_condition_value
func be_emit_condition_value(self: Backend*, expr_id: ExprId) -> string
Evaluate one statement condition into a stable boolean temp.
The returned temp is safe to reference from an if / while header because condition ARC temps are scoped to the emitted condition block and cleaned before control continues.
Parameters:
self: Backend state to update.expr_id: Condition expression to lower.
Returns: Name of the generated boolean temp.
Function be_emit_if_branch
func be_emit_if_branch(self: Backend*, stmt_id: StmtId) -> bool
Emit one if branch and report whether it ends unreachable.
Parameters:
self: Backend state to update.stmt_id: Statement id for the branch.
Returns: true when control cannot fall through the branch.
Function be_emit_stmt
func be_emit_stmt(self: Backend*, stmt_id: StmtId)
Emit one statement.
Parameters:
self: Backend state to update.stmt_id: Statement id to lower.
Function be_body_reassigns_param
func be_body_reassigns_param(self: Backend*, stmt_id: StmtId, param_name: string) -> bool
Check whether the statement sub-tree at stmt_id syntactically reassigns param_name via a bare VarRef target of an ST_ASSIGN .
Used by the function-prologue emitter to decide whether to defensively retain an ARC-typed parameter on entry.
Parameters:
self: Backend state.stmt_id: Root statement id, or negative when absent.param_name: Source-level parameter name to match against assignment targets.
Returns: true when any reachable ST_ASSIGN targets a bare VarRef with that name.
Function be_emit_function_definitions
func be_emit_function_definitions(self: Backend*)
Emit all non-extern function definitions.
Parameters:
self: Backend state to update.
Function be_emit_main_wrapper_if_needed
func be_emit_main_wrapper_if_needed(self: Backend*)
Emit the C main() wrapper when the entry module defines main .
Parameters:
self: Backend state to update.
Function backend_generate
func backend_generate(result: AnalysisResult*, opts: CodegenOptions*, cfg: LogConfig*) -> string
Generate complete C source from a typed analysis result.
Parameters:
result: Typed analysis result to lower.opts: Codegen options to honor.cfg: Logging configuration to use.
Returns: Complete generated C translation unit.
Struct Backend
Represents one Stage 2 backend generation session.
Backend Field result
result: AnalysisResult*
Backend Field opts
opts: CodegenOptions*
Backend Field cfg
cfg: LogConfig*
Backend Field emitter
emitter: CEmitter*
Backend Field current_module
current_module: string?
Backend Field current_unit
current_unit: DriverUnit*?
Backend Field current_env
current_env: ModuleEnv*?
Backend Field current_func_result
current_func_result: Type*?
Backend Field current_scope
current_scope: ScopeContext*?
Backend Field scope_stack
scope_stack: VectorBase*
Backend Field current_loop_labels
current_loop_labels: LoopLabels*?
Backend Field current_loop_cleanup_scopes
current_loop_cleanup_scopes: LoopCleanupScopes*?
Backend Field scope_counter
scope_counter: int
Backend Field label_counter
label_counter: int
Backend Field next_stmt_unreachable
next_stmt_unreachable: bool
Struct LoopLabels
Represents one active loop label pair.
LoopLabels Field parent
parent: LoopLabels*?
LoopLabels Field break_label
break_label: string
LoopLabels Field continue_label
continue_label: string
Struct LoopCleanupScopes
Represents the cleanup targets for one active loop.
LoopCleanupScopes Field parent
parent: LoopCleanupScopes*?
LoopCleanupScopes Field continue_scope
continue_scope: ScopeContext*
LoopCleanupScopes Field break_scope
break_scope: ScopeContext*
LoopCleanupScopes Field continue_scope_id
continue_scope_id: int
LoopCleanupScopes Field break_scope_id
break_scope_id: int