diff options
author | Camil Staps | 2018-12-24 14:27:24 +0100 |
---|---|---|
committer | Camil Staps | 2018-12-24 14:27:24 +0100 |
commit | 86bae16fe950fc2be7ed0a069d1858a353b97a5f (patch) | |
tree | 5b9bf46dc972833479fe3f65a4c69aaf077b7840 /sjit.icl | |
parent | Remove Abstr; add fun_args (diff) |
Fix compilation for constant functions (allocate space for return value)
Diffstat (limited to 'sjit.icl')
-rw-r--r-- | sjit.icl | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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]]} ] |