diff --git a/core/src/avm1/property.rs b/core/src/avm1/property.rs index 66d10b446..edccb7bea 100644 --- a/core/src/avm1/property.rs +++ b/core/src/avm1/property.rs @@ -1,10 +1,8 @@ //! User-defined properties use self::Attribute::*; -use crate::avm1::error::Error; use crate::avm1::function::Executable; -use crate::avm1::stack_frame::StackFrame; -use crate::avm1::{Object, UpdateContext, Value}; +use crate::avm1::Value; use core::fmt; use enumset::{EnumSet, EnumSetType}; @@ -32,23 +30,6 @@ pub enum Property<'gc> { } impl<'gc> Property<'gc> { - /// Get the value of a property slot. - /// - /// This function yields `ReturnValue` because some properties may be - /// user-defined. - pub fn get( - &self, - activation: &mut StackFrame<'_, 'gc>, - context: &mut UpdateContext<'_, 'gc, '_>, - this: Object<'gc>, - base_proto: Option>, - ) -> Result, Error<'gc>> { - match self { - Property::Virtual { get, .. } => get.exec(activation, context, this, base_proto, &[]), - Property::Stored { value, .. } => Ok(value.to_owned()), - } - } - /// Set a property slot. /// /// This function may return an `Executable` of the property's virtual diff --git a/core/src/avm1/script_object.rs b/core/src/avm1/script_object.rs index acdc8eaaf..71252d663 100644 --- a/core/src/avm1/script_object.rs +++ b/core/src/avm1/script_object.rs @@ -309,16 +309,25 @@ impl<'gc> TObject<'gc> for ScriptObject<'gc> { return Ok(self.proto().map_or(Value::Undefined, Value::Object)); } + let mut exec = None; + if let Some(value) = self .0 .read() .values .get(name, activation.is_case_sensitive()) { - return value.get(activation, context, this, Some((*self).into())); + match value { + Property::Virtual { get, .. } => exec = Some(get.to_owned()), + Property::Stored { value, .. } => return Ok(value.to_owned()), + } } - Ok(Value::Undefined) + if let Some(get) = exec { + get.exec(activation, context, this, Some((*self).into()), &[]) + } else { + Ok(Value::Undefined) + } } /// Set a named property on the object.