Changed records to always use their original name in the C code
This fixes the problem with PROCs complaining that one munged version of the record name was not the same as another. This will cause problems if two different record definitions for the same name are visible in the same file.
This commit is contained in:
parent
7a7eefa33e
commit
47d565a3b9
|
@ -1431,6 +1431,10 @@ cgenRecordTypeSpec n attr fs
|
|||
when (A.packedRecord attr || A.mobileRecord attr) $ tell [" occam_struct_packed "]
|
||||
genName n
|
||||
tell [";"]
|
||||
tell ["typedef "]
|
||||
genName n
|
||||
origN <- lookupName n >>* A.ndOrigName
|
||||
tell [" ", nameString $ A.Name emptyMeta origN, ";"]
|
||||
if null [t | (_, A.Mobile t) <- fs]
|
||||
then do genStatic TopLevel n
|
||||
tell ["const word "]
|
||||
|
@ -1593,10 +1597,18 @@ genProcSpec lvl n (A.Proc _ (sm, rm) fs (Just p)) forwardDecl
|
|||
genName n
|
||||
tell [" (Workspace wptr"]
|
||||
sequence_ [do tell [", "]
|
||||
t
|
||||
case origT of
|
||||
A.Record rn | forwardDecl
|
||||
-> do origN <- lookupName rn >>* A.ndOrigName
|
||||
ct <- call getCType (A.nameMeta rn)
|
||||
(A.Record rn) am
|
||||
tell [show $ replacePlainType (nameString rn)
|
||||
(nameString $ A.Name emptyMeta origN) ct
|
||||
]
|
||||
_ -> t
|
||||
tell [" "]
|
||||
n
|
||||
| (t, n) <- rfs]
|
||||
| (A.Formal am origT _, (t, n)) <- zip fs rfs]
|
||||
tell [")"]
|
||||
-- For externals, do nothing here:
|
||||
genProcSpec _ _ (A.Proc _ _ _ Nothing) _ = return ()
|
||||
|
|
|
@ -270,6 +270,15 @@ instance Show CType where
|
|||
show (Template wr cts) = wr ++ "<" ++ concat (intersperse "," $ map (either show show) cts) ++ ">/**/"
|
||||
-- show (Subscript t) = "(" ++ show t ++ "[n])"
|
||||
|
||||
replacePlainType :: String -> String -> CType -> CType
|
||||
replacePlainType old new (Const ct) = Const $ replacePlainType old new ct
|
||||
replacePlainType old new (Pointer ct) = Pointer $ replacePlainType old new ct
|
||||
replacePlainType old new (Template t xs)
|
||||
= Template t $ [transformEither (replacePlainType old new) id x | x <- xs]
|
||||
replacePlainType old new (Plain t)
|
||||
| old == t = Plain new
|
||||
| otherwise = Plain t
|
||||
|
||||
stripPointers :: CType -> CType
|
||||
stripPointers (Pointer t) = t
|
||||
stripPointers (Const (Pointer t)) = t
|
||||
|
|
Loading…
Reference in New Issue
Block a user