LCOV - code coverage report
Current view: top level - data/include/mcrl2/data - rewrite_strategy.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 12 36 33.3 %
Date: 2024-04-21 03:44:01 Functions: 3 5 60.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #ifndef MCRL2_DATA_REWRITE_STRATEGY_H
       2             : #define MCRL2_DATA_REWRITE_STRATEGY_H
       3             : 
       4             : #include "mcrl2/utilities/exception.h"
       5             : #include <string>
       6             : 
       7             : namespace mcrl2
       8             : {
       9             : namespace data
      10             : {
      11             : 
      12             : /// \brief The strategy of the rewriter.
      13             : enum rewrite_strategy
      14             : {
      15             :   jitty,                      /** \brief JITty */
      16             : #ifdef MCRL2_ENABLE_JITTYC
      17             :   jitty_compiling,            /** \brief Compiling JITty */
      18             :   jitty_prover,               /** \brief JITty + Prover */
      19             :   jitty_compiling_prover      /** \brief Compiling JITty + Prover*/
      20             : #else
      21             :   jitty_prover                /** \brief JITty + Prover */
      22             : #endif
      23             : };
      24             : 
      25             : /// \brief standard conversion from string to rewrite strategy
      26             : inline
      27          16 : rewrite_strategy parse_rewrite_strategy(const std::string& s)
      28             : {
      29          16 :   if(s == "jitty")
      30          11 :     return jitty;
      31           5 :   else if (s == "jittyp")
      32           0 :     return jitty_prover;
      33             : 
      34             : #ifdef MCRL2_ENABLE_JITTYC
      35           5 :   if (s == "jittyc")
      36           5 :     return jitty_compiling;
      37           0 :   else if (s == "jittycp")
      38           0 :     return jitty_compiling_prover;
      39             : #endif //MCRL2_ENABLE_JITTYC
      40             : 
      41           0 :   throw mcrl2::runtime_error("unknown rewrite strategy " + s);
      42             : }
      43             : 
      44             : /// \brief standard conversion from stream to rewrite strategy
      45           0 : inline std::istream& operator>>(std::istream& is, rewrite_strategy& s)
      46             : {
      47             :   try
      48             :   {
      49           0 :     std::stringbuf buffer;
      50           0 :     is >> &buffer;
      51           0 :     s = parse_rewrite_strategy(buffer.str());
      52           0 :   }
      53           0 :   catch(mcrl2::runtime_error&)
      54             :   {
      55           0 :     is.setstate(std::ios_base::failbit);
      56           0 :   }
      57             : 
      58           0 :   return is;
      59             : }
      60             : 
      61             : /// \brief Pretty prints a rewrite strategy
      62             : /// \param[in] s A rewrite strategy.
      63         351 : inline std::string pp(const rewrite_strategy s)
      64             : {
      65         351 :   switch (s)
      66             :   {
      67         351 :     case jitty: return "jitty";
      68             : #ifdef MCRL2_ENABLE_JITTYC
      69           0 :     case jitty_compiling: return "jittyc";
      70             : #endif
      71           0 :     case jitty_prover: return "jittyp";
      72             : #ifdef MCRL2_ENABLE_JITTYC
      73           0 :     case jitty_compiling_prover: return "jittycp";
      74             : #endif
      75           0 :     default: throw mcrl2::runtime_error("unknown rewrite_strategy");
      76             :   }
      77             : }
      78             : 
      79             : /// \brief standard conversion from rewrite strategy to stream
      80         351 : inline std::ostream& operator<<(std::ostream& os, const rewrite_strategy s)
      81             : {
      82         351 :   os << pp(s);
      83         351 :   return os;
      84             : }
      85             : 
      86             : /// \brief standard descriptions for rewrite strategies
      87           0 : inline std::string description(const rewrite_strategy s)
      88             : {
      89           0 :   switch (s)
      90             :   {
      91           0 :     case jitty: return "jitty rewriting";
      92             : #ifdef MCRL2_ENABLE_JITTYC
      93           0 :     case jitty_compiling: return "compiled jitty rewriting";
      94             : #endif
      95           0 :     case jitty_prover: return "jitty rewriting with prover";
      96             : #ifdef MCRL2_ENABLE_JITTYC
      97           0 :     case jitty_compiling_prover: return "compiled jitty rewriting with prover";
      98             : #endif
      99           0 :     default: throw mcrl2::runtime_error("unknown rewrite_strategy");
     100             :   }
     101             : }
     102             : 
     103             : } // namespace data
     104             : } // namespace mcrl2
     105             : 
     106             : #endif // MCRL2_DATA_REWRITE_STRATEGY_H

Generated by: LCOV version 1.14