Added a function to check the parameters passed to a proc call against each other for safe usage (CREW)

This commit is contained in:
Neil Brown 2008-01-29 12:00:32 +00:00
parent 4bbb3f86d7
commit 48384746d0
2 changed files with 20 additions and 1 deletions

View File

@ -49,6 +49,7 @@ usageCheckPass t = do g' <- buildFlowGraph labelFunctions t
Right g -> return g
sequence_ $ checkPar (joinCheckParFunctions checkArrayUsage checkPlainVarUsage) g
checkParAssignUsage t
checkProcCallArgsUsage t
-- TODO add checkInitVar here (need to find roots in the tree)
return t
@ -189,3 +190,21 @@ checkParAssignUsage = mapM_ checkParAssign . listify isParAssign
where
mockedupParItems :: ParItems (Maybe Decl, Vars)
mockedupParItems = ParItems [SeqItems [(Nothing, processVarW v)] | v <- vs]
checkProcCallArgsUsage :: forall m t. (CSM m, Die m, Data t) => t -> m ()
checkProcCallArgsUsage = mapM_ checkArgs . listify isProcCall
where
isProcCall :: A.Process -> Bool
isProcCall (A.ProcCall {}) = True
isProcCall _ = False
-- | Need to check that all the destinations in a parallel assignment
-- are distinct. So we check plain variables, and array variables
checkArgs :: A.Process -> m ()
checkArgs (A.ProcCall m _ params)
= do checkPlainVarUsage (m, mockedupParItems)
checkArrayUsage (m, mockedupParItems)
where
mockedupParItems :: ParItems (Maybe Decl, Vars)
mockedupParItems = ParItems [SeqItems [(Nothing, v)] | v <- map getVarActual params]

View File

@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
-}
module UsageCheckUtils (customVarCompare, Decl(..), emptyVars, foldUnionVars, getVarProc, labelFunctions, mapUnionVars, ParItems(..), processVarW, transformParItems, Var(..), Vars(..), vars) where
module UsageCheckUtils (customVarCompare, Decl(..), emptyVars, foldUnionVars, getVarActual, getVarProc, labelFunctions, mapUnionVars, ParItems(..), processVarW, transformParItems, Var(..), Vars(..), vars) where
import Data.Generics hiding (GT)
import Data.List