on 98db71d help sign in
elk/src/AST/Expression/Optimized.hs
79 lines 1.8 kB history raw
1{-# OPTIONS_GHC -Wall #-}
2module AST.Expression.Optimized
3 ( Def(..), Facts(..), dummyFacts
4 , Expr(..)
5 , Decider(..), Choice(..)
6 ) where
8import qualified AST.Expression.Canonical as Can
9import qualified AST.Literal as Literal
10import qualified AST.Module.Name as ModuleName
11import qualified AST.Type as Type
12import qualified AST.Variable as Var
13import qualified Optimize.DecisionTree as DT
14import qualified Reporting.Region as R
18-- DEFINITIONS
20data Def
21 = Def Facts String Expr
22 | TailDef Facts String [String] Expr
25data Facts = Facts
26 { home :: Maybe ModuleName.Canonical
27 }
30dummyFacts :: Facts
31dummyFacts =
32 Facts Nothing
35-- EXPRESSIONS
37data Expr
38 = Literal Literal.Literal
39 | Var Var.Canonical
40 | List [Expr]
41 | Binop Var.Canonical Expr Expr
42 | Function [String] Expr
43 | Call Expr [Expr]
44 | TailCall String [String] [Expr]
45 | If [(Expr, Expr)] Expr
46 | Let [Def] Expr
47 | Case String (Decider Choice) [(Int, Expr)]
48 | Ctor String [Expr]
49 | CtorAccess Expr Int
50 | Access Expr String
51 | Update Expr [(String, Expr)]
52 | Record [(String, Expr)]
53 | Cmd ModuleName.Canonical
54 | Sub ModuleName.Canonical
55 | OutgoingPort String Type.Canonical
56 | IncomingPort String Type.Canonical
57 | Program Can.Main Expr
58 | GLShader String String Literal.GLShaderTipe
59 | Crash ModuleName.Canonical R.Region (Maybe Expr)
62data Decider a
63 = Leaf a
64 | Chain
65 { _testChain :: [(DT.Path, DT.Test)]
66 , _success :: Decider a
67 , _failure :: Decider a
68 }
69 | FanOut
70 { _path :: DT.Path
71 , _tests :: [(DT.Test, Decider a)]
72 , _fallback :: Decider a
73 }
74 deriving (Eq)
77data Choice
78 = Inline Expr
79 | Jump Int