MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / int_to_val

Method int_to_val

compiler/src/modules/vm/ops.rs:581–587  ·  view source on GitHub ↗
(&mut self, r: Option<i128>)

Source from the content-addressed store, hash-verified

579 /* Wrap an i128 into the narrowest Val: None->Overflow, 47-bit->inline, else LongInt. */
580 #[inline]
581 pub(crate) fn int_to_val(&mut self, r: Option<i128>) -> Result<Val, VmErr> {
582 let i = r.ok_or(cold_overflow())?;
583 if (Val::INT_MIN as i128..=Val::INT_MAX as i128).contains(&i) {
584 return Ok(Val::int(i as i64));
585 }
586 self.heap.alloc(HeapObj::LongInt(i))
587 }
588}
589
590/* i128 decimal render via itoa to avoid the heavier `format!` machinery on the hot path. */

Callers 15

bitwise_opMethod · 0.80
add_valsMethod · 0.80
sub_valsMethod · 0.80
mul_valsMethod · 0.80
exec_negMethod · 0.80
exec_posMethod · 0.80
exec_modMethod · 0.80
exec_floordivMethod · 0.80
handle_bitwiseMethod · 0.80
exec_shlMethod · 0.80
exec_shrMethod · 0.80
from_bytesFunction · 0.80

Calls 3

cold_overflowFunction · 0.85
containsMethod · 0.45
allocMethod · 0.45

Tested by

no test coverage detected