From 3b6065d5a92d68f19560b83aa810b2533f85c885 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 21 Jul 2017 07:34:48 +0000 Subject: Prepend labels with __sil_ to prevent name clashes with C functions --- Sil/Compile.icl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Sil') diff --git a/Sil/Compile.icl b/Sil/Compile.icl index 50cc86b..22b6532 100644 --- a/Sil/Compile.icl +++ b/Sil/Compile.icl @@ -96,7 +96,7 @@ typeresolvers cs = cs.typeresolvers fresh :: a -> Gen 'ABC'.Label | toString a fresh n = gets labels >>= \labs -> modify (\cs -> {cs & labels=tl labs}) - $> n <+ hd labs + $> toLabel (n <+ hd labs) storeStackOffset :: Gen () storeStackOffset = modify \cs -> {cs & storedoffsets=[cs.stackoffset:cs.storedoffsets]} @@ -170,7 +170,7 @@ where , 'ABC'.Annotation $ 'ABC'.RawAnnot ["module", "m_sil_compiled", "\"sil_compiled\""] , 'ABC'.Label "__sil_boot" , 'ABC'.Create - , 'ABC'.Fill "_" 0 "main" 0 + , 'ABC'.Fill "_" 0 (toLabel "main") 0 , 'ABC'.Jmp "_driver" ] *> pushTypeResolver typeresolver *> @@ -187,7 +187,7 @@ instance gen Function where gen f = tell [ 'ABC'.Annotation $ 'ABC'.OAnnot args [] - , 'ABC'.Label f.f_name + , 'ABC'.Label $ toLabel f.f_name ] *> foldM reserveVar locals [a.arg_name \\ a <- reverse f.f_args] *> newReturn cleanup` *> @@ -315,7 +315,7 @@ where comment "Retrieve arguments" *> mapM gen args *> comment "Apply function" *> tell [ 'ABC'.Annotation $ 'ABC'.DAnnot fs.fs_arity [] - , 'ABC'.Jsr n + , 'ABC'.Jsr $ toLabel n , 'ABC'.Annotation $ 'ABC'.OAnnot (typeSize fs.fs_rettype) [] ] *> shrinkStack (fs.fs_arity - typeSize fs.fs_rettype) @@ -381,3 +381,6 @@ where comment :: String -> Gen () comment s = tell ['ABC'.Comment s] + +toLabel :: a -> 'ABC'.Label | toString a +toLabel n = "__sil_" <+ n -- cgit v1.2.3