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

Method exec_shr

compiler/src/modules/vm/handlers/arith.rs:332–339  ·  view source on GitHub ↗
(&mut self, a: Val, b: Val)

Source from the content-addressed store, hash-verified

330 }
331
332 fn exec_shr(&mut self, a: Val, b: Val) -> Result<Val, VmErr> {
333 if !b.is_int() { return Err(cold_type("shift count must be an integer")); }
334 let shift = b.as_int();
335 if shift < 0 { return Err(cold_value("negative shift count")); }
336 let ai = self.as_i128(a).ok_or(cold_type(">> requires an integer"))?;
337 // i128 >> is arithmetic (floor on negatives); `.min(127)` dodges shift-count UB.
338 self.int_to_val(Some(ai >> shift.min(127)))
339 }
340
341 pub(crate) fn handle_compare(&mut self, op: OpCode, rip: usize, cache: &mut OpcodeCache, chunk: &SSAChunk, slots: &mut [Val]) -> Result<(), VmErr> {
342 let (a, b) = self.pop2()?;

Callers 1

handle_bitwiseMethod · 0.80

Calls 6

cold_typeFunction · 0.85
cold_valueFunction · 0.85
is_intMethod · 0.80
as_intMethod · 0.80
as_i128Method · 0.80
int_to_valMethod · 0.80

Tested by

no test coverage detected