tools/pas2c/Pas2C.hs
changeset 13860 aba78789f0bf
parent 13858 84b2191efde9
parent 13859 885ee14fe640
child 13862 0ecf77e203c0
equal deleted inserted replaced
13858:84b2191efde9 13860:aba78789f0bf
   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                   (Identifier "LongWord" _) -> return $ text "4294967295"
       
   709                   _ -> error $ "BuiltInFunction 'high' in initExpr: " ++ show e'
       
   710          a -> error $ "BuiltInFunction 'high' in initExpr: " ++ show a ++ ": " ++ show hi
   707 initExpr2C' (BuiltInFunction "succ" [BuiltInFunction "pred" [e]]) = initExpr2C' e
   711 initExpr2C' (BuiltInFunction "succ" [BuiltInFunction "pred" [e]]) = initExpr2C' e
   708 initExpr2C' (BuiltInFunction "pred" [BuiltInFunction "succ" [e]]) = initExpr2C' e
   712 initExpr2C' (BuiltInFunction "pred" [BuiltInFunction "succ" [e]]) = initExpr2C' e
   709 initExpr2C' (BuiltInFunction "succ" [e]) = liftM (<> text " + 1") $ initExpr2C' e
   713 initExpr2C' (BuiltInFunction "succ" [e]) = liftM (<> text " + 1") $ initExpr2C' e
   710 initExpr2C' (BuiltInFunction "pred" [e]) = liftM (<> text " - 1") $ initExpr2C' e
   714 initExpr2C' (BuiltInFunction "pred" [e]) = liftM (<> text " - 1") $ initExpr2C' e
   711 initExpr2C' b@(BuiltInFunction _ _) = error $ show b
   715 initExpr2C' b@(BuiltInFunction _ _) = error $ show b