From 3f802caad799c1bc4d544c9df1e7dd0388350e3e Mon Sep 17 00:00:00 2001 From: Garrit Franke Date: Wed, 10 Feb 2021 16:35:52 +0100 Subject: [PATCH] feat: llvm: return types --- src/generator/llvm.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/generator/llvm.rs b/src/generator/llvm.rs index afd5b57..7d54c0b 100644 --- a/src/generator/llvm.rs +++ b/src/generator/llvm.rs @@ -27,7 +27,13 @@ impl<'ctx> Generator for LLVMGenerator<'ctx> { impl<'ctx> LLVMGenerator<'ctx> { fn generate_function(&mut self, func: Function) { - self.module - .add_function(&func.name, self.ctx.void_type().fn_type(&[], false), None); + dbg!(&func); + let ret_type = match func.ret_type { + Some(Type::Int) => self.ctx.i32_type().fn_type(&[], false), + Some(Type::Bool) => self.ctx.bool_type().fn_type(&[], false), + None => self.ctx.void_type().fn_type(&[], false), + _ => todo!(), + }; + self.module.add_function(&func.name, ret_type, None); } }