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

Method to_f64_coerce

compiler/src/modules/vm/ops.rs:571–577  ·  view source on GitHub ↗
(&self, v: Val)

Source from the content-addressed store, hash-verified

569 }
570
571 pub(crate) fn to_f64_coerce(&self, v: Val) -> Result<f64, VmErr> {
572 if v.is_int() { return Ok(v.as_int() as f64); }
573 if v.is_float() { return Ok(v.as_float()); }
574 if v.is_bool() { return Ok(v.as_bool() as i64 as f64); }
575 if v.is_heap() && let HeapObj::LongInt(i) = self.heap.get(v) { return Ok(*i as f64); }
576 Err(cold_type("numeric operand required"))
577 }
578
579 /* Wrap an i128 into the narrowest Val: None->Overflow, 47-bit->inline, else LongInt. */
580 #[inline]

Callers 5

div_valsMethod · 0.80
exec_modMethod · 0.80
exec_floordivMethod · 0.80
call_sumMethod · 0.80
call_divmodMethod · 0.80

Calls 9

cold_typeFunction · 0.85
is_intMethod · 0.80
as_intMethod · 0.80
is_floatMethod · 0.80
as_floatMethod · 0.80
is_boolMethod · 0.80
as_boolMethod · 0.80
is_heapMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected