Skip to content

Commit

Permalink
ir: do not print bv literal or symbol nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Nov 14, 2023
1 parent 5ea62f5 commit 7c9b211
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
10 changes: 8 additions & 2 deletions src/ir/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ impl SerializableIrNode for TransitionSystem {
// do not explicitly print states
.filter(|(_, s)| !matches!(s.kind, SignalKind::State))
{
// we deduce the expression id from the index
let expr = ctx.get(ExprRef::from_index(ii));

// skip symbols and literals
if expr.is_symbol(ctx) || expr.is_bv_lit(ctx) {
continue;
}

// print the kind
write!(writer, "{} ", signal.kind)?;

Expand All @@ -304,8 +312,6 @@ impl SerializableIrNode for TransitionSystem {
} else {
write!(writer, "%{}", ii)?;
}
// we deduce the expression id from the index
let expr = ExprRef::from_index(ii);

// print the type
let tpe = expr.get_type(ctx);
Expand Down
21 changes: 15 additions & 6 deletions src/ir/smt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ impl Expr {

pub trait ExprIntrospection {
fn is_symbol(&self, ctx: &impl GetNode<Expr, ExprRef>) -> bool;
fn is_bv_lit(&self, _ctx: &impl GetNode<Expr, ExprRef>) -> bool;
fn get_symbol_name<'a>(
&self,
ctx: &'a (impl GetNode<Expr, ExprRef> + GetNode<str, StringRef>),
Expand All @@ -362,12 +363,8 @@ impl ExprIntrospection for Expr {
matches!(self, Expr::BVSymbol { .. } | Expr::ArraySymbol { .. })
}

fn get_symbol_name_ref(&self, _ctx: &impl GetNode<Expr, ExprRef>) -> Option<StringRef> {
match self {
Expr::BVSymbol { name, .. } => Some(*name),
Expr::ArraySymbol { name, .. } => Some(*name),
_ => None,
}
fn is_bv_lit(&self, _ctx: &impl GetNode<Expr, ExprRef>) -> bool {
matches!(self, Expr::BVLiteral { .. })
}

fn get_symbol_name<'a>(
Expand All @@ -376,13 +373,25 @@ impl ExprIntrospection for Expr {
) -> Option<&'a str> {
self.get_symbol_name_ref(ctx).map(|r| ctx.get(r))
}

fn get_symbol_name_ref(&self, _ctx: &impl GetNode<Expr, ExprRef>) -> Option<StringRef> {
match self {
Expr::BVSymbol { name, .. } => Some(*name),
Expr::ArraySymbol { name, .. } => Some(*name),
_ => None,
}
}
}

impl ExprIntrospection for ExprRef {
fn is_symbol(&self, ctx: &impl GetNode<Expr, ExprRef>) -> bool {
ctx.get(*self).is_symbol(ctx)
}

fn is_bv_lit(&self, ctx: &impl GetNode<Expr, ExprRef>) -> bool {
ctx.get(*self).is_bv_lit(ctx)
}

fn get_symbol_name_ref(&self, ctx: &impl GetNode<Expr, ExprRef>) -> Option<StringRef> {
ctx.get(*self).get_symbol_name_ref(ctx)
}
Expand Down

0 comments on commit 7c9b211

Please sign in to comment.