2Module : IRTS.JavaScript.Name
3Description : The JavaScript name mangler.
6Maintainer : The Idris Community.
9{-# LANGUAGE OverloadedStrings, PatternGuards #-}
11module IRTS.JavaScript.Name
24import qualified Data.Map.Strict as Map
25import Data.Text (Text)
26import qualified Data.Text as T
28import IRTS.JavaScript.AST
30jsEscape :: String -> String
31jsEscape = concatMap jschar
34 | isAlpha x || isDigit x = [x]
36 | otherwise = "_" ++ show (fromEnum x) ++ "_"
39jsName (MN i u) = T.concat ["$_", T.pack (show i), "_", T.pack $ jsEscape $ T.unpack u]
40jsName n = T.pack $ jsEscape $ showCG n
42jsNameGenerated :: Int -> Text
43jsNameGenerated v = T.pack $ "$cg$" ++ show v
45data Partial = Partial Name Int Int deriving (Eq, Ord)
47jsNamePartial :: Partial -> Text
48jsNamePartial (Partial n i j) = T.concat ["$partial_", T.pack $ show i, "_", T.pack $ show j, "$" , jsName n]
50jsTailCallOptimName :: Text -> Text
51jsTailCallOptimName x = T.concat ["$tco$", x]
54data HiddenClass = HiddenClass Name Int Int deriving (Eq, Ord)
56jsNameHiddenClass :: HiddenClass -> Text
57jsNameHiddenClass (HiddenClass n id arity) = T.concat ["$HC_", T.pack $ show arity, "_", T.pack $ show id,"$", jsName n]
59dataPartName :: Int -> Text
60dataPartName i = T.pack $ "$" ++ show i
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