Render function variables in struct with no mangling. 13 C units are compilable now.
authorunc0rr
Thu, 10 May 2012 13:45:47 +0400
changeset 7040 4aff2da0d0b3
parent 7039 e7dc6ddd1e29
child 7041 76a9274f280f
Render function variables in struct with no mangling. 13 C units are compilable now.
tools/pas2c.hs
--- a/tools/pas2c.hs	Thu May 10 13:41:18 2012 +0400
+++ b/tools/pas2c.hs	Thu May 10 13:45:47 2012 +0400
@@ -524,17 +524,18 @@
              _ -> return $ \a -> i' <+> text "*" <+> a
     type2C' (PointerTo t) = liftM (\t a -> t (parens $ text "*" <> a)) $ type2C t
     type2C' (RecordType tvs union) = do
-        t <- withState' id $ mapM (tvar2C False) tvs
+        t <- withState' f $ mapM (tvar2C False) tvs
         u <- unions
         return $ \i -> text "struct __" <> i <+> lbrace $+$ nest 4 ((vcat . map (<> semi) . concat $ t) $$ u) $+$ rbrace <+> i
         where
+            f s = s{currentUnit = ""}
             unions = case union of
                      Nothing -> return empty
                      Just a -> do
                          structs <- mapM struct2C a
                          return $ text "union" $+$ braces (nest 4 $ vcat structs) <> semi
             struct2C tvs = do
-                t <- withState' id $ mapM (tvar2C False) tvs
+                t <- withState' f $ mapM (tvar2C False) tvs
                 return $ text "struct" $+$ braces (nest 4 (vcat . map (<> semi) . concat $ t)) <> semi
     type2C' (RangeType r) = return (text "int" <+>)
     type2C' (Sequence ids) = do