# HG changeset patch # User unc0rr # Date 1336763008 -14400 # Node ID 861d6897917f7ecb6e73760f53e00d1ac793f10c # Parent 800dcaf979bf4ba0556469303782a25b8668ccf8 Properly track type in ref2CF, this fixes issues with functions returning strings used in expression (like "a" + line()) diff -r 800dcaf979bf -r 861d6897917f hedgewars/pas2c.h --- a/hedgewars/pas2c.h Fri May 11 22:54:19 2012 +0400 +++ b/hedgewars/pas2c.h Fri May 11 23:03:28 2012 +0400 @@ -47,6 +47,7 @@ typedef Byte * PByte; typedef char * PChar; typedef LongInt * PLongInt; +typedef LongWord * PLongWord; typedef Integer * PInteger; typedef int * PtrInt; diff -r 800dcaf979bf -r 861d6897917f tools/pas2c.hs --- a/tools/pas2c.hs Fri May 11 22:54:19 2012 +0400 +++ b/tools/pas2c.hs Fri May 11 23:03:28 2012 +0400 @@ -664,7 +664,7 @@ expr2C :: Expression -> State RenderState Doc expr2C (Expression s) = return $ text s -expr2C (BinOp op expr1 expr2) = do +expr2C b@(BinOp op expr1 expr2) = do e1 <- expr2C expr1 t1 <- gets lastType e2 <- expr2C expr2 @@ -764,13 +764,17 @@ i <- id2C IOLookup name t <- gets lastType case t of - BTFunction {} -> return $ i <> parens empty + BTFunction _ rt -> do + modify(\s -> s{lastType = rt}) + return $ i <> parens empty _ -> return $ i ref2CF r@(RecordField (SimpleReference _) (SimpleReference _)) = do i <- ref2C r t <- gets lastType case t of - BTFunction {} -> return $ i <> parens empty + BTFunction _ rt -> do + modify(\s -> s{lastType = rt}) + return $ i <> parens empty _ -> return $ i ref2CF r = ref2C r