1module Generate.JavaScript.Variable where
3import qualified AST.Helpers as Help
4import qualified AST.Module as Module
5import qualified AST.Variable as Var
6import qualified Data.List as List
7import qualified Data.Set as Set
8import qualified Generate.JavaScript.Helpers as JS
9import qualified Language.ECMAScript3.Syntax as JS
12swap :: Char -> Char -> Char -> Char
14 if c == from then to else c
17canonical :: Var.Canonical -> JS.Expression ()
18canonical (Var.Canonical home name) =
19 case Help.isOp name of
20 True -> JS.BracketRef () (JS.obj (home' ++ ["_op"])) (JS.string name)
21 False -> JS.obj (home' ++ [ varName name ])
27 Var.Module path -> [ moduleName path ]
30moduleName :: Module.Name -> String
32 '$' : List.intercalate "$" name
35varName :: String -> String
38 if Set.member name jsReserveds then '$' : name else name
40 map (swap '\'' '$') saferName
43value :: Module.Name -> String -> JS.Expression ()
45 canonical (Var.Canonical (Var.Module home) name)
48jsReserveds :: Set.Set String
49jsReserveds = Set.fromList
50 [ "null", "undefined", "Nan", "Infinity", "true", "false", "eval"
51 , "arguments", "int", "byte", "char", "goto", "long", "final", "float"
52 , "short", "double", "native", "throws", "boolean", "abstract", "volatile"
53 , "transient", "synchronized", "function", "break", "case", "catch"
54 , "continue", "debugger", "default", "delete", "do", "else", "finally"
55 , "for", "function", "if", "in", "instanceof", "new", "return", "switch"
56 , "this", "throw", "try", "typeof", "var", "void", "while", "with", "class"
57 , "const", "enum", "export", "extends", "import", "super", "implements"
58 , "interface", "let", "package", "private", "protected", "public"
60 -- reserved by the Elm runtime system
62 , "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9"
63 , "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9"
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