diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index 15b1ea9..646314c 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -160,6 +160,7 @@ data GenOps = GenOps { 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 (), + -- | Generates a while loop with the given condition and body. genWhile :: GenOps -> A.Expression -> A.Process -> CGen (), getScalarType :: GenOps -> A.Type -> Maybe String, introduceSpec :: GenOps -> A.Specification -> CGen (), @@ -1668,11 +1669,11 @@ cgenCase ops m e s --{{{ while cgenWhile :: GenOps -> A.Expression -> A.Process -> CGen () cgenWhile ops e p - = do tell ["while ("] + = do tell ["while("] call genExpression ops e - tell [") {\n"] + tell ["){"] call genProcess ops p - tell ["}\n"] + tell ["}"] --}}} --{{{ par cgenPar :: GenOps -> A.ParMode -> A.Structured -> CGen () diff --git a/backends/GenerateCTest.hs b/backends/GenerateCTest.hs index 1e417bb..5491ab3 100644 --- a/backends/GenerateCTest.hs +++ b/backends/GenerateCTest.hs @@ -582,6 +582,11 @@ testIf = TestList p = undefined over ops = ops {genExpression = override1 dollar, genProcess = override1 at, genStop = override2 caret, genSpec = override2 hash} +testWhile :: Test +testWhile = testBothSame "testWhile 0" "while($){@}" ((tcall2 genWhile undefined undefined) . over) + where + over ops = ops {genExpression = override1 dollar, genProcess = override1 at} + ---Returns the list of tests: tests :: Test tests = TestList @@ -601,4 +606,5 @@ tests = TestList ,testReplicator ,testStop ,testWait + ,testWhile ]