Some more definitions and slight fixes
authorunc0rr
Thu, 10 May 2012 13:16:31 +0400
changeset 7038 d853e4385241
parent 7037 7edce323558f
child 7039 e7dc6ddd1e29
Some more definitions and slight fixes
hedgewars/SysUtils.h
hedgewars/pas2c.h
hedgewars/pas2cSystem.pas
tools/PascalBasics.hs
tools/PascalPreprocessor.hs
tools/pas2c.hs
--- 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);
--- 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;
--- 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
--- 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
--- 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