tools/pas2c/Pas2C.hs
changeset 13856 aed7ee68305a
parent 13819 db1b680bd8d3
child 13858 84b2191efde9
equal deleted inserted replaced
13855:d987e65761ac 13856:aed7ee68305a
   696 initExpr2C' (BuiltInFunction "low" [InitReference e]) = return $
   696 initExpr2C' (BuiltInFunction "low" [InitReference e]) = return $
   697     case e of
   697     case e of
   698          (Identifier "LongInt" _) -> int (-2^31)
   698          (Identifier "LongInt" _) -> int (-2^31)
   699          (Identifier "SmallInt" _) -> int (-2^15)
   699          (Identifier "SmallInt" _) -> int (-2^15)
   700          _ -> error $ "BuiltInFunction 'low': " ++ show e
   700          _ -> error $ "BuiltInFunction 'low': " ++ show e
   701 initExpr2C' (BuiltInFunction "high" [e]) = do
   701 initExpr2C' (BuiltInFunction "high" [InitReference e]) = return $
   702     void $ initExpr2C e
   702     case e of
   703     t <- gets lastType
   703          (Identifier "LongInt" _) -> int (2^31 - 1)
   704     case t of
   704          (Identifier "SmallInt" _) -> int (2^15 - 1)
   705          (BTArray i _ _) -> initExpr2C' $ BuiltInFunction "pred" [InitRange i]
   705          _ -> error $ "BuiltInFunction 'high': " ++ show e
   706          a -> error $ "BuiltInFunction 'high': " ++ show a
       
   707 initExpr2C' (BuiltInFunction "succ" [BuiltInFunction "pred" [e]]) = initExpr2C' e
   706 initExpr2C' (BuiltInFunction "succ" [BuiltInFunction "pred" [e]]) = initExpr2C' e
   708 initExpr2C' (BuiltInFunction "pred" [BuiltInFunction "succ" [e]]) = initExpr2C' e
   707 initExpr2C' (BuiltInFunction "pred" [BuiltInFunction "succ" [e]]) = initExpr2C' e
   709 initExpr2C' (BuiltInFunction "succ" [e]) = liftM (<> text " + 1") $ initExpr2C' e
   708 initExpr2C' (BuiltInFunction "succ" [e]) = liftM (<> text " + 1") $ initExpr2C' e
   710 initExpr2C' (BuiltInFunction "pred" [e]) = liftM (<> text " - 1") $ initExpr2C' e
   709 initExpr2C' (BuiltInFunction "pred" [e]) = liftM (<> text " - 1") $ initExpr2C' e
   711 initExpr2C' b@(BuiltInFunction _ _) = error $ show b
   710 initExpr2C' b@(BuiltInFunction _ _) = error $ show b