1module Generate.JavaScript.BuiltIn where
3import qualified Language.ECMAScript3.Syntax as JS
5import Generate.JavaScript.Helpers
6import qualified Reporting.Region as R
9utils :: String -> [JS.Expression ()] -> JS.Expression ()
11 obj ["_utils", func] `call` args
16character :: Char -> JS.Expression ()
18 utils "chr" [ JS.StringLit () [char] ]
21string :: String -> JS.Expression ()
28list :: [JS.Expression ()] -> JS.Expression ()
30 utils "list" [ JS.ArrayLit () elements ]
33range :: JS.Expression () -> JS.Expression () -> JS.Expression ()
35 utils "range" [ low, high ]
40recordUpdate :: JS.Expression () -> [(String, JS.Expression ())] -> JS.Expression ()
41recordUpdate record fields =
42 utils "update" [ record, JS.ArrayLit () (map toKeyValue fields) ]
45toKeyValue :: (String, JS.Expression ()) -> JS.Expression ()
46toKeyValue (key, value) =
47 JS.ArrayLit () [ JS.StringLit () key, value ]
52eq :: JS.Expression () -> JS.Expression () -> JS.Expression ()
54 utils "eq" [ left, right ]
57compare :: JS.Expression () -> JS.Expression () -> JS.Expression ()
59 utils "compare" [ left, right ]
64crash :: R.Region -> Maybe String -> JS.Expression ()
65crash region maybeCaseCrashValue =
66 case maybeCaseCrashValue of
68 utils "crash" [ regionToJs region ]
71 utils "caseCrash" [ regionToJs region, ref crashValue ]
74regionToJs :: R.Region -> JS.Expression ()
75regionToJs (R.Region start end) =
77 [ ( prop "start", positionToJs start )
78 , ( prop "end", positionToJs end )
82positionToJs :: R.Position -> JS.Expression ()
83positionToJs (R.Position line column) =
85 [ ( prop "line", JS.IntLit () line )
86 , ( 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