aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2018-12-25 02:04:48 +0100
committerCamil Staps2018-12-25 02:04:48 +0100
commitebd62b387d77502f685fcacbb701adc1cdce26a7 (patch)
tree6126c14bcee89a2d657cdb9ee8c57f013824d71c
parentAdd if construct; fib example (diff)
Don't generate pop 0
-rw-r--r--Sjit/Compile.icl4
1 files changed, 3 insertions, 1 deletions
diff --git a/Sjit/Compile.icl b/Sjit/Compile.icl
index 55b8ff3..8fd81a2 100644
--- a/Sjit/Compile.icl
+++ b/Sjit/Compile.icl
@@ -156,7 +156,9 @@ where
# args = if (args=:[]) [Int 0] args
= foldM (flip expr) cs (reverse args) >>= \cs -> case get f cs.funs of
Nothing -> Left ("undefined function '" +++ toString f +++ "'")
- Just f -> gen [Pop (length args-1),Call f] cs
+ Just f -> case length args of
+ 1 -> gen [Call f] cs
+ n -> gen [Pop (n-1),Call f] cs
expr (If b t e) cs =
expr b cs >>=
reserve -1 >>= \(jmptrue,cs=:{sp=orgsp}) ->