CDeclarations class
Defined in module l0_c_declarations (l0_c_declarations.py).
Translation-unit layout and top-level C declarations.
Public static attributes
Public functions
- auto emit_section_comment(self, str text) -> None
- Emit a decorative section comment.
- auto emit_module_comment(self, str module_name) -> None
- Emit a module metadata comment.
- auto emit_module_separator(self, str module_name) -> None
- Emit a decorative module separator.
- auto emit_unreachable_comment(self) -> None
- Emit an unreachable code comment for debugging.
- auto emit_unreachable_marker(self, str reason = "unreachable") -> None
- Emit a runtime panic call for unreachable code paths.
- auto emit_header(self) -> None
- Emit C header boilerplate, SipHash implementation, and L0 runtime.
- auto emit_forward_decls(self) -> None
- Emit forward declarations for all structs and enums in compilation unit.
- auto emit_struct(self, str module_name, StructDecl decl, StructInfo struct_info) -> None
- Emit a complete C struct definition.
- auto emit_enum(self, str module_name, EnumDecl decl, EnumInfo enum_info) -> None
- Emit an L0 enum as a C tagged union.
- auto emit_let_declaration(self, str module_name, LetDecl decl, Type let_type, Callable[[Expr, Type], str] let_initializer_callback) -> None
- Emit a single top-level let declaration as a static variable.
- auto emit_top_level_let_cleanup(self) -> None
- Emit final cleanup for ARC-managed top-level lets before process exit.
- auto emit_function_declaration(self, str module_name, FuncDecl decl, FuncType func_type) -> None
- Emit a single function declaration signature.
- auto emit_function_definition_header(self, str module_name, FuncDecl decl, FuncType func_type) -> None
- Emit function definition header (signature and opening brace).
- auto emit_function_definition_footer(self) -> None
- Emit function definition footer (closing brace).
- auto emit_main_wrapper(self, str entry_module, FuncType func_type) -> None
- Emit C main() wrapper that calls the L0 entry function.
Function documentation
None l0_c_declarations:: CDeclarations:: emit_section_comment(self,
str text)
Emit a decorative section comment.
| Parameters | |
|---|---|
| text | The comment text. |
None l0_c_declarations:: CDeclarations:: emit_module_comment(self,
str module_name)
Emit a module metadata comment.
| Parameters | |
|---|---|
| module_name | The name of the module. |
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. |
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. |
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. |
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. |
| Exceptions | |
| InternalCompilerError | If variant information is missing. |
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. |
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. |
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. |
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. |