l0_c_cleanup.py
Module: l0_c_cleanup
Source: compiler/stage1_py/l0_c_cleanup.py Language: Python
Symbols
Namespace l0_c_cleanup
Class l0_c_cleanup::CCleanup
Recursive value cleanup and allocation/ARC runtime operations.
Member Data l0_c_cleanup.CCleanup.names
1
CNames names
Member Data l0_c_cleanup.CCleanup.state
1
CEmitterState state
Member Data l0_c_cleanup.CCleanup.values
1
CValues values
Function l0_c_cleanup.CCleanup.emit_value_cleanup
1
None l0_c_cleanup.CCleanup.emit_value_cleanup(self, str c_expr, Type ty)
Emit C code to clean up an owned by-value variable.
Parameters:
c_expr: C expression evaluating to the value.ty: The L0 Type of the value.Function
l0_c_cleanup.CCleanup.emit_struct_cleanup
1
None l0_c_cleanup.CCleanup.emit_struct_cleanup(self, str c_ptr_expr, StructType struct_type)
Emit cleanup code for all owned fields in a struct.
Parameters:
c_ptr_expr: C expression evaluating to a pointer to the struct.struct_type: The L0 struct type.Function
l0_c_cleanup.CCleanup.emit_enum_cleanup
1
None l0_c_cleanup.CCleanup.emit_enum_cleanup(self, str c_ptr_expr, EnumType enum_type)
Emit cleanup code for owned fields in an enum’s active variant.
Parameters:
c_ptr_expr: C expression evaluating to a pointer to the enum.enum_type: The L0 enum type.Function
l0_c_cleanup.CCleanup.emit_drop_finish_call
1
None l0_c_cleanup.CCleanup.emit_drop_finish_call(self, str c_ptr_expr)
Emit the runtime call that completes a generated drop.
Function l0_c_cleanup.CCleanup.emit_string_retain
1
None l0_c_cleanup.CCleanup.emit_string_retain(self, str c_expr)
Emit an ARC string retain runtime call.
Parameters:
c_expr: C expression evaluating to an l0_string.Function
l0_c_cleanup.CCleanup.emit_string_release
1
None l0_c_cleanup.CCleanup.emit_string_release(self, str c_expr)
Emit an ARC string release runtime call.
Parameters:
c_expr: C expression evaluating to an l0_string.Function
l0_c_cleanup.CCleanup.emit_alloc_obj
1
None l0_c_cleanup.CCleanup.emit_alloc_obj(self, str c_ptr_type, str c_base_type, str c_temp_name)
Emit a heap allocation runtime call.
Parameters:
c_ptr_type: C pointer type string.c_base_type: C base object type string.c_temp_name: Name of temporary to hold the pointer.Function
l0_c_cleanup.CCleanup._emit_cleanup_by_type
1
None l0_c_cleanup.CCleanup._emit_cleanup_by_type(self, str c_expr, Type ty)
Emit recursive cleanup code for any ARC-managed data inside a type.
Parameters:
c_expr: C expression evaluating to the by-value object to clean up.ty: The L0 type describingc_expr.
See also:
emit_value_cleanup:Public entry point for by-value cleanup emission._emit_enum_value_cleanup:Handles enum-specific cleanup lowering.Function
l0_c_cleanup.CCleanup._emit_enum_value_cleanup
1
None l0_c_cleanup.CCleanup._emit_enum_value_cleanup(self, str c_expr, EnumType enum_type)
Emit C cleanup code for an enum by-value variable.
Function l0_c_cleanup.CCleanup._emit_enum_cleanup_switch
1
None l0_c_cleanup.CCleanup._emit_enum_cleanup_switch(self, EnumType enum_type, str c_tag_expr, Callable[[str, str], str] field_expr_for_variant_field, *bool missing_info_is_ice)
Emit a cleanup switch over the active variant of an enum value.
Parameters:
enum_type: Enum type whose payload cleanup is being emitted.c_tag_expr: C expression yielding the enum tag to switch on.field_expr_for_variant_field: Callback that maps variant and field names to the corresponding C lvalue expression.missing_info_is_ice: Whether missing enum metadata should raise an internal compiler error.
See also:
_emit_enum_value_cleanup:Uses this helper for by-value enum cleanup._iter_variant_cleanup_fields:Supplies the field names paired with types.Function
l0_c_cleanup.CCleanup._iter_variant_cleanup_fields
1
list[tuple[str, Type]] l0_c_cleanup.CCleanup._iter_variant_cleanup_fields(self, EnumType enum_type, str variant_name, list[Type] variant_field_types)
Pair variant field names with their resolved field types.
Parameters:
enum_type: Enum type owning the variant.variant_name: Variant whose fields are being cleaned up.variant_field_types: Resolved payload field types for the variant.
Returns: A list of “(field_name, field_type)” pairs, or an empty list when the AST declaration cannot be matched to the resolved payload types.
See also:
find_variant_decl:Retrieves the source declaration used for field names._emit_enum_cleanup_switch:Consumes these pairs to emit cleanup code.Function
l0_c_cleanup.CCleanup._enum_has_arc_data
1
bool l0_c_cleanup.CCleanup._enum_has_arc_data(self, EnumInfo enum_info)
Report whether any enum payload field requires ARC-aware cleanup.
Parameters:
enum_info: Resolved enum metadata to inspect.
Returns: True if any variant payload contains ARC-managed data.
See also:
_emit_enum_cleanup_switch:Skips switch emission when this is false.Function
l0_c_cleanup.CCleanup._emit_field_cleanup
1
None l0_c_cleanup.CCleanup._emit_field_cleanup(self, str field_expr, Type field_type)
Emit recursive cleanup for a field.