equal
deleted
inserted
replaced
516 , currentFunctionResult = if isVoid then [] else render res}) $ do |
516 , currentFunctionResult = if isVoid then [] else render res}) $ do |
517 p <- functionParams2C params |
517 p <- functionParams2C params |
518 ph <- liftM2 ($+$) (typesAndVars2C False False True tvars) (phrase2C' phrase) |
518 ph <- liftM2 ($+$) (typesAndVars2C False False True tvars) (phrase2C' phrase) |
519 return (p, ph) |
519 return (p, ph) |
520 |
520 |
521 let phrasesBlock = if isVoid then ph else t empty <+> res <> semi $+$ ph $+$ text "return" <+> res <> semi |
521 let isTrivialReturn = case phrase of |
|
522 (Phrases (BuiltInFunctionCall _ (SimpleReference (Identifier "exit" BTUnknown)) : _)) -> True |
|
523 _ -> False |
|
524 let phrasesBlock = if isVoid || isTrivialReturn then ph else t empty <+> res <> semi $+$ ph $+$ text "return" <+> res <> semi |
522 --let define = if hasVars then text "#ifndef" <+> text n $+$ funWithVarsToDefine n params $+$ text "#endif" else empty |
525 --let define = if hasVars then text "#ifndef" <+> text n $+$ funWithVarsToDefine n params $+$ text "#endif" else empty |
523 let inlineDecor = if inline then case notDeclared of |
526 let inlineDecor = if inline then case notDeclared of |
524 True -> text "static inline" |
527 True -> text "static inline" |
525 False -> text "inline" |
528 False -> text "inline" |
526 else empty |
529 else empty |
917 $$ |
920 $$ |
918 text "if" <+> (parens $ i <+> text (if up then "<=" else ">=") <+> iEnd) <+> text "do" <+> ph <+> |
921 text "if" <+> (parens $ i <+> text (if up then "<=" else ">=") <+> iEnd) <+> text "do" <+> ph <+> |
919 text "while" <> parens (i <+> text "!=" <+> iEnd <+> text add) <> semi |
922 text "while" <> parens (i <+> text "!=" <+> iEnd <+> text add) <> semi |
920 where |
923 where |
921 appendPhrase p (Phrases ps) = Phrases $ ps ++ [p] |
924 appendPhrase p (Phrases ps) = Phrases $ ps ++ [p] |
|
925 appendPhrase _ _ = error "illegal appendPhrase call" |
922 phrase2C (RepeatCycle e' p') = do |
926 phrase2C (RepeatCycle e' p') = do |
923 e <- expr2C e' |
927 e <- expr2C e' |
924 p <- phrase2C (Phrases p') |
928 p <- phrase2C (Phrases p') |
925 return $ text "do" <+> p <+> text "while" <> parens (text "!" <> parens e) <> semi |
929 return $ text "do" <+> p <+> text "while" <> parens (text "!" <> parens e) <> semi |
926 |
930 |