aboutsummaryrefslogtreecommitdiff
path: root/snug-clean/src/Snug/Compile
diff options
context:
space:
mode:
Diffstat (limited to 'snug-clean/src/Snug/Compile')
-rw-r--r--snug-clean/src/Snug/Compile/ABI.dcl1
-rw-r--r--snug-clean/src/Snug/Compile/ABI.icl6
2 files changed, 7 insertions, 0 deletions
diff --git a/snug-clean/src/Snug/Compile/ABI.dcl b/snug-clean/src/Snug/Compile/ABI.dcl
index 6de2953..c7fe7ad 100644
--- a/snug-clean/src/Snug/Compile/ABI.dcl
+++ b/snug-clean/src/Snug/Compile/ABI.dcl
@@ -21,3 +21,4 @@ TempImm :== T 0
constructorLabel :: !Namespace !ConstructorIdent -> Label
functionLabel :: !Namespace !EntryPoint !SymbolIdent -> Label
+closureLabel :: !Namespace !SymbolIdent !Int -> Label
diff --git a/snug-clean/src/Snug/Compile/ABI.icl b/snug-clean/src/Snug/Compile/ABI.icl
index 66a8d5c..225f09c 100644
--- a/snug-clean/src/Snug/Compile/ABI.icl
+++ b/snug-clean/src/Snug/Compile/ABI.icl
@@ -20,11 +20,15 @@ where
e = case entry_point of
NodeEntry -> 'n'
+closureLabel :: !Namespace !SymbolIdent !Int -> Label
+closureLabel ns id nargs = constructorLabel ns (concat3 id "@" (toString nargs))
+
escapeLabel :: !String -> String
escapeLabel s = {#c \\ c <- escape [c \\ c <-: s]}
where
escape [] = []
escape [c:cs] | isAlphanum c = [c:escape cs]
+ // Symbols allowed in snug but not in symbol names:
escape ['_':cs] = ['__':escape cs]
escape ['`':cs] = ['_B':escape cs]
escape [':':cs] = ['_C':escape cs]
@@ -36,3 +40,5 @@ where
escape ['+':cs] = ['_P':escape cs]
escape ['\'':cs] = ['_Q':escape cs]
escape ['~':cs] = ['_T':escape cs]
+ // Symbols not allowed in snug but used internally:
+ escape ['@':cs] = ['_c':escape cs] // see closureLabel