summaryrefslogtreecommitdiff
path: root/VM.hs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2019-12-13 13:51:19 +0100
committertomsmeding <tom.smeding@gmail.com>2019-12-13 13:51:19 +0100
commita436e9d7c7c4115ecc397b4b103573e75aa6c8bc (patch)
tree839632246cf198da810ede9cbf757d224bdf4950 /VM.hs
parent19465d7ad8e913f2807a3512dae1cda71f2f8467 (diff)
Honour some IDiscard instructions
Diffstat (limited to 'VM.hs')
-rw-r--r--VM.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/VM.hs b/VM.hs
index bd7cbef..554a310 100644
--- a/VM.hs
+++ b/VM.hs
@@ -81,8 +81,10 @@ vmRunInstr info@(Info _ _ datas) state (dest, instr) = case instr of
IAllocClo name clrefs ->
let cloVals = (map (findRef (sTempMap state)) clrefs)
in return (assignRef state dest (RVClosure name cloVals))
- IDiscard _ ->
- return state -- TODO: erase temporary from state for IDiscard (RTemp i)
+ IDiscard ref ->
+ case ref of
+ RTemp i -> return (state { sTempMap = IMap.delete i (sTempMap state) })
+ _ -> return state
IPush refs ->
return (state { sStack = map (findRef (sTempMap state)) refs ++ sStack state })
IPop refs ->