From cad3cd8dbfbf13e2d09688434f09aba0bce46e78 Mon Sep 17 00:00:00 2001 From: relrelb Date: Sat, 16 Jul 2022 00:18:49 +0300 Subject: [PATCH] avm2: Inline `Activation::run_stack_frame_for_script` This reduces some complexity. --- core/src/avm2.rs | 4 ++-- core/src/avm2/activation.rs | 9 --------- core/src/avm2/method.rs | 12 ------------ 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/core/src/avm2.rs b/core/src/avm2.rs index eccbce810..ce8e24f4f 100644 --- a/core/src/avm2.rs +++ b/core/src/avm2.rs @@ -138,8 +138,8 @@ impl<'gc> Avm2<'gc> { (method.method)(&mut init_activation, Some(scope), &[])?; } - Method::Bytecode(_) => { - init_activation.run_stack_frame_for_script(script)?; + Method::Bytecode(method) => { + init_activation.run_actions(method)?; } }; diff --git a/core/src/avm2/activation.rs b/core/src/avm2/activation.rs index 3f307dc3e..033fa7249 100644 --- a/core/src/avm2/activation.rs +++ b/core/src/avm2/activation.rs @@ -528,15 +528,6 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { }) } - /// Execute a script initializer. - pub fn run_stack_frame_for_script(&mut self, script: Script<'gc>) -> Result<(), Error> { - let init = script.init().0.into_bytecode()?; - - self.run_actions(init)?; - - Ok(()) - } - /// Call the superclass's instance initializer. pub fn super_init( &mut self, diff --git a/core/src/avm2/method.rs b/core/src/avm2/method.rs index c0c0ef2d1..182cc4e0d 100644 --- a/core/src/avm2/method.rs +++ b/core/src/avm2/method.rs @@ -353,18 +353,6 @@ impl<'gc> Method<'gc> { )) } - /// Access the bytecode of this method. - /// - /// This function returns `Err` if there is no bytecode for this method. - pub fn into_bytecode(self) -> Result>, Error> { - match self { - Method::Native { .. } => { - Err("Attempted to unwrap a native method as a user-defined one".into()) - } - Method::Bytecode(bm) => Ok(bm), - } - } - /// Check if this method needs `arguments`. pub fn needs_arguments_object(&self) -> bool { match self {