summaryrefslogtreecommitdiff
path: root/devel/compiler/TMacros.hs
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2007-03-27 16:32:44 +0000
committeraarne <aarne@cs.chalmers.se>2007-03-27 16:32:44 +0000
commit1c1acf1b971d13a496a92b9d8d6b14fde85e28f3 (patch)
tree7fc40594193cbf6435feb5425ee2e4feb2652d32 /devel/compiler/TMacros.hs
parent273dc7120f9ce0b469dc081d6a3382f096a4f97b (diff)
top-level toy compiler - far from complete
Diffstat (limited to 'devel/compiler/TMacros.hs')
-rw-r--r--devel/compiler/TMacros.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/devel/compiler/TMacros.hs b/devel/compiler/TMacros.hs
new file mode 100644
index 000000000..467b6ce4f
--- /dev/null
+++ b/devel/compiler/TMacros.hs
@@ -0,0 +1,16 @@
+module TMacros where
+
+import AbsTgt
+
+appVal :: Val -> [Val] -> Val
+appVal v vs = compVal vs v
+
+compVal :: [Val] -> Val -> Val
+compVal args = comp where
+ comp val = case val of
+ VRec vs -> VRec $ map comp vs
+ VPro r p -> case (comp r, comp p) of
+ (VRec vs, VPar i) -> vs !! fromInteger i
+ VArg i -> args !! fromInteger i
+ VCat x y -> VCat (comp x) (comp y)
+ _ -> val