From ae9d5fd328b2cf0e015bab5165910832b9e79302 Mon Sep 17 00:00:00 2001 From: CUB3D Date: Mon, 5 Apr 2021 01:26:04 +0100 Subject: [PATCH] avm2: Implement Op::Li32 --- core/src/avm2/activation.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/src/avm2/activation.rs b/core/src/avm2/activation.rs index 2b0c44a71..44416961d 100644 --- a/core/src/avm2/activation.rs +++ b/core/src/avm2/activation.rs @@ -701,6 +701,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { Op::Si32 => self.op_si32(), Op::Li8 => self.op_li8(), Op::Li16 => self.op_li16(), + Op::Li32 => self.op_li32(), _ => self.unknown_op(op), }; @@ -2597,6 +2598,26 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { Ok(FrameControl::Continue) } + /// Implements `Op::Li32` + fn op_li32(&mut self) -> Result, 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+4); + drop(dm); + + if let Some(val) = val { + self.context.avm2.push(Value::Integer( + (val[0] as i32) | ((val[1] as i32) << 8) | ((val[2] as i32) << 16) | ((val[3] as i32) << 24) + )); + } else { + return Err("RangeError: The specified range is invalid".into()); + } + + Ok(FrameControl::Continue) + } + #[allow(unused_variables)] #[cfg(avm_debug)] fn op_debug(