Pas2C: Implement rendering of High() similiar to that of Low()
authorWuzzy <Wuzzy2@mail.ru>
Fri, 05 Oct 2018 20:56:40 +0200
changeset 13856 aed7ee68305a
parent 13855 d987e65761ac
child 13858 84b2191efde9
Pas2C: Implement rendering of High() similiar to that of Low()
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 20:56:40 2018 +0200
@@ -698,12 +698,11 @@
          (Identifier "LongInt" _) -> int (-2^31)
          (Identifier "SmallInt" _) -> int (-2^15)
          _ -> error $ "BuiltInFunction 'low': " ++ show e
-initExpr2C' (BuiltInFunction "high" [e]) = do
-    void $ initExpr2C e
-    t <- gets lastType
-    case t of
-         (BTArray i _ _) -> initExpr2C' $ BuiltInFunction "pred" [InitRange i]
-         a -> error $ "BuiltInFunction 'high': " ++ show a
+initExpr2C' (BuiltInFunction "high" [InitReference e]) = return $
+    case e of
+         (Identifier "LongInt" _) -> int (2^31 - 1)
+         (Identifier "SmallInt" _) -> int (2^15 - 1)
+         _ -> error $ "BuiltInFunction 'high': " ++ show e
 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