l0_c_statements.py
Module: l0_c_statements
Source: compiler/stage1_py/l0_c_statements.py Language: Python
Symbols
Namespace l0_c_statements
Class l0_c_statements::CStatements
C statement, control-flow, and initialization syntax.
Member Data l0_c_statements.CStatements.names
1
CNames names
Member Data l0_c_statements.CStatements.state
1
CEmitterState state
Member Data l0_c_statements.CStatements.types
1
CTypes types
Member Data l0_c_statements.CStatements.values
1
CValues values
Function l0_c_statements.CStatements.emit_expr_stmt
1
None l0_c_statements.CStatements.emit_expr_stmt(self, str c_expr)
Emit an expression as a statement.
Parameters:
1
None l0_c_statements.CStatements.emit_return_stmt(self, str|None c_value)
Emit a C return statement.
Parameters:
c_value: Optional C expression string to return.Function
l0_c_statements.CStatements.emit_exit_switch
1
None l0_c_statements.CStatements.emit_exit_switch(self)
Emit a C break statement to exit a switch block.
Function l0_c_statements.CStatements.emit_label
1
None l0_c_statements.CStatements.emit_label(self, str label)
Emit a C label followed by a null statement.
Parameters:
1
None l0_c_statements.CStatements.emit_goto(self, str label)
Emit a C goto statement.
Parameters:
1
None l0_c_statements.CStatements.emit_block_start(self)
Emit an opening brace and increase indentation.
Function l0_c_statements.CStatements.emit_block_end
1
None l0_c_statements.CStatements.emit_block_end(self)
Emit a closing brace and decrease indentation.
Function l0_c_statements.CStatements.emit_while_header
1
None l0_c_statements.CStatements.emit_while_header(self, str c_cond)
Emit a C while loop header.
Parameters:
1
None l0_c_statements.CStatements.emit_if_header(self, str c_cond)
Emit a C if statement header.
Parameters:
1
None l0_c_statements.CStatements.emit_else(self)
Emit a C else keyword.
Function l0_c_statements.CStatements.emit_for_loop_start
1
None l0_c_statements.CStatements.emit_for_loop_start(self)
Emit a decorative comment and opening brace for a for loop block.
Function l0_c_statements.CStatements.emit_for_loop_end
1
None l0_c_statements.CStatements.emit_for_loop_end(self)
Emit closing brace for a for loop block.
Function l0_c_statements.CStatements.emit_let_decl
1
None l0_c_statements.CStatements.emit_let_decl(self, str c_type, str c_var_name, str c_init)
Emit a C local variable declaration with initializer.
Parameters:
c_type: C type string.c_var_name: C identifier.c_init: C initializer expression string.Function
l0_c_statements.CStatements.emit_assignment
1
None l0_c_statements.CStatements.emit_assignment(self, str c_target, str c_value)
Emit a simple C assignment statement.
Parameters:
c_target: C lvalue expression.c_value: C expression for the value.Function
l0_c_statements.CStatements.emit_pointer_assignment
1
None l0_c_statements.CStatements.emit_pointer_assignment(self, str c_ptr_name, str c_value)
Emit a C assignment through a pointer.
Parameters:
c_ptr_name: C expression evaluating to a pointer.c_value: C expression for the value.Function
l0_c_statements.CStatements.emit_checked_pointer_assignment
1
None l0_c_statements.CStatements.emit_checked_pointer_assignment(self, str c_ptr_name, str c_base_type, str c_value)
Emit an assignment through a runtime-checked object pointer.
Function l0_c_statements.CStatements.emit_temp_decl
1
None l0_c_statements.CStatements.emit_temp_decl(self, str c_type, str c_temp_name, str c_value)
Emit a C temporary variable declaration with initializer.
Parameters:
c_type: C type string.c_temp_name: C identifier for temporary.c_value: C initializer expression string.Function
l0_c_statements.CStatements.emit_comment
1
None l0_c_statements.CStatements.emit_comment(self, str comment)
Emit a C block comment.
Parameters:
1
None l0_c_statements.CStatements.emit_match_scrutinee_decl(self, str c_type, str c_expr)
Emit the scrutinee declaration for a match/case statement.
Parameters:
c_type: C type string of scrutinee.c_expr: C expression for scrutinee value.Function
l0_c_statements.CStatements.emit_switch_start
1
None l0_c_statements.CStatements.emit_switch_start(self, str c_expr)
Emit a C switch statement header and opening brace.
Parameters:
1
None l0_c_statements.CStatements.emit_match_switch_start(self, str scrutinee_name)
Emit a match switch over an enum tag.
Parameters:
scrutinee_name: Identifier of the scrutinee variable.Function
l0_c_statements.CStatements.emit_switch_end
1
None l0_c_statements.CStatements.emit_switch_end(self)
Emit a C switch statement closing brace.
Function l0_c_statements.CStatements.emit_case_label
1
None l0_c_statements.CStatements.emit_case_label(self, str c_tag_value)
Emit a C case label.
Parameters:
c_tag_value: The constant C tag identifier or literal.Function
l0_c_statements.CStatements.emit_default_label
1
None l0_c_statements.CStatements.emit_default_label(self)
Emit a C default case label.
Function l0_c_statements.CStatements.emit_null_assignment
1
None l0_c_statements.CStatements.emit_null_assignment(self, str c_var)
Emit a NULL assignment to a variable.
Parameters:
1
None l0_c_statements.CStatements.emit_struct_init(self, str c_temp_name, str c_base_type, str c_init_str)
Emit an object initialization through a pointer.
Parameters:
c_temp_name: Name of the pointer variable.c_base_type: C base object type string.c_init_str: C compound initializer body.Function
l0_c_statements.CStatements.emit_struct_init_from_fields
1
None l0_c_statements.CStatements.emit_struct_init_from_fields(self, str c_temp_name, Type base_type, list[tuple[str, str]] field_inits)
Emit struct initialization using positional field values.
Parameters:
c_temp_name: Name of the pointer variable.base_type: L0 base object type.field_inits: List of (field_name, c_value) tuples.Function
l0_c_statements.CStatements.emit_enum_variant_init
1
None l0_c_statements.CStatements.emit_enum_variant_init(self, str c_temp_name, EnumType enum_type, str variant_name, list[tuple[str, str]] payload_inits)
Emit enum variant initialization for a heap-allocated enum.
Parameters:
c_temp_name: Name of the pointer variable.enum_type: L0 enum type.variant_name: Name of the active variant.payload_inits: List of (field_name, c_value) tuples for payload.Function
l0_c_statements.CStatements.emit_zero_init
1
None l0_c_statements.CStatements.emit_zero_init(self, str c_temp_name, str c_base_type)
Emit zero-initialization through a pointer.
Parameters:
c_temp_name: Name of the pointer variable.c_base_type: C base object type string.Function
l0_c_statements.CStatements.emit_try_check_niche
1
None l0_c_statements.CStatements.emit_try_check_niche(self, str c_tmp, str ret_none)
Emit a NULL check for a niche-optimized optional.
Parameters:
c_tmp: C identifier of the temporary holding the optional.ret_none: C expression for the ‘none’ return value.Function
l0_c_statements.CStatements.emit_try_check_value
1
None l0_c_statements.CStatements.emit_try_check_value(self, str c_tmp, str ret_none)
Emit a has_value check for a value-optional.
Parameters:
c_tmp: C identifier of the temporary holding the optional.ret_none: C expression for the ‘none’ return value.Function
l0_c_statements.CStatements.emit_try_extract_value
1
str l0_c_statements.CStatements.emit_try_extract_value(self, str c_tmp)
Emit C code to extract the inner value from an optional.
Parameters:
c_tmp: C identifier of the temporary holding the optional.
Returns: C expression string for the extracted value.