1{-# OPTIONS_GHC -Wall #-}
19import Control.Monad (liftM, liftM2, liftM3, liftM4)
21import qualified Data.ByteString as BS
22import qualified Data.Map as Map
23import qualified Data.Set as Set
24import Data.Text (Text)
26import qualified AST.Canonical as Can
27import qualified AST.Module.Name as ModuleName
28import qualified Data.Index as Index
29import qualified Elm.Name as N
30import qualified Elm.Package as Pkg
31import qualified Optimize.DecisionTree as DT
32import qualified Reporting.Region as R
46 | VarCycle ModuleName.Canonical N.Name
47 | VarDebug N.Name ModuleName.Canonical R.Region (Maybe N.Name)
48 | VarKernel N.Name N.Name
50 | Function [N.Name] Expr
52 | TailCall N.Name [(N.Name, Expr)]
53 | If [(Expr, Expr)] Expr
55 | Case N.Name N.Name (Decider Choice) [(Int, Expr)]
59 | Update Expr (Map.Map N.Name Expr)
60 | Record (Map.Map N.Name Expr)
62 | Tuple Expr Expr (Maybe Expr)
66data Global = Global ModuleName.Canonical N.Name
70-- Provide "List" not "Elm.Kernel.List"
72kernel :: N.Name -> Global
74 Global (ModuleName.Canonical Pkg.kernel home) N.dollar
83 | TailDef N.Name [N.Name] Expr
93 { _testChain :: [(DT.Path, DT.Test)]
94 , _success :: Decider a
95 , _failure :: Decider a
99 , _tests :: [(DT.Test, Decider a)]
100 , _fallback :: Decider a
116 { _mains :: Map.Map ModuleName.Canonical Main
117 , _nodes :: Map.Map Global Node
118 , _fields :: Map.Map N.Name Int
128 = Define Expr (Set.Set Global)
129 | DefineTailFunc [N.Name] Expr (Set.Set Global)
130 | Ctor N.Name Index.ZeroBased Int
132 | Cycle [(N.Name, Expr)] (Set.Set Global)
133 | Manager EffectsType
134 | Kernel KContent (Maybe KContent)
135 | PortIncoming Expr (Set.Set Global)
136 | PortOutgoing Expr (Set.Set Global)
139data EffectsType = Cmd | Sub | Fx
143 KContent [KChunk] (Set.Set Global)
148 | ElmVar ModuleName.Canonical N.Name
149 | JsVar N.Name N.Name
161instance Binary Global where
162 get = liftM2 Global get get
163 put (Global a b) = put a >> put b
166instance Binary Expr where
169 Chr a -> putWord8 0 >> put a
170 Str a -> putWord8 1 >> put a
171 Int a -> putWord8 2 >> put a
172 Float a -> putWord8 3 >> put a
173 VarLocal a -> putWord8 4 >> put a
174 VarGlobal a -> putWord8 5 >> put a
175 VarCycle a b -> putWord8 6 >> put a >> put b
176 VarDebug a b c d -> putWord8 7 >> put a >> put b >> put c >> put d
177 VarKernel a b -> putWord8 8 >> put a >> put b
178 List a -> putWord8 9 >> put a
179 Function a b -> putWord8 10 >> put a >> put b
180 Call a b -> putWord8 11 >> put a >> put b
181 TailCall a b -> putWord8 12 >> put a >> put b
182 If a b -> putWord8 13 >> put a >> put b
183 Let a b -> putWord8 14 >> put a >> put b
184 Case a b c d -> putWord8 15 >> put a >> put b >> put c >> put d
185 Index a b -> putWord8 16 >> put a >> put b
186 Accessor a -> putWord8 17 >> put a
187 Access a b -> putWord8 18 >> put a >> put b
188 Update a b -> putWord8 19 >> put a >> put b
189 Record a -> putWord8 20 >> put a
191 Tuple a b c -> putWord8 22 >> put a >> put b >> put c
192 Shader a -> putWord8 23 >> put a
201 4 -> liftM VarLocal get
202 5 -> liftM VarGlobal get
203 6 -> liftM2 VarCycle get get
204 7 -> liftM4 VarDebug get get get get
205 8 -> liftM2 VarKernel get get
207 10 -> liftM2 Function get get
208 11 -> liftM2 Call get get
209 12 -> liftM2 TailCall get get
210 13 -> liftM2 If get get
211 14 -> liftM2 Let get get
212 15 -> liftM4 Case get get get get
213 16 -> liftM2 Index get get
214 17 -> liftM Accessor get
215 18 -> liftM2 Access get get
216 19 -> liftM2 Update get get
217 20 -> liftM Record get
219 22 -> liftM3 Tuple get get get
220 23 -> liftM Shader get
221 _ -> error "problem getting Opt.Expr binary"
224instance Binary Def where
227 Def a b -> putWord8 0 >> put a >> put b
228 TailDef a b c -> putWord8 1 >> put a >> put b >> put c
233 0 -> liftM2 Def get get
234 1 -> liftM3 TailDef get get get
235 _ -> error "problem getting Opt.Def binary"
238instance (Binary a) => Binary (Decider a) where
241 Leaf a -> putWord8 0 >> put a
242 Chain a b c -> putWord8 1 >> put a >> put b >> put c
243 FanOut a b c -> putWord8 2 >> put a >> put b >> put c
249 1 -> liftM3 Chain get get get
250 2 -> liftM3 FanOut get get get
251 _ -> error "problem getting Opt.Decider binary"
254instance Binary Choice where
257 Inline expr -> putWord8 0 >> put expr
258 Jump index -> putWord8 1 >> put index
263 0 -> liftM Inline get
265 _ -> error "problem getting Opt.Choice binary"
269instance Binary Graph where
270 get = liftM3 Graph get get get
271 put (Graph a b c) = put a >> put b >> put c
274instance Binary Main where
278 Dynamic a -> putWord8 1 >> put a
284 1 -> liftM Dynamic get
285 _ -> error "problem getting Opt.Main binary"
288instance Binary Node where
291 Define a b -> putWord8 0 >> put a >> put b
292 DefineTailFunc a b c -> putWord8 1 >> put a >> put b >> put c
293 Ctor a b c -> putWord8 2 >> put a >> put b >> put c
294 Link a -> putWord8 3 >> put a
295 Cycle a b -> putWord8 4 >> put a >> put b
296 Manager a -> putWord8 5 >> put a
297 Kernel a b -> putWord8 6 >> put a >> put b
298 PortIncoming a b -> putWord8 7 >> put a >> put b
299 PortOutgoing a b -> putWord8 8 >> put a >> put b
304 0 -> liftM2 Define get get
305 1 -> liftM3 DefineTailFunc get get get
306 2 -> liftM3 Ctor get get get
308 4 -> liftM2 Cycle get get
309 5 -> liftM Manager get
310 6 -> liftM2 Kernel get get
311 7 -> liftM2 PortIncoming get get
312 8 -> liftM2 PortOutgoing get get
313 _ -> error "problem getting Opt.Node binary"
316instance Binary EffectsType where
329 _ -> error "problem getting Opt.EffectsType binary"
332instance Binary KContent where
333 get = liftM2 KContent get get
334 put (KContent a b) = put a >> put b
337instance Binary KChunk where
340 JS a -> putWord8 0 >> put a
341 ElmVar a b -> putWord8 1 >> put a >> put b
342 JsVar a b -> putWord8 2 >> put a >> put b
343 ElmField a -> putWord8 3 >> put a
344 JsField a -> putWord8 4 >> put a
345 Enum a -> putWord8 5 >> put a
353 1 -> liftM2 ElmVar get get
354 2 -> liftM2 JsVar get get
355 3 -> liftM ElmField get
356 4 -> liftM JsField get
360 _ -> error "problem deserializing AST.Optimized.KChunk"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list