Moved the definition of record types into the forward declarations
This commit is contained in:
parent
cfc3577c21
commit
9ab4563a2c
|
@ -109,6 +109,7 @@ cgenOps = GenOps {
|
||||||
genPar = cgenPar,
|
genPar = cgenPar,
|
||||||
genProcCall = cgenProcCall,
|
genProcCall = cgenProcCall,
|
||||||
genProcess = cgenProcess,
|
genProcess = cgenProcess,
|
||||||
|
genRecordTypeSpec = cgenRecordTypeSpec,
|
||||||
genReplicator = cgenReplicator,
|
genReplicator = cgenReplicator,
|
||||||
genReplicatorLoop = cgenReplicatorLoop,
|
genReplicatorLoop = cgenReplicatorLoop,
|
||||||
genRetypeSizes = cgenRetypeSizes,
|
genRetypeSizes = cgenRetypeSizes,
|
||||||
|
@ -1288,13 +1289,7 @@ cintroduceSpec (A.Specification _ n (A.IsChannelArray _ (A.Array _ c) cs))
|
||||||
tell ["};"]
|
tell ["};"]
|
||||||
call declareArraySizes (A.Array [A.Dimension $ length cs] c) n
|
call declareArraySizes (A.Array [A.Dimension $ length cs] c) n
|
||||||
cintroduceSpec (A.Specification _ _ (A.DataType _ _)) = return ()
|
cintroduceSpec (A.Specification _ _ (A.DataType _ _)) = return ()
|
||||||
cintroduceSpec (A.Specification _ n (A.RecordType _ b fs))
|
cintroduceSpec (A.Specification _ _ (A.RecordType _ _ _)) = return ()
|
||||||
= do tell ["typedef struct{"]
|
|
||||||
sequence_ [call genDeclaration t n True | (n, t) <- fs]
|
|
||||||
tell ["}"]
|
|
||||||
when b $ tell [" occam_struct_packed "]
|
|
||||||
genName n
|
|
||||||
tell [";"]
|
|
||||||
cintroduceSpec (A.Specification _ n (A.Protocol _ _)) = return ()
|
cintroduceSpec (A.Specification _ n (A.Protocol _ _)) = return ()
|
||||||
cintroduceSpec (A.Specification _ n (A.ProtocolCase _ ts))
|
cintroduceSpec (A.Specification _ n (A.ProtocolCase _ ts))
|
||||||
= do tell ["typedef enum{"]
|
= do tell ["typedef enum{"]
|
||||||
|
@ -1338,6 +1333,16 @@ cintroduceSpec (A.Specification _ n (A.Retypes m am t v))
|
||||||
--cintroduceSpec (A.Specification _ n (A.RetypesExpr _ am t e))
|
--cintroduceSpec (A.Specification _ n (A.RetypesExpr _ am t e))
|
||||||
cintroduceSpec n = call genMissing $ "introduceSpec " ++ show n
|
cintroduceSpec n = call genMissing $ "introduceSpec " ++ show n
|
||||||
|
|
||||||
|
cgenRecordTypeSpec :: A.Name -> Bool -> [(A.Name, A.Type)] -> CGen ()
|
||||||
|
cgenRecordTypeSpec n b fs
|
||||||
|
= do tell ["typedef struct{"]
|
||||||
|
sequence_ [call genDeclaration t n True | (n, t) <- fs]
|
||||||
|
tell ["}"]
|
||||||
|
when b $ tell [" occam_struct_packed "]
|
||||||
|
genName n
|
||||||
|
tell [";"]
|
||||||
|
|
||||||
|
|
||||||
cgenForwardDeclaration :: A.Specification -> CGen ()
|
cgenForwardDeclaration :: A.Specification -> CGen ()
|
||||||
cgenForwardDeclaration (A.Specification _ n (A.Proc _ sm fs _))
|
cgenForwardDeclaration (A.Specification _ n (A.Proc _ sm fs _))
|
||||||
= do call genSpecMode sm
|
= do call genSpecMode sm
|
||||||
|
@ -1346,6 +1351,8 @@ cgenForwardDeclaration (A.Specification _ n (A.Proc _ sm fs _))
|
||||||
tell [" (Process *me"]
|
tell [" (Process *me"]
|
||||||
call genFormals fs
|
call genFormals fs
|
||||||
tell [");"]
|
tell [");"]
|
||||||
|
cgenForwardDeclaration (A.Specification _ n (A.RecordType _ b fs))
|
||||||
|
= call genRecordTypeSpec n b fs
|
||||||
cgenForwardDeclaration _ = return ()
|
cgenForwardDeclaration _ = return ()
|
||||||
|
|
||||||
cremoveSpec :: A.Specification -> CGen ()
|
cremoveSpec :: A.Specification -> CGen ()
|
||||||
|
|
|
@ -145,6 +145,7 @@ data GenOps = GenOps {
|
||||||
genPar :: A.ParMode -> A.Structured A.Process -> CGen (),
|
genPar :: A.ParMode -> A.Structured A.Process -> CGen (),
|
||||||
genProcCall :: A.Name -> [A.Actual] -> CGen (),
|
genProcCall :: A.Name -> [A.Actual] -> CGen (),
|
||||||
genProcess :: A.Process -> CGen (),
|
genProcess :: A.Process -> CGen (),
|
||||||
|
genRecordTypeSpec :: A.Name -> Bool -> [(A.Name, A.Type)] -> CGen (),
|
||||||
-- | Generates a replicator loop, given the replicator and body
|
-- | Generates a replicator loop, given the replicator and body
|
||||||
genReplicator :: A.Replicator -> CGen () -> CGen (),
|
genReplicator :: A.Replicator -> CGen () -> CGen (),
|
||||||
-- | Generates the three bits of a for loop (e.g. "int i=0;i<10;i++" for the given replicator
|
-- | Generates the three bits of a for loop (e.g. "int i=0;i<10;i++" for the given replicator
|
||||||
|
|
|
@ -725,6 +725,8 @@ cppgenForwardDeclaration (A.Specification _ n (A.Proc _ sm fs _))
|
||||||
genConstructorList :: [A.Formal] -> CGen ()
|
genConstructorList :: [A.Formal] -> CGen ()
|
||||||
genConstructorList fs = mapM_ genConsItem fs
|
genConstructorList fs = mapM_ genConsItem fs
|
||||||
|
|
||||||
|
cppgenForwardDeclaration (A.Specification _ n (A.RecordType _ b fs))
|
||||||
|
= call genRecordTypeSpec n b fs
|
||||||
cppgenForwardDeclaration _ = return ()
|
cppgenForwardDeclaration _ = return ()
|
||||||
|
|
||||||
cppintroduceSpec :: A.Specification -> CGen ()
|
cppintroduceSpec :: A.Specification -> CGen ()
|
||||||
|
@ -805,15 +807,6 @@ cppintroduceSpec (A.Specification _ n (A.IsExpr _ am t e))
|
||||||
rhs
|
rhs
|
||||||
tell [";\n"]
|
tell [";\n"]
|
||||||
|
|
||||||
--This clause was simplified, because we don't need separate array sizes in C++:
|
|
||||||
cppintroduceSpec (A.Specification _ n (A.RecordType _ b fs))
|
|
||||||
= do tell ["typedef struct{"]
|
|
||||||
sequence_ [call genDeclaration t n True
|
|
||||||
| (n, t) <- fs]
|
|
||||||
tell ["}"]
|
|
||||||
when b $ tell [" occam_struct_packed "]
|
|
||||||
genName n
|
|
||||||
tell [";"]
|
|
||||||
--Clause changed to handle array retyping
|
--Clause changed to handle array retyping
|
||||||
cppintroduceSpec (A.Specification _ n (A.Retypes m am t v))
|
cppintroduceSpec (A.Specification _ n (A.Retypes m am t v))
|
||||||
= do origT <- typeOfVariable v
|
= do origT <- typeOfVariable v
|
||||||
|
|
Loading…
Reference in New Issue
Block a user