Changed most of the rest of Tock (except some tests) to understand the new record attributes
This commit is contained in:
parent
86f0218899
commit
1044a94730
|
@ -1322,12 +1322,12 @@ cintroduceSpec (A.Specification _ n (A.Rep m rep))
|
|||
--cintroduceSpec (A.Specification _ n (A.RetypesExpr _ am t e))
|
||||
cintroduceSpec n = call genMissing $ "introduceSpec " ++ show n
|
||||
|
||||
cgenRecordTypeSpec :: A.Name -> Bool -> [(A.Name, A.Type)] -> CGen ()
|
||||
cgenRecordTypeSpec n b fs
|
||||
cgenRecordTypeSpec :: A.Name -> A.RecordAttr -> [(A.Name, A.Type)] -> CGen ()
|
||||
cgenRecordTypeSpec n attr fs
|
||||
= do tell ["typedef struct{"]
|
||||
sequence_ [call genDeclaration t n True | (n, t) <- fs]
|
||||
tell ["}"]
|
||||
when b $ tell [" occam_struct_packed "]
|
||||
when (A.packedRecord attr) $ tell [" occam_struct_packed "]
|
||||
genName n
|
||||
tell [";"]
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ data GenOps = GenOps {
|
|||
genPoison :: Meta -> A.Variable -> CGen (),
|
||||
genProcCall :: A.Name -> [A.Actual] -> CGen (),
|
||||
genProcess :: A.Process -> CGen (),
|
||||
genRecordTypeSpec :: A.Name -> Bool -> [(A.Name, A.Type)] -> CGen (),
|
||||
genRecordTypeSpec :: A.Name -> A.RecordAttr -> [(A.Name, A.Type)] -> CGen (),
|
||||
genReplicatorStart :: A.Name -> A.Replicator -> CGen (),
|
||||
genReplicatorEnd :: A.Replicator -> CGen (),
|
||||
-- | Generates the three bits of a for loop (e.g. @int i = 0; i < 10; i++@ for the given replicator)
|
||||
|
|
|
@ -473,6 +473,10 @@ maybeVal am = tell [if (am == A.ValAbbrev) then "VAL " else ""]
|
|||
maybeValRain :: A.AbbrevMode -> CodeWriter ()
|
||||
maybeValRain am = tell [if (am == A.ValAbbrev) then "const " else ""]
|
||||
|
||||
instance ShowOccam A.RecordAttr where
|
||||
showOccamM attr
|
||||
= do when (A.packedRecord attr) $ tell ["PACKED "]
|
||||
when (A.mobileRecord attr) $ tell ["MOBILE "]
|
||||
|
||||
instance ShowOccam A.Specification where
|
||||
-- TODO add specmode to the output
|
||||
|
@ -497,10 +501,10 @@ instance ShowOccam A.Specification where
|
|||
= showOccamLine $ showOccamM t >> space >> showName n >> tell [" IS ["] >> showWithCommas vs >> tell ["]:"]
|
||||
showOccamM (A.Specification _ n (A.DataType _ t))
|
||||
= showOccamLine $ tell ["DATA TYPE "] >> showName n >> tell [" IS "] >> showOccamM t >> colon
|
||||
showOccamM (A.Specification _ n (A.RecordType _ packed fields))
|
||||
showOccamM (A.Specification _ n (A.RecordType _ attr fields))
|
||||
= do (showOccamLine $ tell ["DATA TYPE "] >> showName n)
|
||||
occamIndent
|
||||
(showOccamLine $ tell [if packed then "PACKED RECORD" else "RECORD"])
|
||||
(showOccamLine $ showOccamM attr >> tell ["RECORD"])
|
||||
occamIndent
|
||||
(sequence_ (map (\(n,t) -> showOccamLine $ showOccamM t >> space >> showName n >> colon) fields))
|
||||
occamOutdent
|
||||
|
|
|
@ -359,7 +359,7 @@ defineRecordType :: String -> [(String, A.Type)] -> State CompState ()
|
|||
defineRecordType s fs
|
||||
= defineThing s st A.Original A.NameUser
|
||||
where
|
||||
st = A.RecordType emptyMeta False [(simpleName s, t) | (s, t) <- fs]
|
||||
st = A.RecordType emptyMeta (A.RecordAttr False False) [(simpleName s, t) | (s, t) <- fs]
|
||||
|
||||
-- | Define a function.
|
||||
defineFunction :: String -> [A.Type] -> [(String, A.Type)]
|
||||
|
|
|
@ -644,7 +644,7 @@ bytesInType (A.Record n)
|
|||
case st of
|
||||
-- We can only do this for *packed* records -- for normal records,
|
||||
-- the compiler might insert padding.
|
||||
(A.RecordType _ True nts) -> bytesInList nts
|
||||
(A.RecordType _ (A.RecordAttr {A.packedRecord=True}) nts) -> bytesInList nts
|
||||
_ -> return $ BIUnknown
|
||||
where
|
||||
bytesInList :: (CSMR m, Die m) => [(A.Name, A.Type)] -> m BytesInResult
|
||||
|
|
Loading…
Reference in New Issue
Block a user