From: Debian Games Team Date: Thu, 22 Sep 2022 12:51:50 +0000 (+0100) Subject: c09063ea0267 X-Git-Tag: archive/raspbian/1.0.2-4+rpi1^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=18ed035ab5a2cbd49c82e9aa136c49a9d2a954b9;p=hedgewars.git c09063ea0267 # HG changeset patch # User alfadur # Date 1663732531 -10800 # Node ID c09063ea0267b1a016a3a682f6d8cb39c3f7300d # Parent 9cd8d7748199d732cf7e5b0b245f1159bc86f0ea fix the other 2 pred/succ conversions Gbp-Pq: Name c09063ea0267.patch --- diff --git a/tools/pas2c/Pas2C.hs b/tools/pas2c/Pas2C.hs index ddb8a21..7eae202 100644 --- a/tools/pas2c/Pas2C.hs +++ b/tools/pas2c/Pas2C.hs @@ -711,8 +711,10 @@ initExpr2C' hi@(BuiltInFunction "high" [e@(InitReference e')]) = do a -> error $ "BuiltInFunction 'high' in initExpr: " ++ show a ++ ": " ++ show hi initExpr2C' (BuiltInFunction "succ" [BuiltInFunction "pred" [e]]) = initExpr2C' e initExpr2C' (BuiltInFunction "pred" [BuiltInFunction "succ" [e]]) = initExpr2C' e -initExpr2C' (BuiltInFunction "succ" [e]) = liftM (\e' -> text "(" <> e' <> text " + 1)") $ initExpr2C' e -initExpr2C' (BuiltInFunction "pred" [e]) = liftM (\e' -> text "(" <> e' <> text " - 1)") $ initExpr2C' e +initExpr2C' (BuiltInFunction "succ" [e]) = + liftM (parens . (<> text " + 1")) $ initExpr2C' e +initExpr2C' (BuiltInFunction "pred" [e]) = + liftM (parens . (<> text " - 1")) $ initExpr2C' e initExpr2C' b@(BuiltInFunction _ _) = error $ show b initExpr2C' (InitTypeCast t' i) = do e <- initExpr2C i @@ -1089,10 +1091,10 @@ expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "high" _))) = do BTArray (RangeFromTo _ n) _ _ -> initExpr2C n _ -> error $ "BuiltInFunCall 'high' from " ++ show e ++ "\ntype: " ++ show lt expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "ord" _))) = liftM parens $ expr2C e -expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "succ" _))) = liftM (<> text " + 1") $ expr2C e -expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "pred" _))) = do - e'<- expr2C e - return $ text "(int)" <> parens e' <> text " - 1" +expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "succ" _))) = + liftM (parens . (<> text " + 1")) $ expr2C e +expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "pred" _))) = + liftM (parens . (<> text " - 1") . ((text "(int)") <>) . parens) $ expr2C e expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "length" _))) = do e' <- expr2C e lt <- gets lastType