git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Revisit identifier renaming
commit7884926d6757a18f769dc35fe80c63e5872d9c82 authorAndy Arvanitis <andyarvanitis@gmail.com> dateMon 5 Oct 2020, 21:39 (6 years ago) parentcada634
3 files changed+13−23
src/CodeGen/IL/Common.hs+6−16 src/CodeGen/IL/Optimizer/TCO.hs+5−5 src/CodeGen/IL/Printer.hs+2−2
src/CodeGen/IL/Common.hs+6−16
@@ -50,17 +50,17 @@ unusedName = "_"
5050
5151properToIL :: Text -> Text
5252properToIL name
53− | nameIsILReserved name || nameIsILBuiltIn name || prefixIsReserved name = name <> "ˉ"
53+ | nameIsILReserved name = "ˉ" <> name
5454 | otherwise = T.concatMap identCharToText name
5555
5656-- | Attempts to find a human-readable name for a symbol, if none has been specified returns the
5757-- ordinal value.
5858identCharToText :: Char -> Text
59−identCharToText 'ṩ' = "ᵤṩ"
59+identCharToText 'ṩ' = "_ṩ"
6060identCharToText c | isAlphaNum c = T.singleton c
6161identCharToText '_' = "_"
62−identCharToText '\'' = "ᵖ"
63−identCharToText c = "ᵤ" <> T.pack (show (ord c))
62+identCharToText '\'' = "ꞌ" -- lowercase saltillo
63+identCharToText c = error (show (ord c)) -- TODO: should never occur now(?)
6464
6565moduleProperToIL :: Text -> Text
6666moduleProperToIL = T.concatMap identCharToText
@@ -126,16 +126,6 @@ ilKeywords =
126126 , "var"
127127 ]
128128
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−
139129ilLiterals :: [Text]
140130ilLiterals =
141131 [ "init"
@@ -161,7 +151,7 @@ ilLiterals =
161151 ]
162152
163153withPrefix :: Text -> Text
164−withPrefix s = "Ꞌ" <> s
154+withPrefix s = "Ꞌ" <> s -- uppercase saltillo
165155
166156anyType :: Text
167157anyType = "Any"
@@ -202,4 +192,4 @@ freshName' = do
202192 return $ T.replace "$" "ṩ" name
203193
204194moduleRenamerMarker :: Text
205−moduleRenamerMarker = "ᴹ"
195+moduleRenamerMarker = "__"
src/CodeGen/IL/Optimizer/TCO.hs+5−5
@@ -12,21 +12,21 @@ import CodeGen.IL.Common
1212import qualified Language.PureScript.Constants as C
1313
1414tcoLoop :: Text
15−tcoLoop = "__tco_loop"
15+tcoLoop = "ṩtco_loop"
1616
1717tco :: AST -> AST -> AST
1818tco mn = everywhere convert where
1919 tcoVar :: Text -> Text
20− tcoVar arg = "__tco_var_" <> arg
20+ tcoVar arg = "ṩtco_var_" <> arg
2121
2222 copyVar :: Text -> Text
23− copyVar arg = "__copy_" <> arg
23+ copyVar arg = "ṩcopy_" <> arg
2424
2525 tcoDone :: Text
26− tcoDone = "__tco_done"
26+ tcoDone = "ṩtco_done"
2727
2828 tcoResult :: Text
29− tcoResult = "__tco_result"
29+ tcoResult = "ṩtco_result"
3030
3131 convert :: AST -> AST
3232 convert fn@(Function ss (Just name) args _)
src/CodeGen/IL/Printer.hs+2−2
@@ -521,7 +521,7 @@ ffiLoader :: Text
521521ffiLoader = modLabel <> "/ffi-loader"
522522
523523initName :: Text -> Text
524−initName s = "_" <> s <> "ᵒⁿᶜᵉ"
524+initName s = "ᛌ" <> s <> "_once"
525525
526526valueName :: Text -> Text
527−valueName s = "_" <> s <> "ᶠᵒʳᵉⁱᵍⁿ"
527+valueName s = "ᛧ" <> s