Added support for output statements to the usage checker
This commit is contained in:
parent
1f97bc7d49
commit
5280bb4fc6
|
@ -68,6 +68,9 @@ unionVars (Vars mr mw dw u) (Vars mr' mw' dw' u') = Vars (mr `Set.union` mr') (m
|
|||
foldUnionVars :: [Vars] -> Vars
|
||||
foldUnionVars = foldl unionVars emptyVars
|
||||
|
||||
mapUnionVars :: (a -> Vars) -> [a] -> Vars
|
||||
mapUnionVars f = foldUnionVars . (map f)
|
||||
|
||||
nameToString :: A.Name -> String
|
||||
nameToString = A.nameName
|
||||
|
||||
|
@ -86,7 +89,12 @@ getVarProc (A.Assign _ vars expList)
|
|||
(getVarExpList expList)
|
||||
getVarProc (A.GetTime _ v) = processVarW v
|
||||
getVarProc (A.Wait _ _ e) = getVarExp e
|
||||
--TODO output input etc (all other processes that directly write to/read from variables)
|
||||
getVarProc (A.Output _ chanVar outItems) = (processVarUsed chanVar) `unionVars` (mapUnionVars getVarOutputItem outItems)
|
||||
where
|
||||
getVarOutputItem :: A.OutputItem -> Vars
|
||||
getVarOutputItem (A.OutExpression _ e) = getVarExp e
|
||||
getVarOutputItem (A.OutCounted _ ce ae) = (getVarExp ce) `unionVars` (getVarExp ae)
|
||||
--TODO input etc (all other processes that directly write to/read from variables)
|
||||
getVarProc _ = emptyVars
|
||||
|
||||
{-
|
||||
|
|
|
@ -31,7 +31,7 @@ import RainUsageCheck
|
|||
--Shorthands for some variables to simplify the list of tests in this file
|
||||
vA = variable "a"
|
||||
vB = A.DerefVariable emptyMeta $ variable "b"
|
||||
vC = variable "c"
|
||||
vC = A.DirectedVariable emptyMeta A.DirInput $ variable "c"
|
||||
vD = variable "d"
|
||||
vL = variable "l"
|
||||
l0 = intLiteral 0
|
||||
|
@ -39,7 +39,7 @@ l1 = intLiteral 1
|
|||
|
||||
tvA = Plain "a"
|
||||
tvB = Deref "b"
|
||||
tvC = Plain "c"
|
||||
tvC = Dir A.DirInput "c"
|
||||
tvD = Plain "d"
|
||||
tvL = Plain "l"
|
||||
|
||||
|
@ -81,7 +81,11 @@ testGetVarProc = TestList (map doTest tests)
|
|||
,(300,[],[tvB],[tvB],[],A.GetTime emptyMeta vB)
|
||||
,(301,[tvA],[],[],[],A.Wait emptyMeta A.WaitFor $ A.ExprVariable emptyMeta vA)
|
||||
|
||||
|
||||
-- Test simple outputs:
|
||||
,(400,[tvA],[],[],[tvC],A.Output emptyMeta vC [A.OutExpression emptyMeta $ A.ExprVariable emptyMeta vA])
|
||||
,(401,[tvA,tvB],[],[],[tvC],A.Output emptyMeta vC $ map ((A.OutExpression emptyMeta) . (A.ExprVariable emptyMeta)) [vA,vB])
|
||||
,(402,[tvA,tvB],[],[],[tvC],A.Output emptyMeta vC
|
||||
[A.OutCounted emptyMeta (A.ExprVariable emptyMeta vA) (A.ExprVariable emptyMeta vB)])
|
||||
|
||||
]
|
||||
doTest :: (Int,[Var],[Var],[Var],[Var],A.Process) -> Test
|
||||
|
|
Loading…
Reference in New Issue
Block a user