diff --git a/examples/cast.reid b/examples/cast.reid index 0a85a0a..bec3460 100644 --- a/examples/cast.reid +++ b/examples/cast.reid @@ -1,6 +1,5 @@ // Arithmetic, function calls and imports! -import std::allocate; import std::print; fn other() -> i16 { @@ -9,7 +8,7 @@ fn other() -> i16 { fn main() -> u32 { - let mut v = (allocate(4) as *u32); + let mut v = (malloc(4) as *u32); v[0] = other() as u32; return v[0]; diff --git a/examples/ptr.reid b/examples/ptr.reid index f4be760..6fc1c4d 100755 --- a/examples/ptr.reid +++ b/examples/ptr.reid @@ -1,7 +1,7 @@ // Arithmetic, function calls and imports! fn main() -> u8 { - let mut ptr = u8::alloca(4); + let mut ptr = u8::malloc(4); ptr[0] = 5; diff --git a/reid/src/codegen/mod.rs b/reid/src/codegen/mod.rs index e92fb8f..2fb77d8 100644 --- a/reid/src/codegen/mod.rs +++ b/reid/src/codegen/mod.rs @@ -255,18 +255,19 @@ impl mir::Module { .collect(); let is_main = self.is_main && function.name == "main"; - let module_name = if let Some(module) = function.source { + let module_prefix = if let Some(module) = function.source { if module == self.module_id { - format!("reid.{}", self.name) + format!("reid.{}.", self.name) } else { - format!("reid.{}", modules.get(&module).unwrap().name) + format!("reid.{}.", modules.get(&module).unwrap().name) } } else { - format!("reid.intrinsic") + format!("reid.intrinsic.") }; + let full_name = format!("{}{}::{}", module_prefix, ty, function.name); let func = match &function.kind { mir::FunctionDefinitionKind::Local(_, _) => Some(module.function( - &format!("{}.{}.{}", module_name, ty, function.name), + &full_name, None, function.return_type.get_type(&type_values), param_types, @@ -278,7 +279,7 @@ impl mir::Module { }, )), mir::FunctionDefinitionKind::Extern(imported) => Some(module.function( - &function.linkage_name.clone().unwrap_or(function.name.clone()), + &full_name, None, function.return_type.get_type(&type_values), param_types, diff --git a/reid/src/mir/linker.rs b/reid/src/mir/linker.rs index 1059861..479fbb3 100644 --- a/reid/src/mir/linker.rs +++ b/reid/src/mir/linker.rs @@ -322,7 +322,7 @@ impl<'map> Pass for LinkerPass<'map> { ty.clone(), FunctionDefinition { name: func_name.clone(), - linkage_name: Some(format!("{}.{}", ty, func_name)), + linkage_name: Some(format!("{}::{}", ty, func_name)), is_pub: false, is_imported: false, return_type, diff --git a/reid/tests/e2e.rs b/reid/tests/e2e.rs index 584ea93..d83ffa2 100644 --- a/reid/tests/e2e.rs +++ b/reid/tests/e2e.rs @@ -149,6 +149,6 @@ fn associated_functions() { test( include_str!("../../examples/associated_functions.reid"), "test", - Some(32), + Some(4), ); }