Added a check to ensure that the channel parameters of the main function have the correct direction if they are specified

This commit is contained in:
Neil Brown 2007-08-22 21:49:33 +00:00
parent 9efa008443
commit 7c61208c93

12
TLP.hs
View File

@ -50,15 +50,23 @@ tlpInterface
return (mainName, chans) return (mainName, chans)
where where
tlpChannel :: (CSM m, Die m) => A.Formal -> m TLPChannel tlpChannel :: (CSM m, Die m) => A.Formal -> m TLPChannel
tlpChannel (A.Formal _ (A.Chan _ _ A.Byte) n) tlpChannel (A.Formal _ (A.Chan dir _ A.Byte) n)
= do def <- lookupName n = do def <- lookupName n
let origN = A.ndOrigName def let origN = A.ndOrigName def
case lookup origN tlpChanNames of case lookup origN tlpChanNames of
Just c -> return c Just c ->
if (dir == A.DirUnknown || dir == (tlpDir c))
then return c
else die $ "TLP formal " ++ show n ++ " has wrong direction for its name"
_ -> die $ "TLP formal " ++ show n ++ " has unrecognised name" _ -> die $ "TLP formal " ++ show n ++ " has unrecognised name"
tlpChannel (A.Formal _ _ n) tlpChannel (A.Formal _ _ n)
= die $ "TLP formal " ++ show n ++ " has unrecognised type" = die $ "TLP formal " ++ show n ++ " has unrecognised type"
tlpDir :: TLPChannel -> A.Direction
tlpDir TLPIn = A.DirInput
tlpDir TLPOut = A.DirOutput
tlpDir TLPError = A.DirOutput
tlpChanNames :: [(String, TLPChannel)] tlpChanNames :: [(String, TLPChannel)]
tlpChanNames tlpChanNames
= [ ("in", TLPIn) = [ ("in", TLPIn)