-------------------------------------------------------------------------------

driver :: Int -> Spec -> Text
driver numIterations Spec { specTriggers = trigs 
                          , specStreams = streams } 
  =
  pack . render $
    ppHeader $$
    ppEnvDecls numIterations env $$
    ppMain numIterations env $$
    ppTriggers trigs
  where 
  env :: [ExtVars]
  env = nubBy (\(name0,_) (name1,_) -> name0 == name1) 
              (concatMap extractExts exprs)
  exprs =    map strmExpr streams
          ++ concatMap triggerArgs trigs 
          ++ map uexpr (map triggerGuard trigs)
  strmExpr Stream { streamExpr = expr } = uexpr expr
  uexpr :: Typed a => Expr a -> UExpr
  uexpr e = UExpr { uExprType = typeOf
                  , uExprExpr = e }

--------------------------------------------------------------------------------

-- XXX will need to be generalized to external arrays and functions at some
-- point.

driver :: Int -> Spec -> Text
driver numIterations Spec { specTriggers = trigs 
                          , specStreams = streams } 
  =
  pack . render $
    ppHeader $$
    ppEnvDecls numIterations env $$
    ppMain numIterations env $$
    ppTriggers trigs
  where 
  env :: [ExtVars]
  env = nubBy (\(name0,_) (name1,_) -> name0 == name1) 
              (concatMap extractExts exprs)
  exprs =    map strmExpr streams
          ++ concatMap triggerArgs trigs 
          ++ map uexpr (map triggerGuard trigs)
  strmExpr Stream { streamExpr = expr } = uexpr expr
  uexpr :: Typed a => Expr a -> UExpr
  uexpr e = UExpr { uExprType = typeOf
                  , uExprExpr = e }

--------------------------------------------------------------------------------

-- XXX will need to be generalized to external arrays and functions at some
-- point.
driver numIterations Spec { specTriggers = trigs 
                          , specStreams = streams } 
  =
  pack . render $
    ppHeader $$
    ppEnvDecls numIterations env $$
    ppMain numIterations env $$
    ppTriggers trigs
  where 
  env :: [ExtVars]
  env = nubBy (\(name0,_) (name1,_) -> name0 == name1) 
              (concatMap extractExts exprs)
  exprs =    map strmExpr streams
          ++ concatMap triggerArgs trigs 
          ++ map uexpr (map triggerGuard trigs)
  strmExpr Stream { streamExpr = expr } = uexpr expr
  uexpr :: Typed a => Expr a -> UExpr
  uexpr e = UExpr { uExprType = typeOf
                  , uExprExpr = e }

--------------------------------------------------------------------------------

-- XXX will need to be generalized to external arrays and functions at some
-- point.