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

Method exec_pos

compiler/src/modules/vm/handlers/arith.rs:100–118  ·  view source on GitHub ↗
(&mut self, rip: usize, cache: &mut OpcodeCache, chunk: &SSAChunk, slots: &mut [Val])

Source from the content-addressed store, hash-verified

98 }
99
100 fn exec_pos(&mut self, rip: usize, cache: &mut OpcodeCache, chunk: &SSAChunk, slots: &mut [Val]) -> Result<(), VmErr> {
101 let v = self.pop()?;
102 // instance `__pos__` takes precedence over numeric coercion.
103 if let Some(r) = self.try_call_dunder(v, "__pos__", &[], chunk, slots)? {
104 self.record_dunder_hit(rip, cache, v, "__pos__", 1);
105 self.push(r);
106 return Ok(());
107 }
108 let result = if v.is_float() {
109 v
110 } else if let Some(i) = self.as_i128(v) {
111 // bool drops its tag to int; plain ints round-trip unchanged.
112 self.int_to_val(Some(i))?
113 } else {
114 return Err(cold_type("unary + requires a number"));
115 };
116 self.push(result);
117 Ok(())
118 }
119
120 fn exec_mod(&mut self, a: Val, b: Val, chunk: &SSAChunk, slots: &mut [Val]) -> Result<Val, VmErr> {
121 // `str % args` is printf-style formatting, not modulo.

Callers 1

handle_arithMethod · 0.80

Calls 8

cold_typeFunction · 0.85
try_call_dunderMethod · 0.80
record_dunder_hitMethod · 0.80
pushMethod · 0.80
is_floatMethod · 0.80
as_i128Method · 0.80
int_to_valMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected