on 267f708 help sign in
elk/src/AST/Expression/Optimized.hs
80 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.General as Expr
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 , dependencies :: [Var.TopLevel]
28 }
31dummyFacts :: Facts
32dummyFacts =
33 Facts Nothing []
36-- EXPRESSIONS
38data Expr
39 = Literal Literal.Literal
40 | Var Var.Canonical
41 | ExplicitList [Expr]
42 | Binop Var.Canonical Expr Expr
43 | Function [String] Expr
44 | Call Expr [Expr]
45 | TailCall String [String] [Expr]
46 | If [(Expr, Expr)] Expr
47 | Let [Def] Expr
48 | Case String (Decider Choice) [(Int, Expr)]
49 | Data String [Expr]
50 | DataAccess Expr Int
51 | Access Expr String
52 | Update Expr [(String, Expr)]
53 | Record [(String, Expr)]
54 | Cmd ModuleName.Canonical
55 | Sub ModuleName.Canonical
56 | OutgoingPort String Type.Canonical
57 | IncomingPort String Type.Canonical
58 | Program (Expr.Main Type.Canonical) Expr
59 | GLShader String String Literal.GLShaderTipe
60 | Crash ModuleName.Canonical R.Region (Maybe Expr)
63data Decider a
64 = Leaf a
65 | Chain
66 { _testChain :: [(DT.Path, DT.Test)]
67 , _success :: Decider a
68 , _failure :: Decider a
69 }
70 | FanOut
71 { _path :: DT.Path
72 , _tests :: [(DT.Test, Decider a)]
73 , _fallback :: Decider a
74 }
75 deriving (Eq)
78data Choice
79 = Inline Expr
80 | Jump Int