Collect shape functions and classes in one place, perhaps for later use.
authorNorman Ramsey <nr@cs.tufts.edu>
Mon, 21 Jun 2010 17:14:54 +0000 (13:14 -0400)
committerNorman Ramsey <nr@cs.tufts.edu>
Mon, 21 Jun 2010 17:14:54 +0000 (13:14 -0400)
src/Compiler/Hoopl/Shape.hs [new file with mode: 0644]
src/hoopl.cabal

diff --git a/src/Compiler/Hoopl/Shape.hs b/src/Compiler/Hoopl/Shape.hs
new file mode 100644 (file)
index 0000000..f1d71ea
--- /dev/null
@@ -0,0 +1,50 @@
+{-# LANGUAGE GADTs, EmptyDataDecls #-}
+
+module Compiler.Hoopl.Shape {-# DEPRECATED "not ready to migrate to this yet" #-}
+where
+
+-- | Used at the type level to indicate an "open" structure with    
+-- a unique, unnamed control-flow edge flowing in or out.         
+-- "Fallthrough" and concatenation are permitted at an open point.
+data O 
+       
+       
+-- | Used at the type level to indicate a "closed" structure which
+-- supports control transfer only through the use of named
+-- labels---no "fallthrough" is permitted.  The number of control-flow
+-- edges is unconstrained.
+data C
+
+
+data HalfShape s where
+  ShapeO :: HalfShape O
+  ShapeC :: HalfShape C
+
+data Shape e x where
+  ShapeOO :: Shape O O
+  ShapeCO :: Shape C O
+  ShapeOC :: Shape O C
+  ShapeCC :: Shape C C
+
+class Shapely n where
+  shape        :: n e x -> Shape e x
+  shapeAtEntry :: n e x -> HalfShape e
+  shapeAtExit  :: n e x -> HalfShape x
+
+  shapeAtEntry = entryHalfShape . shape
+  shapeAtExit  = exitHalfShape  . shape
+  
+
+entryHalfShape :: Shape e x -> HalfShape e
+exitHalfShape  :: Shape e x -> HalfShape x
+
+entryHalfShape ShapeOO = ShapeO
+entryHalfShape ShapeOC = ShapeO
+entryHalfShape ShapeCO = ShapeC
+entryHalfShape ShapeCC = ShapeC
+
+exitHalfShape ShapeOO = ShapeO
+exitHalfShape ShapeOC = ShapeC
+exitHalfShape ShapeCO = ShapeO
+exitHalfShape ShapeCC = ShapeC
+
index c4cf3db..b0c7088 100644 (file)
@@ -31,11 +31,14 @@ Library
                        Compiler.Hoopl.Dataflow,
                        Compiler.Hoopl.Debug,
                        Compiler.Hoopl.Graph, 
+                       Compiler.Hoopl.Label,
                        Compiler.Hoopl.MkGraph,
                        Compiler.Hoopl.Fuel,
                        Compiler.Hoopl.Pointed,
-                       Compiler.Hoopl.Unique, Compiler.Hoopl.Label,
-                       Compiler.Hoopl.Show, Compiler.Hoopl.Util
+                       Compiler.Hoopl.Shape,
+                       Compiler.Hoopl.Show, 
+                       Compiler.Hoopl.Unique, 
+                       Compiler.Hoopl.Util
                        Compiler.Hoopl.XUtil
   ghc-options:       -Wall -fno-warn-name-shadowing