git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Revisit identifier renaming
7884926Andy Arvanitis
src/CodeGen/IL/Common.hs+6−16
@@ -50,17 +50,17 @@ unusedName = "_"
50
50
51properToIL :: Text -> Text
51properToIL :: Text -> Text
52properToIL name
52properToIL name
53− | nameIsILReserved name || nameIsILBuiltIn name || prefixIsReserved name = name <> "ˉ"
53+ | nameIsILReserved name = "ˉ" <> name
54 | otherwise = T.concatMap identCharToText name
54 | otherwise = T.concatMap identCharToText name
55
55
56-- | Attempts to find a human-readable name for a symbol, if none has been specified returns the
56-- | Attempts to find a human-readable name for a symbol, if none has been specified returns the
57-- ordinal value.
57-- ordinal value.
58identCharToText :: Char -> Text
58identCharToText :: Char -> Text
59−identCharToText 'ṩ' = "ᵤṩ"
59+identCharToText 'ṩ' = "_ṩ"
60identCharToText c | isAlphaNum c = T.singleton c
60identCharToText c | isAlphaNum c = T.singleton c
61identCharToText '_' = "_"
61identCharToText '_' = "_"
62−identCharToText '\'' = "ᵖ"
62+identCharToText '\'' = "ꞌ" -- lowercase saltillo
63−identCharToText c = "ᵤ" <> T.pack (show (ord c))
63+identCharToText c = error (show (ord c)) -- TODO: should never occur now(?)
64
64
65moduleProperToIL :: Text -> Text
65moduleProperToIL :: Text -> Text
66moduleProperToIL = T.concatMap identCharToText
66moduleProperToIL = T.concatMap identCharToText
@@ -126,16 +126,6 @@ ilKeywords =
126 , "var"
126 , "var"
127 ]
127 ]
128
128
129−-- moduleIsReserved :: Text -> Bool
130−-- moduleIsReserved "Main" = False
131−-- moduleIsReserved name = not $ T.isInfixOf "_" name
132−
133−prefixIsReserved :: Text -> Bool
134−prefixIsReserved name =
135− any (`T.isPrefixOf` name)
136− [
137− ]
138−
139ilLiterals :: [Text]
129ilLiterals :: [Text]
140ilLiterals =
130ilLiterals =
141 [ "init"
131 [ "init"
@@ -161,7 +151,7 @@ ilLiterals =
161 ]
151 ]
162
152
163withPrefix :: Text -> Text
153withPrefix :: Text -> Text
164−withPrefix s = "Ꞌ" <> s
154+withPrefix s = "Ꞌ" <> s -- uppercase saltillo
165
155
166anyType :: Text
156anyType :: Text
167anyType = "Any"
157anyType = "Any"
@@ -202,4 +192,4 @@ freshName' = do
202 return $ T.replace "$" "ṩ" name
192 return $ T.replace "$" "ṩ" name
203
193
204moduleRenamerMarker :: Text
194moduleRenamerMarker :: Text
205−moduleRenamerMarker = "ᴹ"
195+moduleRenamerMarker = "__"
src/CodeGen/IL/Optimizer/TCO.hs+5−5
@@ -12,21 +12,21 @@ import CodeGen.IL.Common
12import qualified Language.PureScript.Constants as C
12import qualified Language.PureScript.Constants as C
13
13
14tcoLoop :: Text
14tcoLoop :: Text
15−tcoLoop = "__tco_loop"
15+tcoLoop = "ṩtco_loop"
16
16
17tco :: AST -> AST -> AST
17tco :: AST -> AST -> AST
18tco mn = everywhere convert where
18tco mn = everywhere convert where
19 tcoVar :: Text -> Text
19 tcoVar :: Text -> Text
20− tcoVar arg = "__tco_var_" <> arg
20+ tcoVar arg = "ṩtco_var_" <> arg
21
21
22 copyVar :: Text -> Text
22 copyVar :: Text -> Text
23− copyVar arg = "__copy_" <> arg
23+ copyVar arg = "ṩcopy_" <> arg
24
24
25 tcoDone :: Text
25 tcoDone :: Text
26− tcoDone = "__tco_done"
26+ tcoDone = "ṩtco_done"
27
27
28 tcoResult :: Text
28 tcoResult :: Text
29− tcoResult = "__tco_result"
29+ tcoResult = "ṩtco_result"
30
30
31 convert :: AST -> AST
31 convert :: AST -> AST
32 convert fn@(Function ss (Just name) args _)
32 convert fn@(Function ss (Just name) args _)
src/CodeGen/IL/Printer.hs+2−2
@@ -521,7 +521,7 @@ ffiLoader :: Text
521ffiLoader = modLabel <> "/ffi-loader"
521ffiLoader = modLabel <> "/ffi-loader"
522
522
523initName :: Text -> Text
523initName :: Text -> Text
524−initName s = "_" <> s <> "ᵒⁿᶜᵉ"
524+initName s = "ᛌ" <> s <> "_once"
525
525
526valueName :: Text -> Text
526valueName :: Text -> Text
527−valueName s = "_" <> s <> "ᶠᵒʳᵉⁱᵍⁿ"
527+valueName s = "ᛧ" <> s