From f8d4efa0e9ed607650e59fd405b2873acda6be85 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 9 Mar 2008 11:57:43 +0000 Subject: [PATCH] Go back to generating Time variables for timers. This is for two reasons: first, the C++CSP backend still needs them, and second, the way I'd done the removal wasn't correct; since you can have arrays of them, abbreviate them, etc., they need to be stripped out by an earlier pass so that other passes don't try to operate upon them. --- backends/GenerateC.hs | 3 +-- backends/GenerateCTest.hs | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index 085f8b6..db358cf 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -279,7 +279,7 @@ cgetScalarType A.Int32 = Just "int32_t" cgetScalarType A.Int64 = Just "int64_t" cgetScalarType A.Real32 = Just "float" cgetScalarType A.Real64 = Just "double" -cgetScalarType A.Timer = Just "Time" -- Not used in the C backend. +cgetScalarType A.Timer = Just "Time" cgetScalarType A.Time = Just "Time" cgetScalarType _ = Nothing @@ -1090,7 +1090,6 @@ cgenDeclaration (A.Array ds t) n True call genArrayStoreName n call genFlatArraySize ds tell [";"] -cgenDeclaration A.Timer _ _ = return () cgenDeclaration t n _ = do call genType t tell [" "] diff --git a/backends/GenerateCTest.hs b/backends/GenerateCTest.hs index 7846d3f..aedc6b0 100644 --- a/backends/GenerateCTest.hs +++ b/backends/GenerateCTest.hs @@ -462,6 +462,12 @@ testDeclaration = TestList --Records of arrays of int (the sizes are set by declareInit): ,testBothSameS "genDeclaration 400" "REC foo;" (tcall3 genDeclaration (A.Record $ simpleName "REC") foo False) (stateR $ A.Array [A.Dimension 8] A.Int) + + --Timers: + ,testBoth "genDeclaration 500" "Time foo;" "csp::Time foo;" + (tcall3 genDeclaration A.Timer foo False) + ,testBoth "genDeclaration 501" "Time foo[20];" "csp::Time foo[20];" + (tcall3 genDeclaration (A.Array [A.Dimension 20] A.Timer) foo False) ] where stateR t = defRecord "REC" "bar" t