diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index a7c4c4c..15b1ea9 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -158,6 +158,7 @@ data GenOps = GenOps { genVariableAM :: GenOps -> A.Variable -> A.AbbrevMode -> CGen (), -- | Generates a variable, with no indexing checks anywhere genVariableUnchecked :: GenOps -> A.Variable -> CGen (), + -- | Performs a wait for\/until (depending on the 'A.WaitMode') a specified time genWait :: GenOps -> A.WaitMode -> A.Expression -> CGen (), genWhile :: GenOps -> A.Expression -> A.Process -> CGen (), getScalarType :: GenOps -> A.Type -> Maybe String, @@ -1562,9 +1563,9 @@ cgenTimerRead ops c v cgenTimerWait :: GenOps -> A.Expression -> CGen () cgenTimerWait ops e - = do tell ["ProcTimeAfter ("] + = do tell ["ProcTimeAfter("] call genExpression ops e - tell [");\n"] + tell [");"] cgenGetTime :: GenOps -> Meta -> A.Variable -> CGen () cgenGetTime ops m v @@ -1575,9 +1576,9 @@ cgenGetTime ops m v cgenWait :: GenOps -> A.WaitMode -> A.Expression -> CGen () cgenWait ops A.WaitUntil e = call genTimerWait ops e cgenWait ops A.WaitFor e - = do tell ["ProcAfter ("] + = do tell ["ProcAfter("] call genExpression ops e - tell [");\n"] + tell [");"] --}}} --{{{ output diff --git a/backends/GenerateCTest.hs b/backends/GenerateCTest.hs index 4e03cc9..1e417bb 100644 --- a/backends/GenerateCTest.hs +++ b/backends/GenerateCTest.hs @@ -557,6 +557,15 @@ testGetTime = testBoth "testGetTime 0" "ProcTime(&@);" "csp::CurrentTime(&@);" ( where over ops = ops {genVariable = override1 at} +testWait :: Test +testWait = TestList + [ + testBoth "testWait 0" "ProcTimeAfter($);" "csp::SleepUntil($);" ((tcall2 genWait A.WaitUntil undefined) . over) + ,testBoth "testWait 1" "ProcAfter($);" "csp::SleepFor($);" ((tcall2 genWait A.WaitFor undefined) . over) + ] + where + over ops = ops {genExpression = override1 dollar} + testIf :: Test testIf = TestList [ @@ -591,4 +600,5 @@ tests = TestList ,testOverArray ,testReplicator ,testStop + ,testWait ]