From f2c9ae7c50c3382ae9fe651ab7f6f1e7ab8f643d Mon Sep 17 00:00:00 2001 From: = Date: Fri, 19 Aug 2022 15:12:45 +0200 Subject: [PATCH] avm1: Moved root_error_handler from avm1 root to runtime module --- core/src/avm1.rs | 20 -------------------- core/src/avm1/runtime.rs | 27 +++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/core/src/avm1.rs b/core/src/avm1.rs index c1568927f..044f8b4c0 100644 --- a/core/src/avm1.rs +++ b/core/src/avm1.rs @@ -59,26 +59,6 @@ macro_rules! avm_error { ) } -pub fn root_error_handler<'gc>(activation: &mut Activation<'_, 'gc, '_>, error: Error<'gc>) { - match &error { - Error::ThrownValue(value) => { - let message = value - .coerce_to_string(activation) - .unwrap_or_else(|_| "undefined".into()); - activation.context.avm_trace(&message.to_utf8_lossy()); - // Continue execution without halting. - return; - } - Error::InvalidSwf(swf_error) => { - log::error!("{}: {}", error, swf_error); - } - _ => { - log::error!("{}", error); - } - } - activation.context.avm1.halt(); -} - /// Starts dragging this display object, making it follow the cursor. /// Runs via the `startDrag` method or `StartDrag` AVM1 action. pub fn start_drag<'gc>( diff --git a/core/src/avm1/runtime.rs b/core/src/avm1/runtime.rs index 3e27ab8f1..93da11c8f 100644 --- a/core/src/avm1/runtime.rs +++ b/core/src/avm1/runtime.rs @@ -5,8 +5,7 @@ use crate::avm1::object::stage_object; use crate::avm1::object::TObject; use crate::avm1::property_map::PropertyMap; use crate::avm1::scope::Scope; -use crate::avm1::Object; -use crate::avm1::{scope, Activation, ActivationIdentifier, Value}; +use crate::avm1::{scope, Activation, ActivationIdentifier, Error, Object, Value}; use crate::context::UpdateContext; use crate::frame_lifecycle::FramePhase; use crate::prelude::*; @@ -148,7 +147,7 @@ impl<'gc> Avm1<'gc> { None, ); if let Err(e) = child_activation.run_actions(code) { - avm1::root_error_handler(&mut child_activation, e); + root_error_handler(&mut child_activation, e); } } @@ -235,7 +234,7 @@ impl<'gc> Avm1<'gc> { None, ); if let Err(e) = child_activation.run_actions(code) { - avm1::root_error_handler(&mut child_activation, e); + root_error_handler(&mut child_activation, e); } } @@ -506,3 +505,23 @@ pub fn skip_actions(reader: &mut Reader<'_>, num_actions_to_skip: u8) { } } } + +pub fn root_error_handler<'gc>(activation: &mut Activation<'_, 'gc, '_>, error: Error<'gc>) { + match &error { + Error::ThrownValue(value) => { + let message = value + .coerce_to_string(activation) + .unwrap_or_else(|_| "undefined".into()); + activation.context.avm_trace(&message.to_utf8_lossy()); + // Continue execution without halting. + return; + } + Error::InvalidSwf(swf_error) => { + log::error!("{}: {}", error, swf_error); + } + _ => { + log::error!("{}", error); + } + } + activation.context.avm1.halt(); +}