Skip to content

bv_arithmetict: Lift precondition to from_expr's interface #3513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/util/bv_arithmetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ mp_integer bv_arithmetict::pack() const
return value+power(2, spec.width);
}

exprt bv_arithmetict::to_expr() const
constant_exprt bv_arithmetict::to_expr() const
{
return constant_exprt(integer2bvrep(value, spec.width), spec.to_type());
}
Expand Down Expand Up @@ -180,10 +180,8 @@ void bv_arithmetict::change_spec(const bv_spect &dest_spec)
adjust();
}

void bv_arithmetict::from_expr(const exprt &expr)
void bv_arithmetict::from_expr(const constant_exprt &expr)
{
PRECONDITION(expr.is_constant());
spec=bv_spect(expr.type());
value = bvrep2integer(
to_constant_expr(expr).get_value(), spec.width, spec.is_signed);
value = bvrep2integer(expr.get_value(), spec.width, spec.is_signed);
}
7 changes: 4 additions & 3 deletions src/util/bv_arithmetic.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Author: Daniel Kroening, [email protected]
#include "mp_arith.h"
#include "format_spec.h"

class constant_exprt;
class exprt;
class typet;

Expand Down Expand Up @@ -60,7 +61,7 @@ class bv_arithmetict
{
}

explicit bv_arithmetict(const exprt &expr)
explicit bv_arithmetict(const constant_exprt &expr)
{
from_expr(expr);
}
Expand Down Expand Up @@ -91,8 +92,8 @@ class bv_arithmetict
std::string format(const format_spect &format_spec) const;

// expressions
exprt to_expr() const;
void from_expr(const exprt &expr);
constant_exprt to_expr() const;
void from_expr(const constant_exprt &expr);

bv_arithmetict &operator/=(const bv_arithmetict &other);
bv_arithmetict &operator*=(const bv_arithmetict &other);
Expand Down