state.l0
Module: backend.state
Source: compiler/stage2_l0/src/backend/state.l0 Language: Dea/L0
Imports / Includes
typestype_resolvescope_contextstd.assertstd.vectorstd.hashmapstd.hashsetstd.stringstd.textastutil.logc_emitter.statecodegen_optionssymbolsdriverc_emitter.namessem_contextname_resolver
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_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_scope_chain_has_cleanup
- be_is_int_assignable
- be_int_type_size
- type_free_opt
- be_find_struct_decl
- be_find_enum_decl
- be_find_variant_decl
- be_emit_line_directive
- Backend
- LoopLabels
- LoopCleanupScopes
Function be_ice
1
func be_ice(message: string)
Abort on an internal backend error.
Parameters:
message: ICE message to report.
Function be_ice_string
1
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
1
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
1
func be_free(self: Backend*)
Free a backend state.
Parameters:
self: Backend state to free.
Function be_type_key
1
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
1
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
1
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
1
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
1
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
1
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
1
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
1
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
1
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
1
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
1
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
1
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
1
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
1
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
1
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_fresh_label
1
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
1
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
1
func be_pop_scope(self: Backend*)
Pop the current lexical scope.
Parameters:
self: Backend state to update.
Function be_push_loop_labels
1
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
1
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
1
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
1
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
1
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
1
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
1
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
1
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
1
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_scope_chain_has_cleanup
1
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_is_int_assignable
1
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
1
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 type_free_opt
1
func type_free_opt(ty: Type*?)
Free an optional cloned type.
Parameters:
ty: Optional type to free.
Function be_find_struct_decl
1
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
1
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
1
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_emit_line_directive
1
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.
Struct Backend
Represents one Stage 2 backend generation session.
Backend Field result
1
result: AnalysisResult*
Backend Field opts
1
opts: CodegenOptions*
Backend Field cfg
1
cfg: LogConfig*
Backend Field emitter
1
emitter: CEmitter*
Backend Field current_module
1
current_module: string?
Backend Field current_unit
1
current_unit: DriverUnit*?
Backend Field current_env
1
current_env: ModuleEnv*?
Backend Field current_func_result
1
current_func_result: Type*?
Backend Field current_scope
1
current_scope: ScopeContext*?
Backend Field scope_stack
1
scope_stack: VectorBase*
Backend Field current_loop_labels
1
current_loop_labels: LoopLabels*?
Backend Field current_loop_cleanup_scopes
1
current_loop_cleanup_scopes: LoopCleanupScopes*?
Backend Field scope_counter
1
scope_counter: int
Backend Field label_counter
1
label_counter: int
Backend Field next_stmt_unreachable
1
next_stmt_unreachable: bool
Struct LoopLabels
Represents one active loop label pair.
LoopLabels Field parent
1
parent: LoopLabels*?
LoopLabels Field break_label
1
break_label: string
LoopLabels Field continue_label
1
continue_label: string
Struct LoopCleanupScopes
Represents the cleanup targets for one active loop.
LoopCleanupScopes Field parent
1
parent: LoopCleanupScopes*?
LoopCleanupScopes Field continue_scope
1
continue_scope: ScopeContext*
LoopCleanupScopes Field break_scope
1
break_scope: ScopeContext*
LoopCleanupScopes Field continue_scope_id
1
continue_scope_id: int
LoopCleanupScopes Field break_scope_id
1
break_scope_id: int