rulegen:: (some) controllable debug flags

This commit is contained in:
Zeno Rogue 2022-08-17 17:33:36 +02:00
parent ca315c2582
commit ecee5b7f21
1 changed files with 18 additions and 4 deletions

View File

@ -94,6 +94,9 @@ static const flagtype w_skip_transducer_terminate = Flag(34); /*< skip terminati
static const flagtype w_r3_all_errors = Flag(35); /*< consider all errors for R3 */ static const flagtype w_r3_all_errors = Flag(35); /*< consider all errors for R3 */
#endif #endif
/** these control the output */
EX flagtype rdebug_flags;
EX int honeycomb_value = 1; /* how far to build local for honeycombs */ EX int honeycomb_value = 1; /* how far to build local for honeycombs */
EX flagtype flags = 0; EX flagtype flags = 0;
@ -1893,6 +1896,12 @@ EX void clean_parents() {
while(c) { c->parent_dir = MYSTERY; c = c->next; } while(c) { c->parent_dir = MYSTERY; c = c->next; }
} }
int qshortcuts() {
int res = 0;
for(auto& sh: shortcuts) res += isize(sh);
return res;
}
void clear_treestates() { void clear_treestates() {
treestates.clear(); treestates.clear();
for(auto a: all_analyzers) for(auto a: all_analyzers)
@ -1910,7 +1919,7 @@ EX void rules_iteration() {
clean_parents(); clean_parents();
} }
if(debugflags & DF_GEOM) println(hlog, "attempt: ", try_count, " important = ", isize(important), " cells = ", tcellcount); if(rdebug_flags & 1) println(hlog, "attempt: ", try_count, " important = ", isize(important), " cells = ", tcellcount, " shortcuts = ", qshortcuts());
parent_updates = 0; parent_updates = 0;
clear_treestates(); clear_treestates();
@ -1918,7 +1927,7 @@ EX void rules_iteration() {
cq = important; cq = important;
if(debugflags & DF_GEOM) if(rdebug_flags & 2)
println(hlog, "important = ", cq); println(hlog, "important = ", cq);
for(int i=0; i<isize(cq); i++) { for(int i=0; i<isize(cq); i++) {
@ -1960,7 +1969,7 @@ EX void rules_iteration() {
treestates[id].is_live = false, new_deadends++; treestates[id].is_live = false, new_deadends++;
} }
if(debugflags & DF_GEOM) if(rdebug_flags & 4)
println(hlog, "deadend states found: ", new_deadends); println(hlog, "deadend states found: ", new_deadends);
} }
@ -2193,7 +2202,7 @@ EX void rule_iterations() {
break; break;
} }
catch(rulegen_retry& e) { catch(rulegen_retry& e) {
if(debugflags & DF_GEOM) if(rdebug_flags & 8)
println(hlog, "result ", try_count, ": ", e.what()); println(hlog, "result ", try_count, ": ", e.what());
if(try_count >= max_retries) throw; if(try_count >= max_retries) throw;
} }
@ -2638,6 +2647,11 @@ int readRuleArgs() {
rulegen::flags ^= Flag(argi()); rulegen::flags ^= Flag(argi());
} }
else if(argis("-ruledflags")) {
shift();
rulegen::rdebug_flags = argi();
}
else return 1; else return 1;
return 0; return 0;
} }