Added support for the new Wait process to the C and C++ backends

This commit is contained in:
Neil Brown 2007-09-26 23:18:21 +00:00
parent a65953ad89
commit 41d4923e9c
2 changed files with 17 additions and 0 deletions

View File

@ -153,6 +153,7 @@ data GenOps = GenOps {
genVariable' :: GenOps -> Bool -> A.Variable -> CGen (),
genVariableAM :: GenOps -> A.Variable -> A.AbbrevMode -> CGen (),
genVariableUnchecked :: GenOps -> A.Variable -> CGen (),
genWait :: GenOps -> A.WaitMode -> A.Expression -> CGen (),
genWhile :: GenOps -> A.Expression -> A.Process -> CGen (),
getScalarType :: GenOps -> A.Type -> Maybe String,
introduceSpec :: GenOps -> A.Specification -> CGen (),
@ -243,6 +244,7 @@ cgenOps = GenOps {
genVariableAM = cgenVariableAM,
genVariableUnchecked = cgenVariableUnchecked,
genWhile = cgenWhile,
genWait = cgenWait,
getScalarType = cgetScalarType,
introduceSpec = cintroduceSpec,
removeSpec = cremoveSpec
@ -1479,6 +1481,7 @@ cgenProcess ops p = case p of
A.Output m c ois -> call genOutput ops c ois
A.OutputCase m c t ois -> call genOutputCase ops c t ois
A.GetTime m v -> call genGetTime ops m v
A.Wait m wm e -> call genWait ops wm e
A.Skip m -> tell ["/* skip */\n"]
A.Stop m -> call genStop ops m "STOP process"
A.Main m -> tell ["/* main */\n"]
@ -1579,6 +1582,13 @@ cgenGetTime ops m v
call genVariable ops v
tell [");\n"]
cgenWait :: GenOps -> A.WaitMode -> A.Expression -> CGen ()
cgenWait ops A.WaitUntil e = call genTimerWait ops e
cgenWait ops A.WaitFor e
= do tell ["ProcAfter ("]
call genExpression ops e
tell [");\n"]
--}}}
--{{{ output
cgenOutput :: GenOps -> A.Variable -> [A.OutputItem] -> CGen ()

View File

@ -130,6 +130,7 @@ cppgenOps = cgenOps {
genUnfoldedExpression = cppgenUnfoldedExpression,
genUnfoldedVariable = cppgenUnfoldedVariable,
genVariable' = cppgenVariable',
genWait = cppgenWait,
getScalarType = cppgetScalarType,
introduceSpec = cppintroduceSpec,
removeSpec = cppremoveSpec
@ -356,6 +357,12 @@ cppgenGetTime ops m v
call genVariable ops v
tell [");"]
cppgenWait :: GenOps -> A.WaitMode -> A.Expression -> CGen ()
cppgenWait ops wm e
= do tell [if wm == A.WaitFor then "csp::SleepFor" else "csp::SleepUntil", "("]
call genExpression ops e
tell [");"]
{-|
Gets a csp::Time to wait with, given a 32-bit microsecond value (returns the temp variable we have put it in)