Implement llvm returns in function code generator finalize

This commit is contained in:
Brandon Fish 2019-05-04 12:07:21 -05:00
parent c5caf9b6db
commit 60c0504bdf

View File

@ -4610,6 +4610,21 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
}
fn finalize(&mut self) -> Result<(), CodegenError> {
let results = self.state.popn_save(self.func_sig.returns().len())?;
match results.as_slice() {
[] => {
self.builder.build_return(None);
}
[one_value] => {
self.builder.build_return(Some(one_value));
}
_ => {
// let struct_ty = llvm_sig.get_return_type().as_struct_type();
// let ret_struct = struct_ty.const_zero();
unimplemented!("multi-value returns not yet implemented")
}
}
Ok(())
}
}