Struct falcon::il::Constant [−][src]
pub struct Constant { /* fields omitted */ }
A constant value for Falcon IL
IL Constants in Falcon are backed by both rust's u64
primitive, and
BigUint
from the num-bigint
crate. This allows modelling and simulation
of instructions which must operate on values >64 bits in size. When a
Constant has 64 or less bits, the u64
will be used, incurring minimal
performance overhead.
The Falcon IL Expression operations are provided as methods over Constant
.
Methods
impl Constant
[src]
impl Constant
pub fn new(value: u64, bits: usize) -> Constant
[src]
pub fn new(value: u64, bits: usize) -> Constant
Create a new Constant
with the given value and bitness.
pub fn new_big(value: BigUint, bits: usize) -> Constant
[src]
pub fn new_big(value: BigUint, bits: usize) -> Constant
Create a new Constant
from the given BigUint
.
pub fn from_decimal_string(s: &String, bits: usize) -> Result<Constant>
[src]
pub fn from_decimal_string(s: &String, bits: usize) -> Result<Constant>
Crates a constant from a decimal string of the value
pub fn new_zero(bits: usize) -> Constant
[src]
pub fn new_zero(bits: usize) -> Constant
Create a new Constant
with the given bits and a value of zero
pub fn value_u64(&self) -> Option<u64>
[src]
pub fn value_u64(&self) -> Option<u64>
Get the value of this Constant
if it is a u64
.
pub fn value_i64(&self) -> Option<i64>
[src]
pub fn value_i64(&self) -> Option<i64>
Sign-extend the constant out to 64-bits, and return it as an i64
pub fn value(&self) -> &BigUint
[src]
pub fn value(&self) -> &BigUint
Get the value of this Constant
if it is a BigUint
.
pub fn bits(&self) -> usize
[src]
pub fn bits(&self) -> usize
Get the number of bits for this Constant
.
pub fn is_zero(&self) -> bool
[src]
pub fn is_zero(&self) -> bool
Returns true if the value in this Constant is 0, false otherwise.
pub fn is_one(&self) -> bool
[src]
pub fn is_one(&self) -> bool
Returns true if the value in this constant is 1, false otherwise.
pub fn add(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn add(&self, rhs: &Constant) -> Result<Constant>
pub fn sub(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn sub(&self, rhs: &Constant) -> Result<Constant>
pub fn mul(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn mul(&self, rhs: &Constant) -> Result<Constant>
pub fn divu(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn divu(&self, rhs: &Constant) -> Result<Constant>
pub fn modu(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn modu(&self, rhs: &Constant) -> Result<Constant>
pub fn divs(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn divs(&self, rhs: &Constant) -> Result<Constant>
pub fn mods(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn mods(&self, rhs: &Constant) -> Result<Constant>
pub fn and(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn and(&self, rhs: &Constant) -> Result<Constant>
pub fn or(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn or(&self, rhs: &Constant) -> Result<Constant>
pub fn xor(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn xor(&self, rhs: &Constant) -> Result<Constant>
pub fn shl(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn shl(&self, rhs: &Constant) -> Result<Constant>
pub fn shr(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn shr(&self, rhs: &Constant) -> Result<Constant>
pub fn cmpeq(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn cmpeq(&self, rhs: &Constant) -> Result<Constant>
pub fn cmpneq(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn cmpneq(&self, rhs: &Constant) -> Result<Constant>
pub fn cmpltu(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn cmpltu(&self, rhs: &Constant) -> Result<Constant>
pub fn cmplts(&self, rhs: &Constant) -> Result<Constant>
[src]
pub fn cmplts(&self, rhs: &Constant) -> Result<Constant>
pub fn trun(&self, bits: usize) -> Result<Constant>
[src]
pub fn trun(&self, bits: usize) -> Result<Constant>
pub fn zext(&self, bits: usize) -> Result<Constant>
[src]
pub fn zext(&self, bits: usize) -> Result<Constant>
pub fn sext(&self, bits: usize) -> Result<Constant>
[src]
pub fn sext(&self, bits: usize) -> Result<Constant>
Trait Implementations
impl Clone for Constant
[src]
impl Clone for Constant
fn clone(&self) -> Constant
[src]
fn clone(&self) -> Constant
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Constant
[src]
impl Debug for Constant
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Eq for Constant
[src]
impl Eq for Constant
impl Hash for Constant
[src]
impl Hash for Constant
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Ord for Constant
[src]
impl Ord for Constant
fn cmp(&self, other: &Constant) -> Ordering
[src]
fn cmp(&self, other: &Constant) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl PartialEq for Constant
[src]
impl PartialEq for Constant
fn eq(&self, other: &Constant) -> bool
[src]
fn eq(&self, other: &Constant) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Constant) -> bool
[src]
fn ne(&self, other: &Constant) -> bool
This method tests for !=
.
impl PartialOrd for Constant
[src]
impl PartialOrd for Constant
fn partial_cmp(&self, other: &Constant) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Constant) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Constant) -> bool
[src]
fn lt(&self, other: &Constant) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Constant) -> bool
[src]
fn le(&self, other: &Constant) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Constant) -> bool
[src]
fn gt(&self, other: &Constant) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Constant) -> bool
[src]
fn ge(&self, other: &Constant) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Display for Constant
[src]
impl Display for Constant
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Into<Expression> for Constant
[src]
impl Into<Expression> for Constant
fn into(self) -> Expression
[src]
fn into(self) -> Expression
Performs the conversion.
impl Value for Constant
[src]
impl Value for Constant
fn constant(constant: Constant) -> Self
[src]
fn constant(constant: Constant) -> Self
Turn an il::Constant into a representation of this Value
fn bits(&self) -> usize
[src]
fn bits(&self) -> usize
Return the number of bits contained in this value
fn shl(&self, bits: usize) -> Result<Self>
[src]
fn shl(&self, bits: usize) -> Result<Self>
Shift the value left by the given number of bits
fn shr(&self, bits: usize) -> Result<Self>
[src]
fn shr(&self, bits: usize) -> Result<Self>
Shift the value right by the given number of bits
fn trun(&self, bits: usize) -> Result<Self>
[src]
fn trun(&self, bits: usize) -> Result<Self>
Truncate the value to the given number of bits
fn zext(&self, bits: usize) -> Result<Self>
[src]
fn zext(&self, bits: usize) -> Result<Self>
Zero-extend the value to the given number of bits
fn or(&self, other: &Self) -> Result<Self>
[src]
fn or(&self, other: &Self) -> Result<Self>
Or this value with the given value