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