aboutsummaryrefslogtreecommitdiff
path: root/Sil/Compile.icl
diff options
context:
space:
mode:
Diffstat (limited to 'Sil/Compile.icl')
-rw-r--r--Sil/Compile.icl22
1 files changed, 18 insertions, 4 deletions
diff --git a/Sil/Compile.icl b/Sil/Compile.icl
index 254cc67..d59573d 100644
--- a/Sil/Compile.icl
+++ b/Sil/Compile.icl
@@ -277,8 +277,9 @@ where
typeresolver n = listToMaybe [Ok a.arg_type \\ a <- f.f_args | a.arg_name == n]
mainBootstrap :: Gen ()
- mainBootstrap = case (f.f_name, (typeSize f.f_type).bsize) of
- ("main", 1) ->
+ mainBootstrap
+ | f.f_name == "main"
+ | (typeSize f.f_type).bsize == 1 =
fresh "main" >>= \lab ->
tell [ 'ABC'.Annotation $ 'ABC'.DAnnot 0 []
, 'ABC'.Jsr lab
@@ -295,8 +296,21 @@ where
type = case f.f_type of
TBool -> 'ABC'.BT_Bool
TInt -> 'ABC'.BT_Int
- _ ->
- nop
+ | f.f_type == TVoid =
+ fresh "main" >>= \lab ->
+ tell [ 'ABC'.Annotation $ 'ABC'.DAnnot 0 []
+ , 'ABC'.Jsr lab
+ , 'ABC'.Annotation $ 'ABC'.OAnnot 0 []
+ , 'ABC'.Create
+ , 'ABC'.Raw "\tfillh e__predef_d_Unit 0 0"
+ , 'ABC'.Annotation $ 'ABC'.DAnnot 1 []
+ , 'ABC'.Rtn
+ ] *>
+ comment "Reset sos" *>
+ modify (\cs -> {cs & stackoffsets=(0, 0)}) *>
+ tell [ 'ABC'.Label lab ]
+ | otherwise = nop
+ | otherwise = nop
instance gen CodeBlock
where