1module Generate.JavaScript.BuiltIn where
3import Control.Arrow (first)
4import qualified Language.ECMAScript3.Syntax as JS
6import Generate.JavaScript.Helpers
7import qualified Reporting.Region as R
10utils :: String -> [JS.Expression ()] -> JS.Expression ()
12 obj ["_U", func] `call` args
17character :: Char -> JS.Expression ()
19 utils "chr" [ JS.StringLit () [char] ]
22string :: String -> JS.Expression ()
29list :: [JS.Expression ()] -> JS.Expression ()
31 utils "list" [ JS.ArrayLit () elements ]
34range :: JS.Expression () -> JS.Expression () -> JS.Expression ()
36 utils "range" [ low, high ]
41recordUpdate :: JS.Expression () -> [(String, JS.Expression ())] -> JS.Expression ()
42recordUpdate record fields =
45 , JS.ObjectLit () (map (first prop) fields)
51eq :: JS.Expression () -> JS.Expression () -> JS.Expression ()
53 utils "eq" [ left, right ]
56cmp :: JS.Expression () -> JS.Expression () -> JS.Expression ()
58 utils "cmp" [ left, right ]
63crash :: R.Region -> Maybe String -> JS.Expression ()
64crash region maybeCaseCrashValue =
65 case maybeCaseCrashValue of
67 utils "crash" [ regionToJs region ]
70 utils "caseCrash" [ regionToJs region, ref crashValue ]
73regionToJs :: R.Region -> JS.Expression ()
74regionToJs (R.Region start end) =
76 [ ( prop "start", positionToJs start )
77 , ( prop "end", positionToJs end )
81positionToJs :: R.Position -> JS.Expression ()
82positionToJs (R.Position line column) =
84 [ ( prop "line", JS.IntLit () line )
85 , ( prop "column", JS.IntLit () column )
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