use super::*;
impl Expression {
pub fn plus(self, rhs: Expression) -> Expression {
Expression::BinOp {
lhs: Box::new(self),
op: BinOpType::IntAdd,
rhs: Box::new(rhs),
}
}
pub fn plus_const(self, value: i64) -> Expression {
if value == 0 {
return self;
}
let bytesize = self.bytesize();
let mut value = Bitvector::from_i64(value);
match u64::from(bytesize) {
size if size > 8 => value.sign_extend(bytesize).unwrap(),
size if size < 8 => value.truncate(bytesize).unwrap(),
_ => (),
}
self.plus(Expression::Const(value))
}
}