diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2022-12-14 22:56:47 +0100 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2022-12-14 22:56:47 +0100 |
| commit | 2f07d890433bebedc136037ad9cce2eed25b0437 (patch) | |
| tree | 3c1bce09493565a4a1ae200a34d6e54f58fbe986 /app/Interpreter.hs | |
| parent | 71992db7d0e51f87934f7d9c0cf9ddbd3a8d0300 (diff) | |
| download | prlg-2f07d890433bebedc136037ad9cce2eed25b0437.tar.gz prlg-2f07d890433bebedc136037ad9cce2eed25b0437.tar.bz2 | |
10h vacuum cleaner sound
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 |
