From 5e1e51ac153c2406cf42664ca2e2963b98afb462 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sat, 6 Oct 2007 23:08:05 +0000 Subject: [PATCH] Refactored the C++ genOutputItem to merge some duplicate code --- backends/GenerateCPPCSP.hs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/backends/GenerateCPPCSP.hs b/backends/GenerateCPPCSP.hs index b01a33b..b32afc7 100644 --- a/backends/GenerateCPPCSP.hs +++ b/backends/GenerateCPPCSP.hs @@ -426,23 +426,12 @@ cppgenInputItem ops c (A.InVariable m v) cppgenOutputItem :: GenOps -> A.Variable -> A.OutputItem -> CGen () cppgenOutputItem ops chan item = case item of - (A.OutCounted m (A.ExprVariable _ cv) (A.ExprVariable _ av)) -> - do chan' - tell ["< (sendBytes cv) >> (sendBytes av) (A.OutExpression _ (A.ExprVariable _ sv)) -> do t <- typeOfVariable chan tsv <- typeOfVariable sv case (byteArrayChan t,tsv) of - (True,_) -> do chan' - tell ["< sendBytes sv (False,A.Array {}) -> do tell ["tockSendArray("] chan' tell [","] @@ -453,7 +442,12 @@ cppgenOutputItem ops chan item genNonPoint sv tell [";"] where - chan' = genCPPCSPChannelOutput ops chan + chan' = genCPPCSPChannelOutput ops chan + + sendBytes v = do chan' + tell ["< Bool byteArrayChan (A.Chan _ _ (A.UserProtocol _)) = True