never executed always true always false
    1 module HelVM.HelMA.Automata.ETA.Evaluator (
    2   simpleEval,
    3   evalParams,
    4 ) where
    5 
    6 import           HelVM.HelMA.Automata.ETA.API.ETAImplType
    7 
    8 import           HelVM.HelMA.Automata.ETA.Automaton
    9 import           HelVM.HelMA.Automata.ETA.Lexer
   10 import           HelVM.HelMA.Automata.ETA.Optimizer
   11 import qualified HelVM.HelMA.Automata.ETA.SimpleParams      as S
   12 import           HelVM.HelMA.Automata.ETA.Symbol
   13 import           HelVM.HelMA.Automata.ETA.Token
   14 
   15 import qualified HelVM.HelMA.Automaton.API.AutomatonOptions as Automaton
   16 import           HelVM.HelMA.Automaton.API.AutoOptions
   17 import           HelVM.HelMA.Automaton.API.EvalParams
   18 import           HelVM.HelMA.Automaton.API.IOTypes
   19 
   20 import qualified HelVM.HelMA.Automaton.Automaton            as Automaton
   21 
   22 import           HelVM.HelMA.Automaton.IO.AutomatonIO
   23 import           HelVM.HelMA.Automaton.IO.BusinessIO
   24 
   25 import           HelVM.HelMA.Automaton.Types.DumpType
   26 import           HelVM.HelMA.Automaton.Types.StackType
   27 
   28 import           HelVM.HelIO.Collections.SList              as SList
   29 
   30 import qualified Data.Sequence                              as Seq
   31 
   32 import           Prelude                                    hiding (divMod)
   33 
   34 simpleEval :: BIO m => S.SimpleParams -> m ()
   35 simpleEval p = evalSource (S.implType p) (S.source p) (S.stackType p) (S.autoOptions p)
   36 
   37 ----
   38 
   39 evalParams :: BIO m => ETAImplType -> EvalParams -> m ()
   40 evalParams e p = evalSource e (source p) (stackAutoOptions p) (autoOptions p)
   41 
   42 evalSource :: (AutomatonIO Symbol m) => ETAImplType -> Source -> StackType -> AutoOptions -> m ()
   43 evalSource etaImplType source = evalTL etaImplType (tokenize source)
   44 
   45 evalTL :: (AutomatonIO Symbol m) => ETAImplType -> TokenList -> StackType -> AutoOptions -> m ()
   46 evalTL Fast     = fastEval
   47 evalTL Original = originalEval
   48 
   49 fastEval :: (AutomatonIO Symbol m) => TokenList -> StackType -> AutoOptions -> m ()
   50 fastEval tl s a = flip Automaton.start (Automaton.withDefaultRam s a) =<< optimize tl
   51 
   52 originalEval :: (AutomatonIO Symbol m) => TokenList -> StackType -> AutoOptions -> m ()
   53 originalEval tl ListStackType  = eval tl []
   54 originalEval tl SeqStackType   = eval tl Seq.empty
   55 originalEval tl SListStackType = eval tl SList.sListEmpty
   56 
   57 eval :: (SAutomatonIO Symbol s m) => TokenList -> s -> AutoOptions -> m ()
   58 eval tl s (AutoOptions _ limit dt) = logDump dt =<< run limit (newMemory tl s)