summaryrefslogtreecommitdiff
path: root/app/Code.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Code.hs')
-rw-r--r--app/Code.hs23
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