diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-04-06 14:51:29 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-04-06 14:51:29 +0100 |
| commit | 9331d0f454a30091628d2fa1c26e805626917d0a (patch) | |
| tree | ac97e21754307d7368c92aeaa0c460271983d56f /patio-to-cranelift/src/codegen | |
| parent | e6e4fc67d93a354eb3ab7f04bb2f833a90650025 (diff) | |
Add support for mutable data element declarations to patio-to-cranelift
Diffstat (limited to 'patio-to-cranelift/src/codegen')
| -rw-r--r-- | patio-to-cranelift/src/codegen/mod.rs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/patio-to-cranelift/src/codegen/mod.rs b/patio-to-cranelift/src/codegen/mod.rs index 798c0381..316c9e2a 100644 --- a/patio-to-cranelift/src/codegen/mod.rs +++ b/patio-to-cranelift/src/codegen/mod.rs @@ -11,8 +11,9 @@ use crate::{ patio::{ compilation_unit::{ PatioCompilationUnit, PatioCompilationUnitElement, PatioDataElementImmutableDefinition, - PatioDataElementMutableDefinition, PatioFunctionDeclaration, PatioFunctionDefinition, - PatioLocal, PatioLocalType, PatioVisibility, + PatioDataElementMutableDeclaration, PatioDataElementMutableDefinition, + PatioFunctionDeclaration, PatioFunctionDefinition, PatioLocal, PatioLocalType, + PatioVisibility, }, instructions::{ PatioBlock, PatioBoolToInt, PatioCall, PatioCallPointer, PatioDataPtrToInt, PatioIf, @@ -88,6 +89,12 @@ fn declare_compilation_unit_element( declare_data_element_immutable_definition(data_element_immutable_definition, context); } + PatioCompilationUnitElement::DataElementMutableDeclaration( + data_element_mutable_declaration, + ) => { + declare_data_element_mutable_declaration(data_element_mutable_declaration, context); + } + PatioCompilationUnitElement::DataElementMutableDefinition( data_element_mutable_definition, ) => { @@ -115,6 +122,8 @@ fn define_compilation_unit_element( define_data_element_immutable_definition(data_element_immutable_definition, context); } + PatioCompilationUnitElement::DataElementMutableDeclaration(_) => {} + PatioCompilationUnitElement::DataElementMutableDefinition( data_element_mutable_definition, ) => { @@ -151,6 +160,17 @@ fn define_data_element_immutable_definition( context.define_data(&data_element_immutable_definition.name, bytes); } +fn declare_data_element_mutable_declaration( + data_element_mutable_declaration: &PatioDataElementMutableDeclaration, + context: &mut CompilerContext, +) { + context.declare_data( + &data_element_mutable_declaration.name, + cranelift_module::Linkage::Import, + Mutability::Mutable, + ); +} + fn declare_data_element_mutable_definition( data_element_mutable_definition: &PatioDataElementMutableDefinition, context: &mut CompilerContext, |
