Fixed a problem with record abbreviations being pulled all the way up to the top (which C doesn't like)

This commit is contained in:
Neil Brown 2009-03-31 16:50:42 +00:00
parent 33ca2fe253
commit 2941cbd049
2 changed files with 8 additions and 2 deletions

View File

@ -792,7 +792,7 @@ cgetCType m origT am
(A.Record n, _, False, A.Original) -> return $ Plain $ nameString n
-- Abbrev and ValAbbrev, and mobile:
(A.Record n, _, False, _) -> return $ Pointer $ const $ Plain $ nameString n
(A.Record n, _, False, _) -> return $ Const . Pointer $ const $ Plain $ nameString n
(A.Record n, _, True, A.Abbrev) -> return $ Pointer $ Pointer $ Plain $ nameString n
(A.Record n, _, True, _) -> return $ Pointer $ const $ Plain $ nameString n

View File

@ -218,7 +218,7 @@ removeNesting = pass "Pull nested definitions to top level"
doStructured s@(A.Spec m spec subS)
= do spec'@(A.Specification _ n st) <- recurse spec
isConst <- isConstantName n
if isConst || canPull st then
if (isConst && not (abbrevRecord st)) || canPull st then
do debug $ "removeNesting: pulling up " ++ show n
addPulled $ (m, Left spec')
doStructured subS
@ -232,3 +232,9 @@ removeNesting = pass "Pull nested definitions to top level"
canPull (A.ProtocolCase _ _) = True
canPull _ = False
-- C doesn't allow us to pull up pointers to records to the top-level
abbrevRecord :: A.SpecType -> Bool
abbrevRecord (A.Is _ _ (A.Record {}) _) = True
abbrevRecord _ = False