tools/pas2c/Pas2C.hs
changeset 13857 bc90a932a4b3
parent 13819 db1b680bd8d3
child 13859 885ee14fe640
equal deleted inserted replaced
13855:d987e65761ac 13857:bc90a932a4b3
   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' hi@(BuiltInFunction "high" [e@(InitReference e')]) = do
   702     void $ initExpr2C e
   702     void $ initExpr2C e
   703     t <- gets lastType
   703     t <- gets lastType
   704     case t of
   704     case t of
   705          (BTArray i _ _) -> initExpr2C' $ BuiltInFunction "pred" [InitRange i]
   705          (BTArray i _ _) -> initExpr2C' $ BuiltInFunction "pred" [InitRange i]
   706          a -> error $ "BuiltInFunction 'high': " ++ show a
   706          BTInt _ -> case e' of
       
   707                   (Identifier "LongInt" _) -> return $ int (2147483647)
       
   708          _ -> error $ "BuiltInFunction 'high' in initExpr: " ++ show e'
       
   709          a -> error $ "BuiltInFunction 'high' in initExpr: " ++ show a ++ ": " ++ show hi
   707 initExpr2C' (BuiltInFunction "succ" [BuiltInFunction "pred" [e]]) = initExpr2C' e
   710 initExpr2C' (BuiltInFunction "succ" [BuiltInFunction "pred" [e]]) = initExpr2C' e
   708 initExpr2C' (BuiltInFunction "pred" [BuiltInFunction "succ" [e]]) = initExpr2C' e
   711 initExpr2C' (BuiltInFunction "pred" [BuiltInFunction "succ" [e]]) = initExpr2C' e
   709 initExpr2C' (BuiltInFunction "succ" [e]) = liftM (<> text " + 1") $ initExpr2C' e
   712 initExpr2C' (BuiltInFunction "succ" [e]) = liftM (<> text " + 1") $ initExpr2C' e
   710 initExpr2C' (BuiltInFunction "pred" [e]) = liftM (<> text " - 1") $ initExpr2C' e
   713 initExpr2C' (BuiltInFunction "pred" [e]) = liftM (<> text " - 1") $ initExpr2C' e
   711 initExpr2C' b@(BuiltInFunction _ _) = error $ show b
   714 initExpr2C' b@(BuiltInFunction _ _) = error $ show b