From 86bae16fe950fc2be7ed0a069d1858a353b97a5f Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 24 Dec 2018 14:27:24 +0100 Subject: Fix compilation for constant functions (allocate space for return value) --- sjit.icl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sjit.icl') diff --git a/sjit.icl b/sjit.icl index 7a01d2e..6b94745 100644 --- a/sjit.icl +++ b/sjit.icl @@ -145,6 +145,7 @@ where Just i -> ([PushRef (i-cs.sp)], {cs & sp=cs.sp+1, pc=cs.pc+1}) Nothing -> abort "undefined variable\n" expr (App f args) cs + # args = if (args=:[]) [Int 0] args # (iss,cs) = mapSt expr args {cs & sp=cs.sp+1} = case get f cs.funs of Just f -> ([Pop (length args-1):Call f:flatten iss], {cs & sp=cs.sp+2-length args, pc=cs.pc+2}) @@ -267,5 +268,6 @@ where comp_state =: compile_all Nothing [ {fun_name="id", fun_args=["x"], fun_expr=Var "x"} , {fun_name="const", fun_args=["x","y"], fun_expr=Var "x"} - , {fun_name="main", fun_args=[], fun_expr=App "+" [App "const" [Int 37, Int 10], App "const" [Int 5, Int 10]]} + , {fun_name="seven", fun_args=[], fun_expr=App "const" [Int 7, Int 10]} + , {fun_name="main", fun_args=[], fun_expr=App "+" [App "seven" [], App "const" [Int 5, Int 10]]} ] -- cgit v1.2.3