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

Method checked_jump

compiler/src/modules/vm/helpers.rs:116–124  ·  view source on GitHub ↗
(&mut self, target: usize, limit: usize)

Source from the content-addressed store, hash-verified

114
115 #[inline]
116 pub(crate) fn checked_jump(&mut self, target: usize, limit: usize) -> Result<usize, VmErr> {
117 // Sandbox-off skips the budget decrement; the bounds check still runs.
118 if !self.sandbox_off {
119 if self.budget == 0 { return Err(cold_budget()); }
120 self.budget -= 1;
121 }
122 if target > limit { return Err(cold_runtime("jump target out of bounds")); }
123 Ok(target)
124 }
125
126 pub(crate) fn str_to_char_vals(&mut self, s: &str) -> Result<Vec<Val>, VmErr> {
127 // Per-char heap allocs scale with input; charge the budget so loops over this stay bounded.

Callers 1

dispatchMethod · 0.80

Calls 2

cold_budgetFunction · 0.85
cold_runtimeFunction · 0.85

Tested by

no test coverage detected