1module Generate.JavaScript.BuiltIn where
3import Control.Arrow (first)
4import qualified Language.ECMAScript3.Syntax as JS
6import qualified AST.Module.Name as ModuleName
7import Generate.JavaScript.Helpers
8import qualified Reporting.Region as R
12utils :: String -> [JS.Expression ()] -> JS.Expression ()
14 obj ["_U", func] `call` args
21character :: Char -> JS.Expression ()
23 utils "chr" [ JS.StringLit () [char] ]
26string :: String -> JS.Expression ()
35list :: [JS.Expression ()] -> JS.Expression ()
37 utils "list" [ JS.ArrayLit () elements ]
40range :: JS.Expression () -> JS.Expression () -> JS.Expression ()
42 utils "range" [ low, high ]
49recordUpdate :: JS.Expression () -> [(String, JS.Expression ())] -> JS.Expression ()
50recordUpdate record fields =
53 , JS.ObjectLit () (map (first prop) fields)
61eq :: JS.Expression () -> JS.Expression () -> JS.Expression ()
63 utils "eq" [ left, right ]
66cmp :: JS.Expression () -> JS.Expression () -> JS.Expression ()
68 utils "cmp" [ left, right ]
75crash :: ModuleName.Canonical -> R.Region -> Maybe (JS.Expression ()) -> JS.Expression ()
76crash home region maybeCaseCrashValue =
79 JS.StringLit () (ModuleName.canonicalToString home)
81 case maybeCaseCrashValue of
83 utils "crash" [ homeString, regionToJs region ]
86 utils "crashCase" [ homeString, regionToJs region, crashValue ]
89regionToJs :: R.Region -> JS.Expression ()
90regionToJs (R.Region start end) =
92 [ ( prop "start", positionToJs start )
93 , ( prop "end", positionToJs end )
97positionToJs :: R.Position -> JS.Expression ()
98positionToJs (R.Position line column) =
100 [ ( prop "line", JS.IntLit () line )
101 , ( 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