pub enum LogosInt {
Small(i64),
Big(Box<BigInt>),
}Expand description
The exact integer for GENERATED code: i64 on the fast path, spilling to a
heap logicaffeine_base::BigInt the moment a value escapes 64 bits — the
AOT’s mirror of the interpreter’s Int→BigInt promotion (and of the JIT’s
overflow side-exit). Every operation NORMALIZES: a big result that fits
i64 downsizes to Small, so representation never leaks into ==/Ord.
Variants§
Implementations§
Source§impl LogosInt
impl LogosInt
pub fn from_i64(x: i64) -> Self
pub fn from_big(b: BigInt) -> Self
Sourcepub fn from_literal(s: &str) -> Self
pub fn from_literal(s: &str) -> Self
Parse a (possibly > 64-bit) decimal literal the codegen emitted.
Sourcepub fn wrapping_u64(&self) -> u64
pub fn wrapping_u64(&self) -> u64
The low 64 bits of this integer, reduced modulo 2^64.
Sourcepub fn expect_i64(&self, what: &str) -> i64
pub fn expect_i64(&self, what: &str) -> i64
The value as i64, or a LOUD canonical error — for sinks that are
structurally 64-bit (indices, sizes, native call arguments).
pub fn add(&self, rhs: &LogosInt) -> LogosInt
pub fn sub(&self, rhs: &LogosInt) -> LogosInt
pub fn mul(&self, rhs: &LogosInt) -> LogosInt
Sourcepub fn mul_assign_i64(&mut self, rhs: i64)
pub fn mul_assign_i64(&mut self, rhs: i64)
In-place multiply by a machine-integer scalar — the exact-value equivalent of
*self = self.mul(&LogosInt::from(rhs)), but a Big accumulator mutates its heap
buffer in place instead of allocating a fresh product each call (the Set p to p * i
factorial hot loop). A Small stays on the checked fast path, promoting to Big only
on overflow. A Big never shrinks below the i64 range under a nonzero scalar, so it
stays a canonical Big; a zero scalar collapses to Small(0).
Sourcepub fn div(&self, rhs: &LogosInt) -> Result<LogosInt, String>
pub fn div(&self, rhs: &LogosInt) -> Result<LogosInt, String>
Truncating division; Err on a zero divisor (the interp’s catchable
“Division by zero”). i64::MIN / -1 promotes exactly.
Sourcepub fn div_floor(&self, rhs: &LogosInt) -> Result<LogosInt, String>
pub fn div_floor(&self, rhs: &LogosInt) -> Result<LogosInt, String>
Floor division — the quotient rounded toward NEGATIVE INFINITY (-7 // 2 → -4),
the semantics of the // operator. Distinct from div, which
truncates toward zero (-7 / 2 → -3); the two agree when the operands share a
sign. Exact (promotes to BigInt); a zero divisor is a loud error.
Sourcepub fn rem(&self, rhs: &LogosInt) -> Result<LogosInt, String>
pub fn rem(&self, rhs: &LogosInt) -> Result<LogosInt, String>
Truncating remainder (sign of the dividend); i64::MIN % -1 is 0.
Sourcepub fn pow(&self, exp: &LogosInt) -> Result<LogosInt, String>
pub fn pow(&self, exp: &LogosInt) -> Result<LogosInt, String>
Exponentiation with an integer exponent. Err on a negative exponent
(an Int can’t hold the fractional result) or one too large to be a
u32 power; overflow of the i64 fast path promotes to BigInt
exactly. Mirrors the interpreter’s int_power.
pub fn neg(&self) -> LogosInt
Trait Implementations§
Source§impl ContractReason for LogosInt
impl ContractReason for LogosInt
Source§fn contract_reason(&self) -> String
fn contract_reason(&self) -> String
Source§impl DecimalArg for LogosInt
impl DecimalArg for LogosInt
fn into_decimal(self) -> LogosDecimal
Source§impl Default for LogosInt
Zero, so a struct holding a promoted Int can still #[derive(Default)] — the AOT-Rust
struct codegen always derives it and constructs with ..Default::default().
impl Default for LogosInt
Zero, so a struct holding a promoted Int can still #[derive(Default)] — the AOT-Rust
struct codegen always derives it and constructs with ..Default::default().
Source§impl FailureText for LogosInt
impl FailureText for LogosInt
fn failure_text(&self) -> String
Source§impl From<LogosInt> for LogosRational
impl From<LogosInt> for LogosRational
Source§impl From<LogosInt> for LogosValue
impl From<LogosInt> for LogosValue
Source§impl Ord for LogosInt
impl Ord for LogosInt
Source§impl PartialOrd<LogosInt> for i64
impl PartialOrd<LogosInt> for i64
Source§impl PartialOrd<i64> for LogosInt
impl PartialOrd<i64> for LogosInt
Source§impl PartialOrd for LogosInt
impl PartialOrd for LogosInt
impl Eq for LogosInt
Auto Trait Implementations§
impl Freeze for LogosInt
impl RefUnwindSafe for LogosInt
impl Send for LogosInt
impl Sync for LogosInt
impl Unpin for LogosInt
impl UnsafeUnpin for LogosInt
impl UnwindSafe for LogosInt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.