Refactored the C++ genOutputItem to merge some duplicate code
This commit is contained in:
parent
9af1ec78bb
commit
5e1e51ac15
|
@ -426,23 +426,12 @@ cppgenInputItem ops c (A.InVariable m v)
|
||||||
cppgenOutputItem :: GenOps -> A.Variable -> A.OutputItem -> CGen ()
|
cppgenOutputItem :: GenOps -> A.Variable -> A.OutputItem -> CGen ()
|
||||||
cppgenOutputItem ops chan item
|
cppgenOutputItem ops chan item
|
||||||
= case item of
|
= case item of
|
||||||
(A.OutCounted m (A.ExprVariable _ cv) (A.ExprVariable _ av)) ->
|
(A.OutCounted m (A.ExprVariable _ cv) (A.ExprVariable _ av)) -> (sendBytes cv) >> (sendBytes av)
|
||||||
do chan'
|
|
||||||
tell ["<<tockSendableArrayOfBytes("]
|
|
||||||
genPoint cv
|
|
||||||
tell [");"]
|
|
||||||
chan'
|
|
||||||
tell ["<<tockSendableArrayOfBytes("]
|
|
||||||
genPoint av
|
|
||||||
tell [");"]
|
|
||||||
(A.OutExpression _ (A.ExprVariable _ sv)) ->
|
(A.OutExpression _ (A.ExprVariable _ sv)) ->
|
||||||
do t <- typeOfVariable chan
|
do t <- typeOfVariable chan
|
||||||
tsv <- typeOfVariable sv
|
tsv <- typeOfVariable sv
|
||||||
case (byteArrayChan t,tsv) of
|
case (byteArrayChan t,tsv) of
|
||||||
(True,_) -> do chan'
|
(True,_) -> sendBytes sv
|
||||||
tell ["<<tockSendableArrayOfBytes("]
|
|
||||||
genPoint sv
|
|
||||||
tell [");"]
|
|
||||||
(False,A.Array {}) -> do tell ["tockSendArray("]
|
(False,A.Array {}) -> do tell ["tockSendArray("]
|
||||||
chan'
|
chan'
|
||||||
tell [","]
|
tell [","]
|
||||||
|
@ -455,6 +444,11 @@ cppgenOutputItem ops chan item
|
||||||
where
|
where
|
||||||
chan' = genCPPCSPChannelOutput ops chan
|
chan' = genCPPCSPChannelOutput ops chan
|
||||||
|
|
||||||
|
sendBytes v = do chan'
|
||||||
|
tell ["<<tockSendableArrayOfBytes("]
|
||||||
|
genPoint v
|
||||||
|
tell [");"]
|
||||||
|
|
||||||
byteArrayChan :: A.Type -> Bool
|
byteArrayChan :: A.Type -> Bool
|
||||||
byteArrayChan (A.Chan _ _ (A.UserProtocol _)) = True
|
byteArrayChan (A.Chan _ _ (A.UserProtocol _)) = True
|
||||||
byteArrayChan (A.Chan _ _ A.Any) = True
|
byteArrayChan (A.Chan _ _ A.Any) = True
|
||||||
|
|
Loading…
Reference in New Issue
Block a user