# HG changeset patch # User unc0rr # Date 1538766241 -7200 # Node ID bc90a932a4b332d0e9d5d8f7181d013ccc423c0a # Parent d987e65761ac718b2d876db7f5d777ea30077137 Fix pas2c not having support for High(LongInt) in init expressions diff -r d987e65761ac -r bc90a932a4b3 tools/pas2c/Pas2C.hs --- a/tools/pas2c/Pas2C.hs Fri Oct 05 20:28:13 2018 +0200 +++ b/tools/pas2c/Pas2C.hs Fri Oct 05 21:04:01 2018 +0200 @@ -698,12 +698,15 @@ (Identifier "LongInt" _) -> int (-2^31) (Identifier "SmallInt" _) -> int (-2^15) _ -> error $ "BuiltInFunction 'low': " ++ show e -initExpr2C' (BuiltInFunction "high" [e]) = do +initExpr2C' hi@(BuiltInFunction "high" [e@(InitReference e')]) = do void $ initExpr2C e t <- gets lastType case t of (BTArray i _ _) -> initExpr2C' $ BuiltInFunction "pred" [InitRange i] - a -> error $ "BuiltInFunction 'high': " ++ show a + BTInt _ -> case e' of + (Identifier "LongInt" _) -> return $ int (2147483647) + _ -> error $ "BuiltInFunction 'high' in initExpr: " ++ show e' + 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 (<> text " + 1") $ initExpr2C' e