@@ -35,47 +35,9 @@ jsEscape = concatMap jschar
3535 | x == '.' = "__"
3636 | otherwise = "_" ++ show (fromEnum x) ++ "_"
3737
38−showCGJS :: Name -> String
39−showCGJS (UN n) = "u$" ++ jsEscape (T.unpack n)
40−showCGJS (NS n s) = "q_" ++ show (length s) ++ "$" ++ showSep "$" (map (jsEscape . T.unpack) (reverse s))
41− ++ "$" ++ showCGJS n
42−showCGJS (MN _ u) | u == txt "underscore" = "_"
43−showCGJS (MN i s) = "t$" ++ jsEscape (T.unpack s) ++ "$" ++ show i
44−showCGJS (SN s) = showCGJS' s
45− where
46− showCGJS' (WhereN i p c) =
47− "where$" ++ showCGJS p ++ "$" ++ showCGJS c ++ "$" ++ show i
48− showCGJS' (WithN i n) = "with$" ++ showCGJS n ++ "$" ++ show i
49− showCGJS' (ImplementationN cl impl) =
50− "impl_" ++ show (length impl) ++ "$" ++ showCGJS cl ++ "$"
51− ++ showSep "$" (map (jsEscape . T.unpack) impl)
52− showCGJS' (MethodN m) = "meth$" ++ showCGJS m
53− showCGJS' (ParentN p c) = "parent$" ++ showCGJS p ++ "$" ++ show c
54− showCGJS' (CaseN fc c) = "case$" ++ showCGJS c ++ "$" ++ showFC' fc
55− showCGJS' (ElimN sn) = "elim$" ++ showCGJS sn
56− showCGJS' (ImplementationCtorN n) = "ictor$" ++ showCGJS n
57− showCGJS' (MetaN parent meta) =
58− "meta$" ++ showCGJS parent ++ "$" ++ showCGJS meta
59− showFC' (FC' NoFC) = ""
60− showFC' (FC' (FileFC f)) = "_" ++ cgFN f
61− showFC' (FC' (FC f s e))
62− | s == e = "_" ++ cgFN f ++ "_" ++ show (fst s) ++ "_" ++ show (snd s)
63− | otherwise =
64− "_" ++
65− cgFN f ++
66− "_" ++
67− show (fst s) ++
68− "_" ++ show (snd s) ++ "_" ++ show (fst e) ++ "_" ++ show (snd e)
69− cgFN =
70− concatMap
71− (\c ->
72− if not (isDigit c || isLetter c)
73− then "__"
74− else [c])
75−showCGJS (SymRef i) = error "can't do codegen for a symbol reference"
76−
7738jsName :: Name -> Text
78−jsName n = T.pack $ showCGJS n
39+jsName (MN i u) = T.concat ["$_", T.pack (show i), "_", T.pack $ jsEscape $ T.unpack u]
40+jsName n = T.pack $ jsEscape $ showCG n
7941
8042jsNameGenerated :: Int -> Text
8143jsNameGenerated v = T.pack $ "$cg$" ++ show v