module Ivory.Language.Ion.Base where
import Control.Exception
import Control.Monad.State hiding ( forever )
import Data.Typeable
import qualified Ivory.Language as IL
import Ivory.Language
import qualified Ivory.Language.Monad as ILM
type Ion = State IonDef
data IonDef = IonDef { ionId :: String
, ionNum :: Int
, ionDefs :: IL.ModuleDef
, ionCtxt :: Schedule
, ionSched :: [Schedule]
}
defaultIonDef = IonDef { ionId = ""
, ionNum = 0
, ionDefs = return ()
, ionCtxt = defaultSchedule
, ionSched = []
}
data Schedule =
Schedule { schedId :: Integer
, schedName :: String
, schedPath :: [String]
, schedPhase :: Integer
, schedPeriod :: Integer
, schedAction :: [IvoryAction ()]
, schedCond :: [IvoryAction IL.IBool]
}
deriving (Show)
defaultSchedule = Schedule { schedId = 0
, schedName = "root"
, schedPath = []
, schedPhase = 0
, schedPeriod = 1
, schedAction = []
, schedCond = []
}
type IvoryAction = IL.Ivory IL.NoEffects
instance Show (IvoryAction a) where
show iv = "Ivory NoEffects () [" ++ show block ++ "]"
where (_, block) =
ILM.runIvory $ ILM.noReturn $ ILM.noBreak $ ILM.noAlloc iv
data PhaseContext = Absolute
| Relative
deriving (Show)
data PhaseType = Min
| Exact
deriving (Show)
data IonException = InvalidCName [String] String Int
| PhaseExceedsPeriod [String] Integer Integer
| PhaseIsNegative [String] Integer
| PeriodMustBePositive [String] Integer
deriving (Show, Typeable)
instance Exception IonException