Add band and bor operator for bit operations (#5936)

* Add `band` and `bor` Operator

* Add tests
This commit is contained in:
Justin Ma
2022-07-03 02:03:36 +08:00
committed by GitHub
parent 84caf8859f
commit b82dccf0bd
8 changed files with 91 additions and 17 deletions

View File

@ -438,6 +438,14 @@ pub fn eval_expression(
let rhs = eval_expression(engine_state, stack, rhs)?;
lhs.ends_with(op_span, &rhs, expr.span)
}
Operator::BitOr => {
let rhs = eval_expression(engine_state, stack, rhs)?;
lhs.bor(op_span, &rhs, expr.span)
}
Operator::BitAnd => {
let rhs = eval_expression(engine_state, stack, rhs)?;
lhs.band(op_span, &rhs, expr.span)
}
Operator::ShiftRight => {
let rhs = eval_expression(engine_state, stack, rhs)?;
lhs.bshr(op_span, &rhs, expr.span)