From 1cc8954747f95c53b0e9c19185a7f73414826548 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Thu, 5 Mar 2020 21:11:04 -0500 Subject: [PATCH] Impl `pop`, which is the opposite of `dup`; and also the opposite of all the `push` instructions. Confusingly, this one isn't documented in the AVM2 spec at all, but it's method of operation is fairly obvious. --- core/src/avm2.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/avm2.rs b/core/src/avm2.rs index c01d17332..f715fe91e 100644 --- a/core/src/avm2.rs +++ b/core/src/avm2.rs @@ -439,6 +439,7 @@ impl<'gc> Avm2<'gc> { Op::PushTrue => self.op_push_true(), Op::PushUint { value } => self.op_push_uint(value), Op::PushUndefined => self.op_push_undefined(), + Op::Pop => self.op_pop(), Op::Dup => self.op_dup(), Op::GetLocal { index } => self.op_get_local(index), Op::SetLocal { index } => self.op_set_local(context, index), @@ -580,6 +581,12 @@ impl<'gc> Avm2<'gc> { Ok(()) } + fn op_pop(&mut self) -> Result<(), Error> { + self.pop(); + + Ok(()) + } + fn op_dup(&mut self) -> Result<(), Error> { self.push(self.stack.last().cloned().unwrap_or(Value::Undefined));