summaryrefslogtreecommitdiff
path: root/app/Interpreter.hs
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2023-01-14 23:11:59 +0100
committerMirek Kratochvil <exa.exa@gmail.com>2023-01-14 23:11:59 +0100
commit80cf4b03a4b2353de68a3adc3304334b8a7e347d (patch)
tree1c0bfad8f8cf2d6a9a68e0e84de38031075b764e /app/Interpreter.hs
parentab86f0f21f09230aaa2225b0355907446038f819 (diff)
downloadprlg-80cf4b03a4b2353de68a3adc3304334b8a7e347d.tar.gz
prlg-80cf4b03a4b2353de68a3adc3304334b8a7e347d.tar.bz2
unify simpler heapref cases
Diffstat (limited to 'app/Interpreter.hs')
-rw-r--r--app/Interpreter.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/Interpreter.hs b/app/Interpreter.hs
index bb47144..774c13d 100644
--- a/app/Interpreter.hs
+++ b/app/Interpreter.hs
@@ -129,6 +129,16 @@ proveStep = St.get >>= go
unify (HeapRef _) VoidRef = uok
unify VoidRef (HeapRef _) = uok
{- actual HeapRefs, these are dereferenced and then unified (sometimes with copying) -}
+ unify (HeapRef hr) (HeapRef gr)
+ | BoundRef ha _ <- deref hr
+ , BoundRef ga _ <- deref gr
+ , ha == ga = uok
+ | FreeRef ha <- deref hr
+ , BoundRef ga _ <- deref gr = setHeap ha (HeapRef ga)
+ | BoundRef ha _ <- deref hr
+ , FreeRef ga <- deref gr = setHeap ga (HeapRef ha)
+ | FreeRef ha <- deref hr
+ , FreeRef ga <- deref gr = setHeap ha (HeapRef ga)
unify (HeapRef hr') g =
case deref hr' of
FreeRef hr ->