mirror of
https://github.com/Z3Prover/z3
synced 2025-06-27 08:28:44 +00:00
nicer lit_pp
This commit is contained in:
parent
a4f0e3a228
commit
4312611bd6
2 changed files with 69 additions and 21 deletions
|
@ -46,23 +46,62 @@ show_deref_t<T> show_deref(Ptr const& ptr) {
|
||||||
return show_deref_t<T>{ptr.get()};
|
return show_deref_t<T>{ptr.get()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct repeat {
|
||||||
|
unsigned count;
|
||||||
|
T const& obj;
|
||||||
|
repeat(unsigned count, T const& obj): count(count), obj(obj) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::ostream& operator<<(std::ostream& out, repeat<T> const& r) {
|
||||||
|
for (unsigned i = r.count; i-- > 0; ) {
|
||||||
|
out << r.obj;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class pad_direction {
|
||||||
|
left,
|
||||||
|
right,
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct pad {
|
||||||
|
pad_direction dir;
|
||||||
|
unsigned width;
|
||||||
|
T const& obj;
|
||||||
|
pad(pad_direction dir, unsigned width, T const& obj): dir(dir), width(width), obj(obj) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::ostream& operator<<(std::ostream& out, pad<T> const& p) {
|
||||||
|
std::stringstream tmp;
|
||||||
|
tmp << p.obj;
|
||||||
|
std::string s = tmp.str();
|
||||||
|
unsigned n = (s.length() < p.width) ? (p.width - s.length()) : 0;
|
||||||
|
switch (p.dir) {
|
||||||
|
case pad_direction::left:
|
||||||
|
out << repeat(n, ' ') << s;
|
||||||
|
break;
|
||||||
|
case pad_direction::right:
|
||||||
|
out << s << repeat(n, ' ');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
/// Fill with spaces to the right:
|
/// Fill with spaces to the right:
|
||||||
/// out << rpad(8, "hello")
|
/// out << rpad(8, "hello")
|
||||||
/// writes "hello ".
|
/// writes "hello ".
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct rpad {
|
pad<T> rpad(unsigned width, T const& obj) {
|
||||||
unsigned width;
|
return pad<T>(pad_direction::right, width, obj);
|
||||||
T const& obj;
|
}
|
||||||
rpad(unsigned width, T const& obj): width(width), obj(obj) {}
|
|
||||||
};
|
/// Fill with spaces to the left.
|
||||||
|
template <typename T>
|
||||||
template <typename T>
|
pad<T> lpad(unsigned width, T const& obj) {
|
||||||
std::ostream& operator<<(std::ostream& out, rpad<T> const& pad) {
|
return pad<T>(pad_direction::left, width, obj);
|
||||||
std::stringstream tmp;
|
|
||||||
tmp << pad.obj;
|
|
||||||
auto s = tmp.str();
|
|
||||||
out << s;
|
|
||||||
if (s.length() < pad.width)
|
|
||||||
out << std::string(pad.width - s.length(), ' ');
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -994,12 +994,21 @@ namespace polysat {
|
||||||
|
|
||||||
std::ostream& lit_pp::display(std::ostream& out) const {
|
std::ostream& lit_pp::display(std::ostream& out) const {
|
||||||
auto c = s.lit2cnstr(lit);
|
auto c = s.lit2cnstr(lit);
|
||||||
out << lit << ": " << c << " [";
|
out << lpad(4, lit) << ": " << rpad(30, c) << " [";
|
||||||
out << " bvalue=" << s.m_bvars.value(lit);
|
out << " " << s.m_bvars.value(lit);
|
||||||
if (s.m_bvars.is_assigned(lit))
|
if (s.m_bvars.is_assigned(lit)) {
|
||||||
out << " @" << s.m_bvars.level(lit);
|
out << ' ';
|
||||||
out << " pwatched=" << c->is_pwatched();
|
if (s.m_bvars.is_assumption(lit))
|
||||||
out << " ]";
|
out << "assert";
|
||||||
|
else if (s.m_bvars.is_bool_propagation(lit))
|
||||||
|
out << "bprop";
|
||||||
|
else if (s.m_bvars.is_value_propagation(lit))
|
||||||
|
out << "eval";
|
||||||
|
out << '@' << s.m_bvars.level(lit);
|
||||||
|
}
|
||||||
|
if (c->is_pwatched())
|
||||||
|
out << " pwatched";
|
||||||
|
out << " ]";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue