summaryrefslogtreecommitdiff
path: root/app/IR.hs
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2022-11-12 17:47:51 +0100
committerMirek Kratochvil <exa.exa@gmail.com>2022-11-12 17:47:51 +0100
commitb9633a33182f5b381e912366273709e59f469bb9 (patch)
tree0b7eb7f1e67792253cfaf9caee3a92570ab60407 /app/IR.hs
parentfe6666d204c0728b4556574ddc184bc46013b193 (diff)
downloadprlg-b9633a33182f5b381e912366273709e59f469bb9.tar.gz
prlg-b9633a33182f5b381e912366273709e59f469bb9.tar.bz2
reorg.
Diffstat (limited to 'app/IR.hs')
-rw-r--r--app/IR.hs33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/IR.hs b/app/IR.hs
new file mode 100644
index 0000000..50c7493
--- /dev/null
+++ b/app/IR.hs
@@ -0,0 +1,33 @@
+module IR where
+
+import qualified Data.Map as M
+
+data PrlgStr
+ = CallS String [PrlgStr]
+ | LiteralS String
+ deriving (Show)
+
+data Id =
+ Id
+ { str :: Int
+ , arity :: Int
+ }
+ deriving (Show, Eq, Ord)
+
+data PrlgInt
+ = CallI Id [PrlgInt]
+ | LiteralI Int
+ | VarI Int Int
+ | VoidI
+ deriving (Show)
+
+data StrTable =
+ StrTable Int (M.Map String Int) (M.Map Int String)
+ deriving (Show)
+
+emptystrtable = StrTable 0 M.empty M.empty
+
+strtablize t@(StrTable nxt fwd rev) str =
+ case fwd M.!? str of
+ Just i -> (t, i)
+ _ -> (StrTable (nxt + 1) (M.insert str nxt fwd) (M.insert nxt str rev), nxt)