aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-03-30 22:29:11 +0100
committerMichael Williamson <mike@zwobble.org>2026-03-30 22:29:11 +0100
commitfa83dd5c628a93fc3129f5c6f21b617fdd3fffc8 (patch)
tree757ab74c3310580c67a0a01ff1db1615b951bc05
parentfaade250d5adafb3fe9c8ab440e0a4d40a5e9f63 (diff)
Add lookup for defined functions
-rw-r--r--patio-to-cranelift/src/context.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/patio-to-cranelift/src/context.rs b/patio-to-cranelift/src/context.rs
index ca382be7..9f1cf05b 100644
--- a/patio-to-cranelift/src/context.rs
+++ b/patio-to-cranelift/src/context.rs
@@ -53,9 +53,9 @@ impl CompilerContext {
self.module.finish()
}
- pub(crate) fn declare_function(&mut self, function_name: &str, signature: &cranelift::prelude::Signature) {
- let func_id = self.module.declare_function(function_name, cranelift_module::Linkage::Import, signature).unwrap();
- self.func_name_to_func_id.insert(function_name.to_string(), func_id);
+ pub(crate) fn declare_function(&mut self, name: &str, signature: &cranelift::prelude::Signature) {
+ let func_id = self.module.declare_function(name, cranelift_module::Linkage::Import, signature).unwrap();
+ self.func_name_to_func_id.insert(name.to_string(), func_id);
}
pub(crate) fn enter_function(
@@ -69,6 +69,7 @@ impl CompilerContext {
self.codegen_context.clear();
let func_id = self.module.declare_function(name, linkage, &signature).unwrap();
+ self.func_name_to_func_id.insert(name.to_string(), func_id);
// TODO: reuse function builder context
let mut func_builder_context = cranelift::prelude::FunctionBuilderContext::new();