|
32 | 32 | #include "eval/visitors/autom_impl_visitor.hpp" |
33 | 33 | #include "parser/file_parser.hpp" |
34 | 34 | #include "util/debug.hpp" |
| 35 | +#include "util/logger.hpp" |
35 | 36 |
|
36 | 37 | namespace SBG { |
37 | 38 |
|
@@ -64,29 +65,52 @@ void printHeader(Util::prog_opts::variables_map vm) |
64 | 65 | // Evaluation Executor --------------------------------------------------------- |
65 | 66 | //////////////////////////////////////////////////////////////////////////////// |
66 | 67 |
|
67 | | -EvalExecutor::EvalExecutor() : set_impl_(0) |
| 68 | +EvalExecutor::EvalExecutor() : scc_impl_(1) |
68 | 69 | { |
69 | 70 | config_.add_options() |
70 | 71 | ("set_impl,s", Util::prog_opts::value(&set_impl_), |
71 | 72 | " Desired set implementation:" |
72 | 73 | "\n - 0 for unordered sets (default option)" |
73 | 74 | "\n - 1 for ordered sets" |
74 | 75 | "\n - 2 for unidimensional ordered dense sets") |
| 76 | + ("pw_impl,p", Util::prog_opts::value(&pw_impl_), |
| 77 | + " Desired PWMap implementation:" |
| 78 | + "\n - 0 for unordered PWMaps (default option)" |
| 79 | + "\n - 1 for ordered PWMaps" |
| 80 | + "\n - 2 for domain ordered PWMaps") |
75 | 81 | ("scc_impl", Util::prog_opts::value(&scc_impl_), |
76 | 82 | "Desired SCC algorithm implementation:" |
77 | | - "\n - 0 for V1 of minimum reachable SCC (default option)" |
78 | | - "\n - 1 for V2 of minimum reachable SCC"); |
| 83 | + "\n - 0 for V1 of minimum reachable SCC" |
| 84 | + "\n - 1 for V2 of minimum reachable SCC (default option)"); |
79 | 85 |
|
80 | 86 | cmd_line_opts_.add(generic_).add(config_).add(hidden_); |
81 | 87 | cfg_file_opts_.add(config_).add(hidden_); |
82 | 88 | visible_.add(generic_).add(config_); |
83 | 89 | } |
84 | 90 |
|
85 | | -EvalUserInput EvalExecutor::gatherUserInput() |
| 91 | +EvalUserInput EvalExecutor::chooseImplementation() |
86 | 92 | { |
87 | 93 | EvalUserInput result; |
88 | 94 |
|
89 | | - result.set_set_impl(set_impl_); |
| 95 | + AutomImplVisitor autom_impl_visitor; |
| 96 | + EvalUserInput autom_impl = autom_impl_visitor.visit(Parser::parseFile( |
| 97 | + *input_file_, false)); |
| 98 | + |
| 99 | + result.set_set_impl(autom_impl.set_impl()); |
| 100 | + result.set_pw_impl(autom_impl.pw_impl()); |
| 101 | + |
| 102 | + if (set_impl_) { |
| 103 | + if (set_impl_ > autom_impl.set_impl()) |
| 104 | + Util::ERROR("Incompatible set implementation for the SBG input\n"); |
| 105 | + |
| 106 | + result.set_set_impl(set_impl_); |
| 107 | + } |
| 108 | + if (pw_impl_) { |
| 109 | + if (pw_impl_ > autom_impl.pw_impl()) |
| 110 | + Util::ERROR("Incompatible PW implementation for the SBG input\n"); |
| 111 | + |
| 112 | + result.set_pw_impl(pw_impl_); |
| 113 | + } |
90 | 114 | result.set_scc_impl(scc_impl_); |
91 | 115 |
|
92 | 116 | return result; |
@@ -130,14 +154,12 @@ void EvalExecutor::execute(int arg_count, char* args[]) |
130 | 154 |
|
131 | 155 | // Input SBG program file handling ------------------------------------------- |
132 | 156 |
|
133 | | - if (input_file_) { |
134 | | - AutomImplVisitor autom_impl; |
135 | | - std::streambuf* old_cout_buffer = std::cout.rdbuf(); |
136 | | - std::cout.rdbuf(nullptr); |
137 | | - autom_impl.visit(Parser::parseFile(*input_file_)); |
138 | | - std::cout.rdbuf(old_cout_buffer); |
| 157 | + if (vm.count("debug")) { |
| 158 | + Util::SBGLogger::instance().setLevel(Util::LogLevel::Debug); |
| 159 | + } |
139 | 160 |
|
140 | | - EvalUserInput input = gatherUserInput(); |
| 161 | + if (input_file_) { |
| 162 | + EvalUserInput input = chooseImplementation(); |
141 | 163 | InputTranslator input_translator; |
142 | 164 | input_translator.translate(input); |
143 | 165 | ProgramIO eval_result = parseEvalFile(*input_file_); |
|
0 commit comments