Skip to content

Commit df55e87

Browse files
author
Daniel Kroening
committed
replication_exprt now gets a constant_exprt
When doing replication the number of times we replicate must be a constant. This change now uses a constant_exprt to type the number of times.
1 parent 4dc7725 commit df55e87

File tree

1 file changed

+74
-76
lines changed

1 file changed

+74
-76
lines changed

src/util/std_expr.h

Lines changed: 74 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,82 +2953,6 @@ class lshr_exprt:public shift_exprt
29532953
}
29542954
};
29552955

2956-
/// \brief Bit-vector replication
2957-
class replication_exprt:public binary_exprt
2958-
{
2959-
public:
2960-
DEPRECATED("use replication_exprt(times, value) instead")
2961-
replication_exprt():binary_exprt(ID_replication)
2962-
{
2963-
}
2964-
2965-
DEPRECATED("use replication_exprt(times, value) instead")
2966-
explicit replication_exprt(const typet &_type):
2967-
binary_exprt(ID_replication, _type)
2968-
{
2969-
}
2970-
2971-
replication_exprt(const exprt &_times, const exprt &_src):
2972-
binary_exprt(_times, ID_replication, _src)
2973-
{
2974-
}
2975-
2976-
exprt &times()
2977-
{
2978-
return op0();
2979-
}
2980-
2981-
const exprt &times() const
2982-
{
2983-
return op0();
2984-
}
2985-
2986-
exprt &op()
2987-
{
2988-
return op1();
2989-
}
2990-
2991-
const exprt &op() const
2992-
{
2993-
return op1();
2994-
}
2995-
};
2996-
2997-
/// \brief Cast an exprt to a \ref replication_exprt
2998-
///
2999-
/// \a expr must be known to be \ref replication_exprt.
3000-
///
3001-
/// \param expr: Source expression
3002-
/// \return Object of type \ref replication_exprt
3003-
inline const replication_exprt &to_replication_expr(const exprt &expr)
3004-
{
3005-
PRECONDITION(expr.id()==ID_replication);
3006-
DATA_INVARIANT(
3007-
expr.operands().size()==2,
3008-
"Bit-wise replication must have two operands");
3009-
return static_cast<const replication_exprt &>(expr);
3010-
}
3011-
3012-
/// \copydoc to_replication_expr(const exprt &)
3013-
inline replication_exprt &to_replication_expr(exprt &expr)
3014-
{
3015-
PRECONDITION(expr.id()==ID_replication);
3016-
DATA_INVARIANT(
3017-
expr.operands().size()==2,
3018-
"Bit-wise replication must have two operands");
3019-
return static_cast<replication_exprt &>(expr);
3020-
}
3021-
3022-
template<> inline bool can_cast_expr<replication_exprt>(const exprt &base)
3023-
{
3024-
return base.id()==ID_replication;
3025-
}
3026-
inline void validate_expr(const replication_exprt &value)
3027-
{
3028-
validate_operands(value, 2, "Bit-wise replication must have two operands");
3029-
}
3030-
3031-
30322956
/// \brief Extracts a single bit of a bit-vector operand
30332957
class extractbit_exprt:public binary_predicate_exprt
30342958
{
@@ -4420,6 +4344,80 @@ class null_pointer_exprt:public constant_exprt
44204344
}
44214345
};
44224346

4347+
/// \brief Bit-vector replication
4348+
class replication_exprt : public binary_exprt
4349+
{
4350+
public:
4351+
DEPRECATED("use replication_exprt(times, value) instead")
4352+
replication_exprt() : binary_exprt(ID_replication)
4353+
{
4354+
}
4355+
4356+
DEPRECATED("use replication_exprt(times, value) instead")
4357+
explicit replication_exprt(const typet &_type)
4358+
: binary_exprt(ID_replication, _type)
4359+
{
4360+
}
4361+
4362+
replication_exprt(const constant_exprt &_times, const exprt &_src)
4363+
: binary_exprt(_times, ID_replication, _src)
4364+
{
4365+
}
4366+
4367+
constant_exprt &times()
4368+
{
4369+
return static_cast<constant_exprt &>(op0());
4370+
}
4371+
4372+
const constant_exprt &times() const
4373+
{
4374+
return static_cast<const constant_exprt &>(op0());
4375+
}
4376+
4377+
exprt &op()
4378+
{
4379+
return op1();
4380+
}
4381+
4382+
const exprt &op() const
4383+
{
4384+
return op1();
4385+
}
4386+
};
4387+
4388+
/// \brief Cast an exprt to a \ref replication_exprt
4389+
///
4390+
/// \a expr must be known to be \ref replication_exprt.
4391+
///
4392+
/// \param expr: Source expression
4393+
/// \return Object of type \ref replication_exprt
4394+
inline const replication_exprt &to_replication_expr(const exprt &expr)
4395+
{
4396+
PRECONDITION(expr.id() == ID_replication);
4397+
DATA_INVARIANT(
4398+
expr.operands().size() == 2, "Bit-wise replication must have two operands");
4399+
return static_cast<const replication_exprt &>(expr);
4400+
}
4401+
4402+
/// \copydoc to_replication_expr(const exprt &)
4403+
inline replication_exprt &to_replication_expr(exprt &expr)
4404+
{
4405+
PRECONDITION(expr.id() == ID_replication);
4406+
DATA_INVARIANT(
4407+
expr.operands().size() == 2, "Bit-wise replication must have two operands");
4408+
return static_cast<replication_exprt &>(expr);
4409+
}
4410+
4411+
template <>
4412+
inline bool can_cast_expr<replication_exprt>(const exprt &base)
4413+
{
4414+
return base.id() == ID_replication;
4415+
}
4416+
inline void validate_expr(const replication_exprt &value)
4417+
{
4418+
validate_operands(value, 2, "Bit-wise replication must have two operands");
4419+
}
4420+
44234421
/// \brief Concatenation of bit-vector operands
44244422
///
44254423
/// This expression takes any number of operands

0 commit comments

Comments
 (0)