diff options
Diffstat (limited to 'app/Code.hs')
| -rw-r--r-- | app/Code.hs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/app/Code.hs b/app/Code.hs index 00d1d1c..5721d17 100644 --- a/app/Code.hs +++ b/app/Code.hs @@ -1,8 +1,10 @@ module Code where +import Control.Monad.Trans.State.Lazy import qualified Data.Map as M import IR (Id(..), StrTable) import Operators (Ops) +import System.Console.Haskeline data Datum = Atom Int -- unifies a constant @@ -12,16 +14,10 @@ data Datum | HeapRef Int (Maybe Int) -- heap structure idx deriving (Show, Eq, Ord) -data BuiltinFunc = - BuiltinFunc (Interp -> Interp) - -instance Show BuiltinFunc where - show _ = "BuiltinFunc _" - data Instr = U Datum -- something unifiable | NoGoal -- trivial goal (directly after head) - | Builtin BuiltinFunc -- trivial goal (directly after head) + | Invoke Builtin -- also directly after head | Goal -- a new goal (set head) | Call -- all seems okay, call the head's hoal | LastCall -- tail call the head's goal @@ -64,3 +60,13 @@ data Interp = , strtable :: StrTable -- string table } deriving (Show) + +type PrlgEnv a = StateT Interp (InputT IO) a + +type BuiltinFn = PrlgEnv (Maybe (Either String Bool)) + +data Builtin = + Builtin BuiltinFn + +instance Show Builtin where + show _ = "Builtin _" |
