Some more work on scopes
authorunc0rr
Thu, 08 Dec 2011 14:44:10 +0400
changeset 6520 6fecdc5d182f
parent 6519 b0dc69bb1f54
child 6521 16d9ac07f504
Some more work on scopes
hedgewars/pas2cSystem.pas
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/FrontendDataUtils.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/GameMode.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Grave.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Map.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Scheme.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Team.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Weapon.java
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/UserInput/TouchInterface.java
share/hedgewars/Data/Scripts/plist/Racer.plist
tools/PascalBasics.hs
tools/pas2c.hs
--- a/hedgewars/pas2cSystem.pas	Wed Dec 07 19:38:33 2011 -0500
+++ b/hedgewars/pas2cSystem.pas	Thu Dec 08 14:44:10 2011 +0400
@@ -5,6 +5,11 @@
     LongWord = integer;
     Cardinal = integer;
     PtrInt = integer;
+    Word = integer;
+    Integer = integer;
+    Byte = integer;
+    SmallInt = integer;
+    ShortInt = integer;
 
     pointer = pointer;
     PChar = pointer;
@@ -21,7 +26,16 @@
     ansistring = string;
 
     char = char;
+    
+    PByte = ^Byte;
+    PLongInt = ^LongInt;
+    PLongWord = ^LongWord;
+    PInteger = ^Integer;
 var 
     false, true: boolean;
-    write, writeln, read, readln: procedure;
-    strlen : function : integer;
+    write, writeLn, read, readLn, inc, dec: procedure;
+    StrLen, ord, Succ, Pred : function : integer;
+    Low, High : function : integer;
+    Now : function : integer;
+    SysUtils.StrPas, FormatDateTime : function : shortstring;
+    exit : procedure;
--- a/tools/PascalBasics.hs	Wed Dec 07 19:38:33 2011 -0500
+++ b/tools/PascalBasics.hs	Thu Dec 08 14:44:10 2011 +0400
@@ -26,7 +26,7 @@
             , "procedure", "function", "with", "for", "to"
             , "downto", "div", "mod", "record", "set", "nil"
             , "cdecl", "external", "if", "then", "else"
-            ] ++ builtin
+            ] -- ++ builtin
     , reservedOpNames= [] 
     , caseSensitive  = False   
     }
--- a/tools/pas2c.hs	Wed Dec 07 19:38:33 2011 -0500
+++ b/tools/pas2c.hs	Thu Dec 08 14:44:10 2011 +0400
@@ -72,10 +72,12 @@
     extractTVs (Unit _ (Interface _ (TypesAndVars tv)) _ _ _) = tv
     
     tv2id :: TypeVarDeclaration -> [(String, String)]
+    tv2id (TypeDeclaration i (Sequence ids)) = map (\(Identifier i _) -> fi i) $ i : ids
     tv2id (TypeDeclaration (Identifier i _) _) = [(map toLower i, i)]
-    tv2id (VarDeclaration _ (ids, _) _) = map (\(Identifier i _) -> (map toLower i, i)) ids
-    tv2id (FunctionDeclaration (Identifier i _) _ _ _) = [(map toLower i, i)]
-    tv2id (OperatorDeclaration i _ _ _ _) = [(map toLower i, i)]
+    tv2id (VarDeclaration _ (ids, _) _) = map (\(Identifier i _) -> fi i) ids
+    tv2id (FunctionDeclaration (Identifier i _) _ _ _) = [fi i]
+    tv2id (OperatorDeclaration i _ _ _ _) = [fi i]
+    fi i = (map toLower i, i)
     
     
 toCFiles :: Map.Map String [(String, String)] -> (String, PascalUnit) -> IO ()
@@ -214,12 +216,15 @@
 type2C UnknownType = return $ text "void"
 type2C (String l) = return $ text $ "string" ++ show l
 type2C (SimpleType i) = id2C False i
+type2C (PointerTo (SimpleType i)) = liftM (<> text "*") $ id2C True i
 type2C (PointerTo t) = liftM (<> text "*") $ type2C t
 type2C (RecordType tvs union) = do
     t <- mapM (tvar2C False) tvs
     return $ text "{" $+$ (nest 4 . vcat $ t) $+$ text "}"
 type2C (RangeType r) = return $ text "<<range type>>"
-type2C (Sequence ids) = return $ text "<<sequence type>>"
+type2C (Sequence ids) = do
+    mapM_ (id2C True) ids
+    return $ text "<<sequence type>>"
 type2C (ArrayDecl r t) = return $ text "<<array type>>"
 type2C (Set t) = return $ text "<<set>>"
 type2C (FunctionType returnType params) = return $ text "<<function>>"