diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index e6f6570..2406b73 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -324,7 +324,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" +cgetScalarType (A.Timer A.OccamTimer) = Just "Time" cgetScalarType A.Time = Just "Time" cgetScalarType _ = Nothing diff --git a/backends/GenerateCPPCSP.hs b/backends/GenerateCPPCSP.hs index 867b4ec..80957c6 100644 --- a/backends/GenerateCPPCSP.hs +++ b/backends/GenerateCPPCSP.hs @@ -642,7 +642,7 @@ cppgetScalarType A.Int32 = Just "int32_t" cppgetScalarType A.Int64 = Just "int64_t" cppgetScalarType A.Real32 = Just "float" cppgetScalarType A.Real64 = Just "double" -cppgetScalarType A.Timer = Just "csp::Time" +cppgetScalarType (A.Timer A.OccamTimer) = Just "csp::Time" cppgetScalarType A.Time = Just "csp::Time" cppgetScalarType _ = Nothing diff --git a/backends/GenerateCTest.hs b/backends/GenerateCTest.hs index f973c47..a25edaa 100644 --- a/backends/GenerateCTest.hs +++ b/backends/GenerateCTest.hs @@ -230,7 +230,7 @@ testGenType = TestList ,testBothSame "GenType 102" "int*" (tcall genType $ A.Array [dimension 5, A.UnknownDimension] A.Int) ,testBothSame "GenType 103" "foo" (tcall genType $ A.Record (simpleName "foo")) ,testBoth "GenType 200" "Time" "csp::Time" (tcall genType A.Time) - ,testBoth "GenType 201" "Time" "csp::Time" (tcall genType A.Timer) + ,testBoth "GenType 201" "Time" "csp::Time" (tcall genType $ A.Timer A.OccamTimer) ,testBothSame "GenType 250" "int*" (tcall genType $ A.Mobile $ A.Array [dimension 5, dimension 2, dimension 9] A.Int) ,testBothSame "GenType 251" "int*" (tcall genType $ A.Mobile $ A.Array [dimension 5, A.UnknownDimension] A.Int) @@ -486,9 +486,9 @@ testDeclaration = TestList --Timers: ,testBoth "genDeclaration 500" "Time foo;" "csp::Time foo;" - (tcall3 genDeclaration A.Timer foo False) + (tcall3 genDeclaration (A.Timer A.OccamTimer) foo False) ,testBoth "genDeclaration 501" "Time foo[20];" "csp::Time foo[20];" - (tcall3 genDeclaration (A.Array [dimension 20] A.Timer) foo False) + (tcall3 genDeclaration (A.Array [dimension 20] (A.Timer A.OccamTimer)) foo False) ] where stateR t = defRecord "REC" "bar" t diff --git a/common/ShowCode.hs b/common/ShowCode.hs index 8d47a94..9265d34 100644 --- a/common/ShowCode.hs +++ b/common/ShowCode.hs @@ -223,7 +223,7 @@ instance ShowOccam A.Type where showOccamM A.Real32 = tell ["REAL32"] showOccamM A.Real64 = tell ["REAL64"] showOccamM A.Any = tell ["ANY"] - showOccamM A.Timer = tell ["TIMER"] + showOccamM (A.Timer _) = tell ["TIMER"] showOccamM A.Time = tell ["TIME"] showOccamM (A.Mobile t) = tell ["MOBILE "] >> showOccamM t diff --git a/data/AST.hs b/data/AST.hs index ff1e767..b7217fc 100644 --- a/data/AST.hs +++ b/data/AST.hs @@ -98,6 +98,13 @@ data ChanAttributes = ChanAttributes { } deriving (Show, Eq, Typeable, Data) +-- | In future we will probably add more timers to this list, especially for +-- occam. But for now we just differentiate between an occam timer (which +-- reads into something of type Int), and a Rain timer (which reads into something +-- of type Time). +data TimerType = OccamTimer | RainTimer + deriving (Eq, Show, Ord, Typeable, Data) + -- | A data or protocol type. -- The two concepts aren't unified in occam, but they are here, because it -- makes sense to be able to ask what type a particular name is defined to @@ -132,7 +139,7 @@ data Type = -- | A counted input or output. | Counted Type Type | Any - | Timer + | Timer TimerType | Time | Port Type | Mobile Type diff --git a/frontends/ParseOccam.hs b/frontends/ParseOccam.hs index 6e1d574..3300e98 100644 --- a/frontends/ParseOccam.hs +++ b/frontends/ParseOccam.hs @@ -628,7 +628,7 @@ channelType timerType :: OccParser A.Type timerType - = do { sTIMER; return $ A.Timer } + = do { sTIMER; return $ A.Timer A.OccamTimer } <|> arrayType timerType "timer type" @@ -1969,7 +1969,7 @@ actual (A.Formal am t n) _ -> case stripArrayType t of A.Chan {} -> var (channelOfType t) - A.Timer -> var timer + A.Timer {} -> var timer A.Port _ -> var (portOfType t) _ -> var (variableOfType t) "actual of type " ++ showOccam t ++ " for " ++ show n diff --git a/frontends/RainPasses.hs b/frontends/RainPasses.hs index b6219d7..5c70f6d 100644 --- a/frontends/RainPasses.hs +++ b/frontends/RainPasses.hs @@ -298,7 +298,7 @@ excludeNonRainFeatures = excludeConstr [ con0 A.Real32 ,con0 A.Real64 ,con2 A.Counted - ,con0 A.Timer + ,con1 A.Timer ,con1 A.Port ,con2 A.BytesInExpr ,con2 A.BytesInType