# HG changeset patch # User unc0rr # Date 1334428823 -14400 # Node ID 19d77932ea9174914352fa3c2302597c41f0faf3 # Parent 4463ee51c9ecfef802bfb870775569883f3b3583 Render some builtin functions diff -r 4463ee51c9ec -r 19d77932ea91 hedgewars/Math.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/Math.h Sat Apr 14 22:40:23 2012 +0400 @@ -0,0 +1,2 @@ +#pragma once + diff -r 4463ee51c9ec -r 19d77932ea91 tools/pas2c.hs --- a/tools/pas2c.hs Sat Apr 14 22:24:09 2012 +0400 +++ b/tools/pas2c.hs Sat Apr 14 22:40:23 2012 +0400 @@ -375,9 +375,15 @@ initExpr2C (InitRange a) = return $ text "<>" initExpr2C (InitSet []) = return $ text "0" initExpr2C (InitSet a) = return $ text "<>" -initExpr2C (BuiltInFunction {}) = return $ text "<>" +initExpr2C (BuiltInFunction "low" [InitReference e]) = return $ + case e of + (Identifier "LongInt" _) -> int (-2^31) + _ -> error $ show e +initExpr2C (BuiltInFunction "succ" [InitReference e]) = liftM (<> text " + 1") $ id2C IOLookup e +initExpr2C b@(BuiltInFunction _ _) = error $ show b initExpr2C a = error $ "initExpr2C: don't know how to render " ++ show a + range2C :: InitExpression -> State RenderState [Doc] range2C (InitString [a]) = return [quotes $ text [a]] range2C (InitRange (Range i)) = liftM (flip (:) []) $ id2C IOLookup i @@ -413,7 +419,7 @@ type2C' (RangeType r) = return (text "<>" <+>) type2C' (Sequence ids) = do is <- mapM (id2C IOInsert . setBaseType bt) ids - return (text "enum" <+> (braces . vcat . punctuate comma . map (\(a, b) -> a <+> equals <+> text "0x" <> text (showHex b "")) $ zip is (iterate (*2) 1)) <+>) + return (text "enum" <+> (braces . vcat . punctuate comma . map (\(a, b) -> a <+> equals <+> text "0x" <> text (showHex b "")) $ zip is [1..]) <+>) where bt = BTEnum $ map (\(Identifier i _) -> map toLower i) ids type2C' (ArrayDecl Nothing t) = do