2module Generate.JavaScript.Helpers where
4import qualified SourceSyntax.Helpers as Help
5import Language.ECMAScript3.Syntax
7split :: String -> [String]
11 case break (=='.') str of
12 (x,_:rest) | Help.isOp x -> vars ++ [x ++ '.' : rest]
13 | otherwise -> go (vars ++ [x]) rest
17ref name = VarRef () (var name)
18prop name = PropId () (var name)
19f <| x = CallExpr () f [x]
20ret e = ReturnStmt () (Just e)
21args ==> e = FuncExpr () Nothing (map var args) [ ret e ]
22function args stmts = FuncExpr () Nothing (map var args) stmts
28 x:xs -> foldl (DotRef ()) (ref x) (map var xs)
29 [] -> error "dotSep must be called on a non-empty list of variables"
33equal a b = InfixExpr () OpStrictEq a b
35 InfixExpr () OpLAnd (typeof "object" x) (InfixExpr () OpInstanceof x (ref tipe))
36typeof tipe x = equal (PrefixExpr () PrefixTypeof x) (string tipe)
37member field x = InfixExpr () OpIn (string field) x
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