Browse Source

feat: llvm: return types

c_for-loops
Garrit Franke 3 years ago
parent
commit
3f802caad7
  1. 10
      src/generator/llvm.rs

10
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);
}
}

Loading…
Cancel
Save