l0_c_declarations.py
Module: l0_c_declarations
Source: compiler/stage1_py/l0_c_declarations.py Language: Python
Symbols
Namespace l0_c_declarations
Class l0_c_declarations::CDeclarations
Translation-unit layout and top-level C declarations.
Member Data l0_c_declarations.CDeclarations.cleanup
1
CCleanup cleanup
Member Data l0_c_declarations.CDeclarations.names
1
CNames names
Member Data l0_c_declarations.CDeclarations.state
1
CEmitterState state
Member Data l0_c_declarations.CDeclarations.types
1
CTypes types
Function l0_c_declarations.CDeclarations.emit_section_comment
1
None l0_c_declarations.CDeclarations.emit_section_comment(self, str text)
Emit a decorative section comment.
Parameters:
1
None l0_c_declarations.CDeclarations.emit_module_comment(self, str module_name)
Emit a module metadata comment.
Parameters:
1
None l0_c_declarations.CDeclarations.emit_module_separator(self, str module_name)
Emit a decorative module separator.
Parameters:
module_name: The name of the module.Function
l0_c_declarations.CDeclarations.emit_unreachable_comment
1
None l0_c_declarations.CDeclarations.emit_unreachable_comment(self)
Emit an unreachable code comment for debugging.
Function l0_c_declarations.CDeclarations.emit_unreachable_marker
1
None l0_c_declarations.CDeclarations.emit_unreachable_marker(self, str reason="unreachable")
Emit a runtime panic call for unreachable code paths.
Parameters:
reason: Description of why the path is unreachable.Function
l0_c_declarations.CDeclarations.emit_header
1
None l0_c_declarations.CDeclarations.emit_header(self)
Emit C header boilerplate, SipHash implementation, and L0 runtime.
Function l0_c_declarations.CDeclarations.emit_forward_decls
1
None l0_c_declarations.CDeclarations.emit_forward_decls(self)
Emit forward declarations for all structs and enums in compilation unit.
Function l0_c_declarations.CDeclarations.emit_struct
1
None l0_c_declarations.CDeclarations.emit_struct(self, str module_name, StructDecl decl, StructInfo struct_info)
Emit a complete C struct definition.
Parameters:
module_name: Name of the module.decl: StructDecl AST node.struct_info: Resolved type information for the struct.Function
l0_c_declarations.CDeclarations.emit_enum
1
None l0_c_declarations.CDeclarations.emit_enum(self, str module_name, EnumDecl decl, EnumInfo enum_info)
Emit an L0 enum as a C tagged union.
Parameters:
module_name: Name of the module.decl: EnumDecl AST node.enum_info: Resolved type information for the enum.Function
l0_c_declarations.CDeclarations.emit_let_declaration
1
None l0_c_declarations.CDeclarations.emit_let_declaration(self, str module_name, LetDecl decl, Type let_type, Callable[[Expr, Type], str] let_initializer_callback)
Emit a single top-level let declaration as a static variable.
Parameters:
module_name: Module containing the let.decl: Let declaration AST node.let_type: Resolved type of the let.let_initializer_callback: Callback to emit initializer expression string.Function
l0_c_declarations.CDeclarations.emit_top_level_let_cleanup
1
None l0_c_declarations.CDeclarations.emit_top_level_let_cleanup(self)
Emit final cleanup for ARC-managed top-level lets before process exit.
Function l0_c_declarations.CDeclarations.emit_function_declaration
1
None l0_c_declarations.CDeclarations.emit_function_declaration(self, str module_name, FuncDecl decl, FuncType func_type)
Emit a single function declaration signature.
Parameters:
module_name: Name of the module.decl: FuncDecl AST node.func_type: Resolved signature of the function.Function
l0_c_declarations.CDeclarations.emit_function_definition_header
1
None l0_c_declarations.CDeclarations.emit_function_definition_header(self, str module_name, FuncDecl decl, FuncType func_type)
Emit function definition header (signature and opening brace).
Parameters:
module_name: Name of the module.decl: FuncDecl AST node.func_type: Resolved signature of the function.Function
l0_c_declarations.CDeclarations.emit_function_definition_footer
1
None l0_c_declarations.CDeclarations.emit_function_definition_footer(self)
Emit function definition footer (closing brace).
Function l0_c_declarations.CDeclarations.emit_main_wrapper
1
None l0_c_declarations.CDeclarations.emit_main_wrapper(self, str entry_module, FuncType func_type)
Emit C main() wrapper that calls the L0 entry function.
Parameters:
entry_module: Name of the entry module.func_type: Resolved signature of the L0 main function.