From 1124bb5a4423d16a7b0d994728235c4bf27ce3e6 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sat, 15 Mar 2008 15:15:21 +0000 Subject: [PATCH] Use either Alt or TimerAlt as appropriate. --- backends/GenerateC.hs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index bd3c59f..52ad76e 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -1597,13 +1597,14 @@ cgenAlt isPri s = do id <- csmLift $ makeNonce "alt_id" tell ["int ", id, " = 0;\n"] - tell ["TimerAlt (wptr);\n"] + let isTimerAlt = containsTimers s + tell [if isTimerAlt then "TimerAlt" else "Alt", " (wptr);\n"] tell ["{\n"] genAltEnable id s tell ["}\n"] -- Like occ21, this is always a PRI ALT, so we can use it for both. - tell ["TimerAltWait (wptr);\n"] + tell [if isTimerAlt then "TimerAltWait" else "AltWait", " (wptr);\n"] tell [id, " = 0;\n"] tell ["{\n"] genAltDisable id s @@ -1618,6 +1619,18 @@ cgenAlt isPri s tell ["}\n"] tell [label, ":\n;\n"] where + containsTimers :: A.Structured A.Alternative -> Bool + containsTimers (A.Rep _ _ s) = containsTimers s + containsTimers (A.Spec _ _ s) = containsTimers s + containsTimers (A.ProcThen _ _ s) = containsTimers s + containsTimers (A.Only _ a) + = case a of + A.Alternative _ _ (A.InputTimerRead _ _) _ -> True + A.Alternative _ _ (A.InputTimerAfter _ _) _ -> True + A.AlternativeWait _ _ _ _ -> True + _ -> False + containsTimers (A.Several _ ss) = or $ map containsTimers ss + genAltEnable :: String -> A.Structured A.Alternative -> CGen () genAltEnable id s = call genStructured s doA where