tools/pas2c/Pas2C.hs
changeset 13863 84b2191efde9
parent 13861 aed7ee68305a
child 13865 aba78789f0bf
equal deleted inserted replaced
13861:aed7ee68305a 13863:84b2191efde9
   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" [InitReference e]) = return $
   701 initExpr2C' (BuiltInFunction "high" [e]) = do
   702     case e of
   702     void $ initExpr2C e
   703          (Identifier "LongInt" _) -> int (2^31 - 1)
   703     t <- gets lastType
   704          (Identifier "SmallInt" _) -> int (2^15 - 1)
   704     case t of
   705          _ -> error $ "BuiltInFunction 'high': " ++ show e
   705          (BTArray i _ _) -> initExpr2C' $ BuiltInFunction "pred" [InitRange i]
       
   706          a -> error $ "BuiltInFunction 'high': " ++ show a
   706 initExpr2C' (BuiltInFunction "succ" [BuiltInFunction "pred" [e]]) = initExpr2C' e
   707 initExpr2C' (BuiltInFunction "succ" [BuiltInFunction "pred" [e]]) = initExpr2C' e
   707 initExpr2C' (BuiltInFunction "pred" [BuiltInFunction "succ" [e]]) = initExpr2C' e
   708 initExpr2C' (BuiltInFunction "pred" [BuiltInFunction "succ" [e]]) = initExpr2C' e
   708 initExpr2C' (BuiltInFunction "succ" [e]) = liftM (<> text " + 1") $ initExpr2C' e
   709 initExpr2C' (BuiltInFunction "succ" [e]) = liftM (<> text " + 1") $ initExpr2C' e
   709 initExpr2C' (BuiltInFunction "pred" [e]) = liftM (<> text " - 1") $ initExpr2C' e
   710 initExpr2C' (BuiltInFunction "pred" [e]) = liftM (<> text " - 1") $ initExpr2C' e
   710 initExpr2C' b@(BuiltInFunction _ _) = error $ show b
   711 initExpr2C' b@(BuiltInFunction _ _) = error $ show b