Added support for simple input statements to the usage checker
This commit is contained in:
parent
5280bb4fc6
commit
fddc3fb6b8
|
@ -94,7 +94,12 @@ getVarProc (A.Output _ chanVar outItems) = (processVarUsed chanVar) `unionVars`
|
|||
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 (A.Input _ chanVar (A.InputSimple _ iis)) = (processVarUsed chanVar) `unionVars` (mapUnionVars getVarInputItem iis)
|
||||
where
|
||||
getVarInputItem :: A.InputItem -> Vars
|
||||
getVarInputItem (A.InCounted _ cv av) = writtenVars [variableToVar cv,variableToVar av]
|
||||
getVarInputItem (A.InVariable _ v) = writtenVars [variableToVar v]
|
||||
--TODO process calls
|
||||
getVarProc _ = emptyVars
|
||||
|
||||
{-
|
||||
|
|
|
@ -87,6 +87,12 @@ testGetVarProc = TestList (map doTest tests)
|
|||
,(402,[tvA,tvB],[],[],[tvC],A.Output emptyMeta vC
|
||||
[A.OutCounted emptyMeta (A.ExprVariable emptyMeta vA) (A.ExprVariable emptyMeta vB)])
|
||||
|
||||
-- Test simple inputs:
|
||||
,(500,[],[tvB],[tvB],[tvC],A.Input emptyMeta vC (A.InputSimple emptyMeta [A.InVariable emptyMeta vB]))
|
||||
,(501,[],[tvA,tvB],[tvA,tvB],[tvC],A.Input emptyMeta vC
|
||||
(A.InputSimple emptyMeta [A.InVariable emptyMeta vB,A.InVariable emptyMeta vA]))
|
||||
,(502,[],[tvA,tvB],[tvA,tvB],[tvC],A.Input emptyMeta vC
|
||||
(A.InputSimple emptyMeta [A.InCounted emptyMeta vA vB]))
|
||||
]
|
||||
doTest :: (Int,[Var],[Var],[Var],[Var],A.Process) -> Test
|
||||
doTest (index,mr,mw,dw,u,proc) = TestCase $ assertEqual ("testGetVarProc-" ++ (show index)) (vars mr mw dw u) (getVarProc proc)
|
||||
|
|
Loading…
Reference in New Issue
Block a user