diff options
Diffstat (limited to 'app/Interpreter.hs')
| -rw-r--r-- | app/Interpreter.hs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/app/Interpreter.hs b/app/Interpreter.hs index 7192c7b..15ab1e5 100644 --- a/app/Interpreter.hs +++ b/app/Interpreter.hs @@ -89,10 +89,10 @@ proveStep = St.get >>= go in ( Heap (nxt + n) $ foldr (uncurry M.insert) m [(a, HeapRef a) | a <- addrs] , addrs) - allocLocal (LocalRef reg ident) scope cont - | Just (addr, _) <- scope M.!? reg = cont scope heap addr + allocLocal (LocalRef reg) scope cont + | Just addr <- scope M.!? reg = cont scope heap addr | (heap', addr) <- newHeapVar heap = - cont (M.insert reg (addr, ident) scope) heap' addr + cont (M.insert reg addr scope) heap' addr newHeapStruct addr s@(Struct Id {arity = arity}) cont = let (Heap nxt' m', addrs) = newHeapVars (arity + 1) heap m'' = @@ -113,10 +113,10 @@ proveStep = St.get >>= go unify (Struct Id {arity = a}) VoidRef = c i {cur = cur {hed = hs, gol = replicate a (U VoidRef) ++ gs}} {- handle local refs; first ignore their combination with voids to save memory -} - unify (LocalRef _ _) VoidRef = uok - unify VoidRef (LocalRef _ _) = uok + unify (LocalRef _) VoidRef = uok -- TRICKY: builtins need to check if locals actually exist because of this + unify VoidRef (LocalRef _) = uok {- allocate heap for LocalRefs and retry with HeapRefs -} - unify lr@(LocalRef _ _) _ = + unify lr@(LocalRef _) _ = allocLocal lr (hvar cur) $ \hvar' heap' addr -> c i @@ -124,7 +124,7 @@ proveStep = St.get >>= go cur {hed = U (HeapRef addr) : hs, hvar = hvar', heap = heap'} } - unify _ lr@(LocalRef _ _) = + unify _ lr@(LocalRef _) = allocLocal lr (gvar cur) $ \gvar' heap' addr -> c i |
