Rain: implemented type-checking for wait guards

This commit is contained in:
Neil Brown 2007-09-26 23:42:40 +00:00
parent c38978c123
commit 028c27eb73

View File

@ -311,9 +311,9 @@ checkCommTypes p = (everywhereASTM checkInputOutput p) >>= (everywhereASTM check
= checkInput chanVar destVar m a = checkInput chanVar destVar m a
checkAltInput a = return a checkAltInput a = return a
-- | Checks the types in now and wait statements: -- | Checks the types in now and wait statements, and wait guards:
checkGetTimeTypes :: Data t => t -> PassM t checkGetTimeTypes :: Data t => t -> PassM t
checkGetTimeTypes = everywhereASTM checkGetTime checkGetTimeTypes p = (everywhereASTM checkGetTime p) >>= (everywhereASTM checkTimeGuards)
where where
checkGetTime :: A.Process -> PassM A.Process checkGetTime :: A.Process -> PassM A.Process
checkGetTime p@(A.GetTime m v) checkGetTime p@(A.GetTime m v)
@ -325,5 +325,13 @@ checkGetTimeTypes = everywhereASTM checkGetTime
= do t <- typeOfExpression e = do t <- typeOfExpression e
case t of case t of
A.Time -> return p A.Time -> return p
_ -> diePC m $ formatCode "Cannot wait for an expression of non-time type: \"%\"" t _ -> diePC m $ formatCode "Cannot wait with an expression of non-time type: \"%\"" t
checkGetTime p = return p checkGetTime p = return p
checkTimeGuards :: A.Alternative -> PassM A.Alternative
checkTimeGuards g@(A.AlternativeWait m _ e _)
= do t <- typeOfExpression e
case t of
A.Time -> return g
_ -> diePC m $ formatCode "Cannot wait with an expression of non-time type: \"%\"" t
checkTimeGuards g = return g