pub enum BinaryOperator {
Show 36 variants
Mul,
Div,
SignedDiv,
Mod,
SignedMod,
FloatDiv,
FloatMul,
Add,
Sub,
FloatAdd,
FloatSub,
LeftShift,
RightShift,
SignedRightShift,
SignedLessThan,
SignedGreaterThan,
SignedLessEqual,
SignedGreaterEqual,
LessEqual,
GreaterEqual,
LessThan,
GreaterThan,
FloatLessEqual,
FloatGreaterEqual,
FloatLessThan,
FloatGreaterThan,
Equal,
NotEqual,
FloatEqual,
FloatNotEqual,
LogicalXor,
LogicalAnd,
LogicalOr,
BitwiseXor,
BitwiseOr,
BitwiseAnd,
}Expand description
An infix operator in a p-code expression.
Unless a variant says otherwise, both operands and the result are the same
width, and arithmetic wraps rather than trapping. The comparisons are the
exception: they yield one byte holding 0 or 1, whatever their operands’
width. Self::is_comparison and its siblings classify a variant without
having to match all thirty-six.
Variants§
Mul
* — multiplication. The low half of the product, so the same for
signed and unsigned operands.
Div
/ — unsigned division.
SignedDiv
s/ — signed division, truncating towards zero.
Mod
% — unsigned remainder.
SignedMod
s% — signed remainder, taking its sign from the dividend.
FloatDiv
f/ — floating-point division.
FloatMul
f* — floating-point multiplication.
Add
+ — addition. Two’s-complement, so the same for signed and unsigned
operands; a carry or overflow flag is computed separately, with
Builtin::Carry or
Builtin::Sborrow.
Sub
- — subtraction, likewise sign-agnostic.
FloatAdd
f+ — floating-point addition.
FloatSub
f- — floating-point subtraction.
LeftShift
<< — left shift. Bits shifted off the top are discarded.
RightShift
>> — logical right shift, shifting in zeroes.
SignedRightShift
s>> — arithmetic right shift, shifting in copies of the sign bit.
SignedLessThan
s< — signed less-than.
SignedGreaterThan
s> — signed greater-than.
SignedLessEqual
s<= — signed less-than-or-equal.
SignedGreaterEqual
s>= — signed greater-than-or-equal.
LessEqual
<= — unsigned less-than-or-equal.
GreaterEqual
>= — unsigned greater-than-or-equal.
LessThan
< — unsigned less-than.
GreaterThan
> — unsigned greater-than.
FloatLessEqual
f<= — floating-point less-than-or-equal.
FloatGreaterEqual
f>= — floating-point greater-than-or-equal.
FloatLessThan
f< — floating-point less-than.
FloatGreaterThan
f> — floating-point greater-than.
Equal
== — bitwise equality. Sign-agnostic, since two’s-complement
equality is bit equality.
NotEqual
!= — bitwise inequality.
FloatEqual
f== — floating-point equality, which is not bit equality: NaN
compares unequal to itself, and the two zeroes compare equal.
FloatNotEqual
f!= — floating-point inequality.
LogicalXor
^^ — boolean exclusive-or. Operands are read as false when zero and
true otherwise; the result is one byte.
LogicalAnd
&& — boolean and. One byte, and not short-circuiting: p-code has
no control flow inside an expression, so both operands are evaluated.
LogicalOr
|| — boolean or, likewise one byte and not short-circuiting.
BitwiseXor
^ — bitwise exclusive-or, in the width of the operands.
BitwiseOr
| — bitwise or.
BitwiseAnd
& — bitwise and.
Implementations§
Source§impl BinaryOperator
impl BinaryOperator
Sourcepub fn is_comparison(self) -> bool
pub fn is_comparison(self) -> bool
Does this operator yield a one-byte boolean rather than a value in the width of its operands?
Sourcepub fn is_shift(self) -> bool
pub fn is_shift(self) -> bool
Is this a shift, whose right operand is a distance rather than a value of the same width?
Sourcepub fn is_signed_comparison(self) -> bool
pub fn is_signed_comparison(self) -> bool
Is this one of the four comparisons that read their operands as two’s-complement signed integers?
Sourcepub fn is_float_comparison(self) -> bool
pub fn is_float_comparison(self) -> bool
Is this one of the six comparisons that read their operands as floating-point?
Sourcepub fn is_float(self) -> bool
pub fn is_float(self) -> bool
Does this operator read its operands as floating-point, whether it compares them or computes with them?
Sourcepub fn is_logical(self) -> bool
pub fn is_logical(self) -> bool
Is this a boolean connective (&&, ||, ^^) rather than a bitwise
one? Both operands and the result are truth values, one byte wide.
Sourcepub fn is_signed_integer(self) -> bool
pub fn is_signed_integer(self) -> bool
Does this operator read its operands as two’s-complement signed
integers? Covers the signed comparisons plus s/, s% and s>>.
pub fn pretty_print(self) -> &'static str
Trait Implementations§
Source§impl Clone for BinaryOperator
impl Clone for BinaryOperator
Source§fn clone(&self) -> BinaryOperator
fn clone(&self) -> BinaryOperator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more