aboutsummaryrefslogtreecommitdiff
path: root/Sil/Compile.icl
diff options
context:
space:
mode:
Diffstat (limited to 'Sil/Compile.icl')
-rw-r--r--Sil/Compile.icl24
1 files changed, 8 insertions, 16 deletions
diff --git a/Sil/Compile.icl b/Sil/Compile.icl
index ced497e..6569dd1 100644
--- a/Sil/Compile.icl
+++ b/Sil/Compile.icl
@@ -264,9 +264,6 @@ where
class gen a :: a -> Gen ()
-instance gen (Positioned a) | gen a
-where gen p = gen $ fromPositioned p
-
instance gen Program
where
gen p =
@@ -280,27 +277,24 @@ where
, 'ABC'.Jmp "_driver"
, 'ABC'.Annotation $ 'ABC'.OAnnot 0 []
, 'ABC'.Label "_sil_boot2" ] *>
- let gsize = foldr (+~) zero [typeSize i.init_type \\ i <- globs] in
+ let gsize = foldr (+~) zero [typeSize i.init_type \\ i <- p.p_globals] in
modify (\cs -> {cs & globalsize=(gsize.asize, gsize.bsize)}) *>
shrinkStack gsize *>
- mapM_ reserveVar [(i.init_name, i.init_type) \\ i <- globs] *>
+ mapM_ reserveVar [(i.init_name, i.init_type) \\ i <- p.p_globals] *>
mapM_ gen p.p_globals *>
tell [ 'ABC'.Jmp (toLabel "main") ] *>
pushTypeResolver typeresolver *>
- mapM_ (addFunction o fromPositioned) p.p_funs *>
+ mapM_ addFunction p.p_funs *>
mapM_ gen p.p_funs *>
popTypeResolver
where
typeresolver :: Name -> Maybe (MaybeError Error Type)
- typeresolver n = case [f \\ f <- funs | f.f_name == n] of
+ typeresolver n = case [f \\ f <- p.p_funs | f.f_name == n] of
[f:_] -> type typeresolver f
- [] -> case [g.init_type \\ g <- globs | g.init_name == n] of
+ [] -> case [g.init_type \\ g <- p.p_globals | g.init_name == n] of
[t:_] -> Just $ Ok t
[] -> Nothing
- globs = map fromPositioned p.p_globals
- funs = map fromPositioned p.p_funs
-
instance gen Function
where
gen f =
@@ -375,7 +369,7 @@ where
gen cb =
storeStackOffsets *>
gets stackoffsets >>= \so ->
- mapM_ reserveVar [(i.init_name, i.init_type) \\ i <- init] *>
+ mapM_ reserveVar [(i.init_name, i.init_type) \\ i <- cb.cb_init] *>
mapM_ gen cb.cb_init *>
addToReturn cleanup` *>
pushTypeResolver typeresolver *>
@@ -390,12 +384,10 @@ where
_ -> [ 'ABC'.Pop_a locals.asize
, 'ABC'.Pop_b locals.bsize
]
- locals = foldr (+~) zero [typeSize i.init_type \\ i <- init]
+ locals = foldr (+~) zero [typeSize i.init_type \\ i <- cb.cb_init]
typeresolver :: Name -> Maybe (MaybeError Error Type)
- typeresolver n = listToMaybe [Ok i.init_type \\ i <- init | i.init_name == n]
-
- init = map fromPositioned cb.cb_init
+ typeresolver n = listToMaybe [Ok i.init_type \\ i <- cb.cb_init | i.init_name == n]
instance gen Initialisation
where