diff options
author | Camil Staps | 2017-07-21 07:34:48 +0000 |
---|---|---|
committer | Camil Staps | 2017-07-21 07:34:48 +0000 |
commit | 3b6065d5a92d68f19560b83aa810b2533f85c885 (patch) | |
tree | f584efbc67608e3776bc4dadccdf13c1ac1ebc63 /Sil/Compile.icl | |
parent | Fix: main can have any result, but no arguments (diff) |
Prepend labels with __sil_ to prevent name clashes with C functions
Diffstat (limited to 'Sil/Compile.icl')
-rw-r--r-- | Sil/Compile.icl | 11 |
1 files changed, 7 insertions, 4 deletions
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 |