From 9454fc61944e24b1eb355ef2556ad2b53bf794da Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 16 Jan 2017 01:06:59 -0800 Subject: [PATCH] Add return statements to generated functions --- compile.schala | 4 +++- src/compilation.rs | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/compile.schala b/compile.schala index 04c7dc2..bd317ab 100644 --- a/compile.schala +++ b/compile.schala @@ -7,5 +7,7 @@ fn paha(x, y, z) { x * y * z } +q = 4 + +q + 1 -2 + 8 diff --git a/src/compilation.rs b/src/compilation.rs index 8a4144a..37cedaf 100644 --- a/src/compilation.rs +++ b/src/compilation.rs @@ -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);