# HG changeset patch # User unc0rr # Date 1336641391 -14400 # Node ID d853e4385241c01ea45bed76cb0aa3872ba5d123 # Parent 7edce323558f844f87553ef3cd5e6ae5835b7aec Some more definitions and slight fixes diff -r 7edce323558f -r d853e4385241 hedgewars/SysUtils.h diff -r 7edce323558f -r d853e4385241 hedgewars/pas2c.h --- a/hedgewars/pas2c.h Thu May 10 11:29:18 2012 +0400 +++ b/hedgewars/pas2c.h Thu May 10 13:16:31 2012 +0400 @@ -46,6 +46,7 @@ typedef char * PChar; typedef LongInt * PLongInt; typedef Integer * PInteger; +typedef int * PtrInt; #ifdef __GNUG__ #define NULL __null @@ -91,3 +92,16 @@ void close(int f); bool odd(int i); + + +typedef int TThreadId; +void ThreadSwitch(); +#define InterlockedIncrement(a) __InterlockedIncrement(&(a)) +#define InterlockedDecrement(a) __InterlockedDecrement(&(a)) +void __InterlockedIncrement(int * a); +void __InterlockedDecrement(int * a); + +bool Assigned(void * a); + +int random(int max); +int abs(int i); diff -r 7edce323558f -r d853e4385241 hedgewars/pas2cSystem.pas --- a/hedgewars/pas2cSystem.pas Thu May 10 11:29:18 2012 +0400 +++ b/hedgewars/pas2cSystem.pas Thu May 10 13:16:31 2012 +0400 @@ -63,7 +63,7 @@ new, dispose, FillChar, Move : procedure; trunc, round : function : integer; - Abs, Sqr : function : integer; + abs, Sqr : function : integer; StrPas, FormatDateTime, copy, delete, str, pos, trim, LowerCase : function : shortstring; Length, StrToInt : function : integer; diff -r 7edce323558f -r d853e4385241 tools/PascalBasics.hs --- a/tools/PascalBasics.hs Thu May 10 11:29:18 2012 +0400 +++ b/tools/PascalBasics.hs Thu May 10 13:16:31 2012 +0400 @@ -8,7 +8,7 @@ import Text.Parsec.Language import Data.Char -builtin = ["succ", "pred", "low", "high", "ord", "inc", "dec", "exit"] +builtin = ["succ", "pred", "low", "high", "ord", "inc", "dec", "exit", "break"] pascalLanguageDef = emptyDef diff -r 7edce323558f -r d853e4385241 tools/PascalPreprocessor.hs --- a/tools/PascalPreprocessor.hs Thu May 10 11:29:18 2012 +0400 +++ b/tools/PascalPreprocessor.hs Thu May 10 13:16:31 2012 +0400 @@ -15,7 +15,11 @@ , (try $ string "//") >> manyTill anyChar (try newline) >> return "\n" ] -initDefines = Map.fromList [("FPC", ""), ("PAS2C", "")] +initDefines = Map.fromList [ + ("FPC", "") + , ("PAS2C", "") + , ("USE_SDLTHREADS", "") + ] preprocess :: String -> IO String preprocess fn = do diff -r 7edce323558f -r d853e4385241 tools/pas2c.hs --- a/tools/pas2c.hs Thu May 10 11:29:18 2012 +0400 +++ b/tools/pas2c.hs Thu May 10 13:16:31 2012 +0400 @@ -638,6 +638,7 @@ phrase2C NOP = return $ text ";" phrase2C (BuiltInFunctionCall [] (SimpleReference (Identifier "exit" BTUnknown))) = return $ text "return" <> semi +phrase2C (BuiltInFunctionCall [] (SimpleReference (Identifier "break" BTUnknown))) = return $ text "break" <> semi phrase2C (BuiltInFunctionCall [e] (SimpleReference (Identifier "exit" BTUnknown))) = liftM (\e -> text "return" <+> e <> semi) $ expr2C e phrase2C (BuiltInFunctionCall [e] (SimpleReference (Identifier "dec" BTUnknown))) = liftM (\e -> text "--" <> e <> semi) $ expr2C e phrase2C (BuiltInFunctionCall [e1, e2] (SimpleReference (Identifier "dec" BTUnknown))) = liftM2 (\a b -> a <> text " -= " <> b <> semi) (expr2C e1) (expr2C e2) @@ -802,7 +803,7 @@ a -> do e <- expr2C expr t <- id2C IOLookup t' - return $ parens t <> e + return . parens $ parens t <> e ref2C (RefExpression expr) = expr2C expr