From 658bfd08e469b230417e72e2eb19a51b6c395ca8 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 23 Mar 2009 21:14:10 +0000 Subject: [PATCH] Added some code to deal with channel bundles --- backends/GenerateC.hs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index 49d7c9f..7f12477 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -681,12 +681,22 @@ cgenVariableWithAM checkValid v am fct ct <- case lookup fieldName fs of Just x -> call getCType m x A.Original Nothing -> dieP m $ "Could not find type of field name: " ++ show fieldName - -- For records, we expect it to be a pointer to a record: - return (do tell ["("] + case vt of + A.Record {} -> + -- For records, we expect it to be a pointer to a record: + return + (do tell ["("] call genVariable' v A.Original stripPointers tell [")."] genName fieldName , ct) + A.ChanDataType {} -> + return + (do tell ["(&("] + call genVariable' v A.Original (const $ Plain "mt_cb_t") + let ind = findIndex ((== fieldName) . fst) fs + tell [".channels[", maybe "" show ind, "]))"] + , ct) A.SubscriptFromFor m' subCheck start count -> do ct <- details v return (do let check = if checkValid then subCheck else A.NoCheck @@ -752,6 +762,8 @@ cgetCType m origT am (A.Chan {}, _, False, A.Abbrev) -> return $ Pointer $ Plain "Channel" (A.ChanEnd {}, _, False, _) -> return $ Pointer $ Plain "Channel" + (A.ChanDataType {}, _, _, _) -> return $ Pointer $ Plain "mt_cb_t" + -- Scalar types: (_, Just pl, False, A.Original) -> return $ Plain pl (_, Just pl, False, A.Abbrev) -> return $ Pointer $ Plain pl