diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2023-03-05 21:34:20 +0100 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2023-03-05 21:34:20 +0100 |
| commit | 98c40f4bf8849f5cdd3d3c49123bc911b8fa42e1 (patch) | |
| tree | e41a1cd05d17765f9e27b0844580655b2dc1ae95 /app/Code.hs | |
| parent | 45c3f81891837820aea7c3dbd45e3bae25fc4c22 (diff) | |
| download | prlg-98c40f4bf8849f5cdd3d3c49123bc911b8fa42e1.tar.gz prlg-98c40f4bf8849f5cdd3d3c49123bc911b8fa42e1.tar.bz2 | |
strings and a few other small nice changes
Diffstat (limited to 'app/Code.hs')
| -rw-r--r-- | app/Code.hs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/app/Code.hs b/app/Code.hs index b60ab66..6efa5b9 100644 --- a/app/Code.hs +++ b/app/Code.hs @@ -2,24 +2,31 @@ module Code where +import Constant import Control.Monad.Trans.State.Lazy (StateT) import qualified Data.Map as M -import IR (Id(..), StrTable) +import IR (StrTable) import Operators (Ops) import Parser (PAST) import System.Console.Haskeline (InputT) +data Id = + Id + { str :: !Int + , arity :: !Int + } + deriving (Show, Eq, Ord) + data Datum - = Atom Int -- unifies a symbolic constant - | Number Int -- unifies a numeric constant - | Struct Id -- unifies a structure with arity + = C !Constant -- unifies a constant + | Struct !Id -- unifies a structure with arity | VoidRef -- unifies with anything - | LocalRef Int -- code-local variable idx (should never occur on heap) - | HeapRef Int -- something further on the heap + | LocalRef !Int -- code-local variable idx (should never occur on heap) + | HeapRef !Int -- something further on the heap deriving (Show, Eq, Ord) data Instr - = U Datum -- unify/resolve something + = U !Datum -- unify/resolve something | Invoke Builtin -- give control to a builtin (invoked from head) | Done -- all done, can return | Cut -- remove choicepoints of the current goal @@ -31,7 +38,7 @@ type Code = [Instr] type Defs = M.Map Id [Code] data Heap = - Heap Int (M.Map Int Datum) + Heap !Int (M.Map Int Datum) deriving (Show) emptyHeap = Heap 1 M.empty |
