Fixed the C++CSP backend's use of channels (this fixes occam but probably breaks Rain, but I can come back to it later)

This commit is contained in:
Neil Brown 2008-11-13 21:00:56 +00:00
parent 377233b4b0
commit 9be287f157

View File

@ -305,17 +305,7 @@ cppgenInputItem c dest
(A.InVariable m v) -> (A.InVariable m v) ->
do ct <- astTypeOf c do ct <- astTypeOf c
t <- astTypeOf v t <- astTypeOf v
case (byteArrayChan ct,t) of recvBytes v (call genBytesIn m t (Right v))
(True,_)-> recvBytes v (call genBytesIn m t (Right v))
(False,A.Array {}) -> do tell ["tockRecvArray("]
chan'
tell [","]
call genVariable v
tell [");"]
(False,_) -> do chan'
tell [">>"]
genNonPoint v
tell [";"]
where where
chan' = genCPPCSPChannelInput c chan' = genCPPCSPChannelInput c
recvBytes :: A.Variable -> CGen () -> CGen () recvBytes :: A.Variable -> CGen () -> CGen ()
@ -334,24 +324,15 @@ cppgenOutputItem chan item
(A.OutExpression _ (A.ExprVariable _ sv)) -> (A.OutExpression _ (A.ExprVariable _ sv)) ->
do t <- astTypeOf chan do t <- astTypeOf chan
tsv <- astTypeOf sv tsv <- astTypeOf sv
case (byteArrayChan t,tsv) of sendBytes sv
(True,_) -> sendBytes sv
(False,A.Array {}) -> do tell ["tockSendArray("]
chan'
tell [","]
call genVariable sv
tell [");"]
(False,_) -> do chan'
tell ["<<"]
genNonPoint sv
tell [";"]
where where
chan' = genCPPCSPChannelOutput chan chan' = genCPPCSPChannelOutput chan
sendBytes v = do chan' sendBytes v = do tell ["tockSendArrayOfBytes("]
tell ["<<tockSendableArrayOfBytes("] chan'
tell [",tockSendableArrayOfBytes("]
genPoint v genPoint v
tell [");"] tell ["));"]
byteArrayChan :: A.Type -> Bool byteArrayChan :: A.Type -> Bool
byteArrayChan (A.Chan _ _ (A.UserProtocol _)) = True byteArrayChan (A.Chan _ _ (A.UserProtocol _)) = True