diff options
Diffstat (limited to 'VM.hs')
-rw-r--r-- | VM.hs | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -103,7 +103,14 @@ callClosure info@(Info bbmap gfds _) state@(State { sTempMap = tmap }) cl as = Just (GlobFuncDef b _ _) -> do (rv, state') <- vmRunBB info (state { sArgs = map (findRef tmap) as, sCloVals = clvals }) (bbmap Map.! b) - return (rv, state' { sArgs = sArgs state, sCloVals = sCloVals state }) + -- TODO: we restore tempmap here after the call, and that's + -- _really_ dodgy. I think it works because we never mutate + -- a reference after first assigning it, and without it + -- recursion fails, but it feels ugly. A proper solution + -- would be to further compile the IR down to something + -- that stores its values on a stack, so that recursion is + -- handled automatically. + return (rv, state' { sArgs = sArgs state, sCloVals = sCloVals state, sTempMap = sTempMap state }) Nothing -> -- Take 'tail as' to skip the first self-link argument vmRunBuiltin state clname (map (findRef tmap) (tail as)) |