--- a/hedgewars/GSHandlers.inc Fri May 11 23:22:01 2012 +0400
+++ b/hedgewars/GSHandlers.inc Fri May 11 23:34:35 2012 +0400
@@ -3030,7 +3030,7 @@
procedure doStepCakeWork(Gear: PGear);
-const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0));
+const dirs: array[0..3] of TPoint = ((X: 0; Y: -1), (X: 1; Y: 0),(X: 0; Y: 1),(X: -1; Y: 0));
var
xx, yy, xxn, yyn: LongInt;
dA: LongInt;
--- a/hedgewars/pas2c.h Fri May 11 23:22:01 2012 +0400
+++ b/hedgewars/pas2c.h Fri May 11 23:34:35 2012 +0400
@@ -87,6 +87,9 @@
#define STRINIT(a) {.len = sizeof(a) - 1, .str = a}
+
+int length_ar(void * a);
+
typedef int file;
typedef int TextFile;
extern int FileMode;
@@ -131,3 +134,5 @@
#define val(a, b) _val(a, (LongInt*)&(b))
void _val(string255 str, LongInt * a);
+
+extern double pi;
--- a/hedgewars/pas2cSystem.pas Fri May 11 23:22:01 2012 +0400
+++ b/hedgewars/pas2cSystem.pas Fri May 11 23:34:35 2012 +0400
@@ -82,7 +82,8 @@
ParamCount : function : integer;
ParamStr : function : string;
- sqrt, arctan2, pi, cos, sin, power : function : float;
+ sqrt, arctan2, cos, sin, power : function : float;
+ pi : float;
TypeInfo, GetEnumName : function : shortstring;
--- a/tools/PascalBasics.hs Fri May 11 23:22:01 2012 +0400
+++ b/tools/PascalBasics.hs Fri May 11 23:34:35 2012 +0400
@@ -8,7 +8,7 @@
import Text.Parsec.Language
import Data.Char
-builtin = ["succ", "pred", "low", "high", "ord", "inc", "dec", "exit", "break", "continue"]
+builtin = ["succ", "pred", "low", "high", "ord", "inc", "dec", "exit", "break", "continue", "length"]
pascalLanguageDef
= emptyDef
--- a/tools/pas2c.hs Fri May 11 23:22:01 2012 +0400
+++ b/tools/pas2c.hs Fri May 11 23:34:35 2012 +0400
@@ -747,6 +747,13 @@
expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "ord" _))) = liftM parens $ expr2C e
expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "succ" _))) = liftM (<> text " + 1") $ expr2C e
expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "pred" _))) = liftM (<> text " - 1") $ expr2C e
+expr2C (BuiltInFunCall [e] (SimpleReference (Identifier "length" _))) = do
+ e' <- expr2C e
+ lt <- gets lastType
+ case lt of
+ BTString -> return $ text "length" <> parens e'
+ BTArray {} -> return $ text "length_ar" <> parens e'
+ _ -> error $ "length() called on " ++ show lt
expr2C (BuiltInFunCall params ref) = do
r <- ref2C ref
t <- gets lastType