Fix function definition

This commit is contained in:
Francesco Gazzetta
2022-07-03 17:18:37 +02:00
parent 1405020497
commit 630a29e8c6
3 changed files with 14 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
export
function :t $f
(env %env, w %a, d %b, ...)
{@l
ret }
function :t $f (env %env, w %a, d %b, ...) {
@l
ret
}

View File

@@ -2,8 +2,8 @@
data $str =
{b "hello world", b 0}
export
function w $main
()
{@start
%r =w call $puts (l $str)
ret 0}
function w $main () {
@start
%r =w call $puts (l $str)
ret 0
}

View File

@@ -15,7 +15,7 @@ import Data.List.NonEmpty (NonEmpty, toList)
import Data.Maybe (maybeToList)
import Prettyprinter
( Pretty(pretty), Doc, (<+>), vsep, hsep, hang, punctuate, group, flatAlt
, space, encloseSep, tupled, comma, equals, braces )
, space, encloseSep, tupled, comma, equals, braces, lbrace, rbrace )
-- Instances
import Data.Hashable (Hashable)
import Control.DeepSeq (NFData)
@@ -194,12 +194,13 @@ data FuncDef = FuncDef [Linkage] (Maybe AbiTy) (Ident 'Global) (Maybe (Ident 'Te
instance Pretty FuncDef where
pretty (FuncDef linkage abiTy ident env params variadic blocks) = vsep
[ vsep $ pretty <$> linkage
, "function" <+> pretty abiTy <+> pretty ident
, tupled $
, "function" <+> pretty abiTy <+> pretty ident <+> tupled (
maybeToList (("env" <+>) . pretty <$> env)
++ fmap pretty params
++ maybeToList (prettyVariadic variadic)
, braces $ vsep $ toList $ pretty <$> blocks
) <+> lbrace
, vsep $ toList $ pretty <$> blocks
, rbrace
]
data AbiTy = AbiBaseTy BaseTy | AbiAggregateTy (Ident 'AggregateTy)