# HG changeset patch # User unc0rr # Date 1323266123 -14400 # Node ID 8ba891d34ebab03e058cffcba3a171833d7366b0 # Parent 677b96d13e1f0abb9ea53673d012f08b5dc04ed5 - Fix type2C id2C call - Introduce renderCFiles function diff -r 677b96d13e1f -r 8ba891d34eba tools/pas2c.hs --- a/tools/pas2c.hs Wed Dec 07 12:19:36 2011 +0100 +++ b/tools/pas2c.hs Wed Dec 07 17:55:23 2011 +0400 @@ -23,7 +23,7 @@ pas2C fn = do setCurrentDirectory "../hedgewars/" s <- flip execStateT initState $ f fn - mapM_ toCFiles (Map.toList s) + renderCFiles s where printLn = liftIO . hPutStrLn stderr print = liftIO . hPutStr stderr @@ -53,6 +53,12 @@ modify (Map.insert fileName a) mapM_ f (usesFiles a) + +renderCFiles :: Map.Map String PascalUnit -> IO () +renderCFiles units = do + let u = Map.toList units + mapM_ toCFiles u + toCFiles :: (String, PascalUnit) -> IO () toCFiles (_, System _) = return () toCFiles p@(fn, pu) = do @@ -172,7 +178,7 @@ type2C :: TypeDecl -> State RenderState Doc type2C UnknownType = return $ text "void" type2C (String l) = return $ text $ "string" ++ show l -type2C (SimpleType i) = id2C True i +type2C (SimpleType i) = id2C False i type2C (PointerTo t) = liftM (<> text "*") $ type2C t type2C (RecordType tvs union) = do t <- mapM (tvar2C False) tvs