1{-# OPTIONS_GHC -Wall #-}
21import Control.Monad (liftM, liftM2, liftM3, liftM4)
23import qualified Data.ByteString as BS
24import qualified Data.Map as Map
25import qualified Data.Set as Set
26import Data.Text (Text)
28import qualified AST.Canonical as Can
29import qualified AST.Module.Name as ModuleName
30import qualified Data.Index as Index
31import qualified Elm.Name as N
32import qualified Elm.Package as Pkg
33import qualified Optimize.DecisionTree as DT
34import qualified Reporting.Region as R
49 | VarEnum Global Index.ZeroBased
51 | VarCycle ModuleName.Canonical N.Name
52 | VarDebug N.Name ModuleName.Canonical R.Region (Maybe N.Name)
53 | VarKernel N.Name N.Name
55 | Function [N.Name] Expr
57 | TailCall N.Name [(N.Name, Expr)]
58 | If [(Expr, Expr)] Expr
60 | Destruct Destructor Expr
61 | Case N.Name N.Name (Decider Choice) [(Int, Expr)]
64 | Update Expr (Map.Map N.Name Expr)
65 | Record (Map.Map N.Name Expr)
67 | Tuple Expr Expr (Maybe Expr)
71data Global = Global ModuleName.Canonical N.Name
75-- Provide "List" not "Elm.Kernel.List"
77kernel :: N.Name -> Global
79 Global (ModuleName.Canonical Pkg.kernel home) N.dollar
88 | TailDef N.Name [N.Name] Expr
92 Destructor N.Name Path
96 = Index Index.ZeroBased Path
109 { _testChain :: [(DT.Path, DT.Test)]
110 , _success :: Decider a
111 , _failure :: Decider a
115 , _tests :: [(DT.Test, Decider a)]
116 , _fallback :: Decider a
132 { _mains :: Map.Map ModuleName.Canonical Main
133 , _nodes :: Map.Map Global Node
134 , _fields :: Map.Map N.Name Int
141 { _message :: Can.Type
147 = Define Expr (Set.Set Global)
148 | DefineTailFunc [N.Name] Expr (Set.Set Global)
149 | Ctor N.Name Index.ZeroBased Int
150 | Enum N.Name Index.ZeroBased
153 | Cycle [(N.Name, Expr)] (Set.Set Global)
154 | Manager EffectsType
155 | Kernel KContent (Maybe KContent)
156 | PortIncoming Expr (Set.Set Global)
157 | PortOutgoing Expr (Set.Set Global)
160data EffectsType = Cmd | Sub | Fx
164 KContent [KChunk] (Set.Set Global)
169 | ElmVar ModuleName.Canonical N.Name
170 | JsVar N.Name N.Name
182instance Binary Global where
183 get = liftM2 Global get get
184 put (Global a b) = put a >> put b
187instance Binary Expr where
190 Bool a -> putWord8 0 >> put a
191 Chr a -> putWord8 1 >> put a
192 Str a -> putWord8 2 >> put a
193 Int a -> putWord8 3 >> put a
194 Float a -> putWord8 4 >> put a
195 VarLocal a -> putWord8 5 >> put a
196 VarGlobal a -> putWord8 6 >> put a
197 VarEnum a b -> putWord8 7 >> put a >> put b
198 VarBox a -> putWord8 8 >> put a
199 VarCycle a b -> putWord8 9 >> put a >> put b
200 VarDebug a b c d -> putWord8 10 >> put a >> put b >> put c >> put d
201 VarKernel a b -> putWord8 11 >> put a >> put b
202 List a -> putWord8 12 >> put a
203 Function a b -> putWord8 13 >> put a >> put b
204 Call a b -> putWord8 14 >> put a >> put b
205 TailCall a b -> putWord8 15 >> put a >> put b
206 If a b -> putWord8 16 >> put a >> put b
207 Let a b -> putWord8 17 >> put a >> put b
208 Destruct a b -> putWord8 18 >> put a >> put b
209 Case a b c d -> putWord8 19 >> put a >> put b >> put c >> put d
210 Accessor a -> putWord8 20 >> put a
211 Access a b -> putWord8 21 >> put a >> put b
212 Update a b -> putWord8 22 >> put a >> put b
213 Record a -> putWord8 23 >> put a
215 Tuple a b c -> putWord8 25 >> put a >> put b >> put c
216 Shader a -> putWord8 26 >> put a
226 5 -> liftM VarLocal get
227 6 -> liftM VarGlobal get
228 7 -> liftM2 VarEnum get get
229 8 -> liftM VarBox get
230 9 -> liftM2 VarCycle get get
231 10 -> liftM4 VarDebug get get get get
232 11 -> liftM2 VarKernel get get
234 13 -> liftM2 Function get get
235 14 -> liftM2 Call get get
236 15 -> liftM2 TailCall get get
237 16 -> liftM2 If get get
238 17 -> liftM2 Let get get
239 18 -> liftM2 Destruct get get
240 19 -> liftM4 Case get get get get
241 20 -> liftM Accessor get
242 21 -> liftM2 Access get get
243 22 -> liftM2 Update get get
244 23 -> liftM Record get
246 25 -> liftM3 Tuple get get get
247 26 -> liftM Shader get
248 _ -> error "problem getting Opt.Expr binary"
251instance Binary Def where
254 Def a b -> putWord8 0 >> put a >> put b
255 TailDef a b c -> putWord8 1 >> put a >> put b >> put c
260 0 -> liftM2 Def get get
261 1 -> liftM3 TailDef get get get
262 _ -> error "problem getting Opt.Def binary"
265instance Binary Destructor where
266 get = liftM2 Destructor get get
267 put (Destructor a b) = put a >> put b
270instance Binary Path where
273 Index a b -> putWord8 0 >> put a >> put b
274 Field a b -> putWord8 1 >> put a >> put b
275 Unbox a -> putWord8 2 >> put a
276 Root a -> putWord8 3 >> put a
281 0 -> liftM2 Index get get
282 1 -> liftM2 Field get get
285 _ -> error "problem getting Opt.Path binary"
288instance (Binary a) => Binary (Decider a) where
291 Leaf a -> putWord8 0 >> put a
292 Chain a b c -> putWord8 1 >> put a >> put b >> put c
293 FanOut a b c -> putWord8 2 >> put a >> put b >> put c
299 1 -> liftM3 Chain get get get
300 2 -> liftM3 FanOut get get get
301 _ -> error "problem getting Opt.Decider binary"
304instance Binary Choice where
307 Inline expr -> putWord8 0 >> put expr
308 Jump index -> putWord8 1 >> put index
313 0 -> liftM Inline get
315 _ -> error "problem getting Opt.Choice binary"
319instance Binary Graph where
320 get = liftM3 Graph get get get
321 put (Graph a b c) = put a >> put b >> put c
324instance Binary Main where
328 Dynamic a b -> putWord8 1 >> put a >> put b
334 1 -> liftM2 Dynamic get get
335 _ -> error "problem getting Opt.Main binary"
338instance Binary Node where
341 Define a b -> putWord8 0 >> put a >> put b
342 DefineTailFunc a b c -> putWord8 1 >> put a >> put b >> put c
343 Ctor a b c -> putWord8 2 >> put a >> put b >> put c
344 Enum a b -> putWord8 3 >> put a >> put b
345 Box a -> putWord8 4 >> put a
346 Link a -> putWord8 5 >> put a
347 Cycle a b -> putWord8 6 >> put a >> put b
348 Manager a -> putWord8 7 >> put a
349 Kernel a b -> putWord8 8 >> put a >> put b
350 PortIncoming a b -> putWord8 9 >> put a >> put b
351 PortOutgoing a b -> putWord8 10 >> put a >> put b
356 0 -> liftM2 Define get get
357 1 -> liftM3 DefineTailFunc get get get
358 2 -> liftM3 Ctor get get get
359 3 -> liftM2 Enum get get
362 6 -> liftM2 Cycle get get
363 7 -> liftM Manager get
364 8 -> liftM2 Kernel get get
365 9 -> liftM2 PortIncoming get get
366 10 -> liftM2 PortOutgoing get get
367 _ -> error "problem getting Opt.Node binary"
370instance Binary EffectsType where
383 _ -> error "problem getting Opt.EffectsType binary"
386instance Binary KContent where
387 get = liftM2 KContent get get
388 put (KContent a b) = put a >> put b
391instance Binary KChunk where
394 JS a -> putWord8 0 >> put a
395 ElmVar a b -> putWord8 1 >> put a >> put b
396 JsVar a b -> putWord8 2 >> put a >> put b
397 ElmField a -> putWord8 3 >> put a
398 JsField a -> putWord8 4 >> put a
399 JsEnum a -> putWord8 5 >> put a
407 1 -> liftM2 ElmVar get get
408 2 -> liftM2 JsVar get get
409 3 -> liftM ElmField get
410 4 -> liftM JsField get
411 5 -> liftM JsEnum get
414 _ -> 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