Skip to content

Commit 2a86f96

Browse files
authored
Merge pull request #164 from sunjay/pc-debug
More useful debug implementation for ProgramClause and ProgramClauseImplication
2 parents 62038e0 + 6ebb59c commit 2a86f96

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/ir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,13 +959,13 @@ impl<V: IntoIterator> Iterator for BindersIntoIterator<V> {
959959
/// Represents one clause of the form `consequence :- conditions` where
960960
/// `conditions = cond_1 && cond_2 && ...` is the conjunction of the individual
961961
/// conditions.
962-
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
962+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
963963
pub struct ProgramClauseImplication {
964964
crate consequence: DomainGoal,
965965
crate conditions: Vec<Goal>,
966966
}
967967

968-
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
968+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
969969
pub enum ProgramClause {
970970
Implies(ProgramClauseImplication),
971971
ForAll(Binders<ProgramClauseImplication>),

src/ir/debug.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,32 @@ impl<T: Debug> Debug for Binders<T> {
291291
}
292292
}
293293

294+
impl Debug for ProgramClause {
295+
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
296+
match self {
297+
ProgramClause::Implies(pc) => write!(fmt, "{:?}", pc),
298+
ProgramClause::ForAll(pc) => write!(fmt, "{:?}", pc),
299+
}
300+
}
301+
}
302+
303+
impl Debug for ProgramClauseImplication {
304+
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
305+
write!(fmt, "{:?}", self.consequence)?;
306+
307+
let conds = self.conditions.len();
308+
if conds == 0 {
309+
return Ok(());
310+
}
311+
312+
write!(fmt, " :- ")?;
313+
for cond in &self.conditions[..conds - 1] {
314+
write!(fmt, "{:?}, ", cond)?;
315+
}
316+
write!(fmt, "{:?}", self.conditions[conds - 1])
317+
}
318+
}
319+
294320
impl Debug for Environment {
295321
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
296322
write!(fmt, "Env({:?})", self.clauses)

0 commit comments

Comments
 (0)