aboutsummaryrefslogtreecommitdiff
path: root/ast/CC/Typed.hs
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-06-10 19:59:03 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-06-10 19:59:13 +0200
commitbc52411ae2ed26cab1d5086ae6df68f23ebbd052 (patch)
tree365e7bab678bb46981befe5b2a1c0c967a9a9c57 /ast/CC/Typed.hs
Initial state I found the code in
Diffstat (limited to 'ast/CC/Typed.hs')
-rw-r--r--ast/CC/Typed.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/ast/CC/Typed.hs b/ast/CC/Typed.hs
new file mode 100644
index 0000000..b11067f
--- /dev/null
+++ b/ast/CC/Typed.hs
@@ -0,0 +1,35 @@
+module CC.Typed(
+ module CC.Typed,
+ module CC.Types
+) where
+
+import CC.Types
+
+
+data ProgramT = ProgramT [DeclT]
+ deriving (Show, Read)
+
+data DeclT = DefT DefT -- import?
+ deriving (Show, Read)
+
+data DefT = FunctionT TypeT Name [Name] ExprT
+ deriving (Show, Read)
+
+data TypeT = TFunT TypeT TypeT
+ | TIntT
+ | TyVar Int
+ deriving (Show, Read)
+
+data ExprT = CallT TypeT ExprT ExprT
+ | IntT Int
+ | VarT Occ
+ deriving (Show, Read)
+
+-- | Occurrence of a variable
+data Occ = Occ Name TypeT
+ deriving (Show, Read)
+
+exprType :: ExprT -> TypeT
+exprType (CallT typ _ _) = typ
+exprType (IntT _) = TIntT
+exprType (VarT (Occ _ typ)) = typ