avm2: Implement Op::Lf64

This commit is contained in:
CUB3D 2021-04-07 18:10:49 +01:00 committed by Mike Welsh
parent b4736413fa
commit 9ffa4f1f50
1 changed files with 23 additions and 0 deletions

View File

@ -705,6 +705,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
Op::Li16 => self.op_li16(),
Op::Li32 => self.op_li32(),
Op::Lf32 => self.op_lf32(),
Op::Lf64 => self.op_lf64(),
_ => self.unknown_op(op),
};
@ -2677,6 +2678,28 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
Ok(FrameControl::Continue)
}
/// Implements `Op::Lf64`
fn op_lf64(&mut self) -> Result<FrameControl<'gc>, Error> {
let address = self.context.avm2.pop().coerce_to_u32(self)? as usize;
let dm = self.domain_memory().expect("Not domain memory?");
let r = dm.read();
let val = r.get_range(address..address + 8);
drop(dm);
if let Some(val) = val {
let buf: [u8; 8] = [val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]];
self.context
.avm2
.push(Value::Number(f64::from_le_bytes(buf)));
} else {
return Err("RangeError: The specified range is invalid".into());
}
Ok(FrameControl::Continue)
}
#[allow(unused_variables)]
#[cfg(avm_debug)]
fn op_debug(