51 lines
1.5 KiB
Rust
51 lines
1.5 KiB
Rust
use crate::{BytecodeReader, Mutation, Step, Value};
|
|
|
|
impl<'gc> crate::Vm<'gc> {
|
|
#[inline(always)]
|
|
pub(crate) fn op_load_local(&mut self, reader: &mut BytecodeReader<'_>) -> Step {
|
|
let idx = reader.read_u32() as usize;
|
|
self.push(self.env.borrow().locals[idx]);
|
|
Step::Continue(())
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn op_load_outer(&mut self, reader: &mut BytecodeReader<'_>) -> Step {
|
|
let layer = reader.read_u8();
|
|
let idx = reader.read_u32() as usize;
|
|
let mut cur = self.env;
|
|
for _ in 0..layer {
|
|
let prev = cur.borrow().prev.expect("LoadOuter: env chain too short");
|
|
cur = prev;
|
|
}
|
|
let val = cur.borrow().locals[idx];
|
|
self.push(val);
|
|
Step::Continue(())
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn op_store_local(
|
|
&mut self,
|
|
reader: &mut BytecodeReader<'_>,
|
|
mc: &Mutation<'gc>,
|
|
) -> Step {
|
|
let idx = reader.read_u32() as usize;
|
|
let val = self.pop();
|
|
self.env.borrow_mut(mc).locals[idx] = val;
|
|
Step::Continue(())
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn op_alloc_locals(
|
|
&mut self,
|
|
reader: &mut BytecodeReader<'_>,
|
|
mc: &Mutation<'gc>,
|
|
) -> Step {
|
|
let count = reader.read_u32() as usize;
|
|
self.env
|
|
.borrow_mut(mc)
|
|
.locals
|
|
.extend(std::iter::repeat_n(Value::default(), count));
|
|
Step::Continue(())
|
|
}
|
|
}
|