Add return statements to generated functions

This commit is contained in:
greg 2017-01-16 01:06:59 -08:00
parent c8feaa9b57
commit 9454fc6194
2 changed files with 5 additions and 1 deletions

View File

@ -7,5 +7,7 @@ fn paha(x, y, z) {
x * y * z
}
q = 4
q + 1
2 + 8

View File

@ -143,6 +143,8 @@ impl CodeGen for Function {
ret = expr.codegen(data);
}
LLVMWrap::BuildRet(data.builder, ret);
// get basic block of main
let main_bb = LLVMWrap::GetBasicBlocks(data.main_function).get(0).expect("Couldn't get first block of main").clone();
LLVMWrap::PositionBuilderAtEnd(data.builder, main_bb);