use fix_runtime::Machine; use crate::{BytecodeReader, Mutation, Step, Value}; #[inline(always)] #[expect( clippy::indexing_slicing, reason = "local slot index is produced by codegen and bounded by the frame's AllocLocals count" )] pub(crate) fn op_load_local<'gc, M: Machine<'gc>>( m: &mut M, reader: &mut BytecodeReader<'_>, ) -> Step { let idx = reader.read_u32() as usize; m.push(m.env().borrow().locals[idx]); Step::Continue(()) } #[inline(always)] #[expect( clippy::indexing_slicing, reason = "local slot index is produced by codegen and bounded by the target frame's AllocLocals count" )] pub(crate) fn op_load_outer<'gc, M: Machine<'gc>>( m: &mut M, reader: &mut BytecodeReader<'_>, ) -> Step { let layer = reader.read_u8(); let idx = reader.read_u32() as usize; let mut cur = m.env(); for _ in 0..layer { let prev = cur.borrow().prev.expect("LoadOuter: env chain too short"); cur = prev; } let val = cur.borrow().locals[idx]; m.push(val); Step::Continue(()) } #[inline(always)] #[expect( clippy::indexing_slicing, reason = "local slot index is produced by codegen and bounded by the frame's AllocLocals count" )] pub(crate) fn op_store_local<'gc, M: Machine<'gc>>( m: &mut M, reader: &mut BytecodeReader<'_>, mc: &Mutation<'gc>, ) -> Step { let idx = reader.read_u32() as usize; let val = m.pop(); m.env().borrow_mut(mc).locals[idx] = val; Step::Continue(()) } #[inline(always)] pub(crate) fn op_alloc_locals<'gc, M: Machine<'gc>>( m: &mut M, reader: &mut BytecodeReader<'_>, mc: &Mutation<'gc>, ) -> Step { let count = reader.read_u32() as usize; m.env() .borrow_mut(mc) .locals .extend(std::iter::repeat_n(Value::default(), count)); Step::Continue(()) }