From dff74dcb9202b4b38029045a0310c27e0c9702b9 Mon Sep 17 00:00:00 2001 From: relrelb Date: Wed, 25 Aug 2021 01:50:39 +0300 Subject: [PATCH] avm1: Simplify `SuperObject::from_this_and_base_proto` --- core/src/avm1/function.rs | 9 +-------- core/src/avm1/object/super_object.rs | 10 +++++----- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/core/src/avm1/function.rs b/core/src/avm1/function.rs index 9973b0b30..6a0f5af6e 100644 --- a/core/src/avm1/function.rs +++ b/core/src/avm1/function.rs @@ -268,14 +268,7 @@ impl<'gc> Executable<'gc> { let argcell = arguments.into(); let super_object: Option> = if !af.flags.contains(FunctionFlags::SUPPRESS_SUPER) { - Some( - SuperObject::from_this_and_base_proto( - this, - base_proto.unwrap_or(this), - activation, - )? - .into(), - ) + Some(SuperObject::new(activation, this, base_proto.unwrap_or(this)).into()) } else { None }; diff --git a/core/src/avm1/object/super_object.rs b/core/src/avm1/object/super_object.rs index 472da0184..e2e0240ca 100644 --- a/core/src/avm1/object/super_object.rs +++ b/core/src/avm1/object/super_object.rs @@ -35,18 +35,18 @@ impl<'gc> SuperObject<'gc> { /// Construct a `super` for an incoming stack frame. /// /// `this` and `base_proto` must be the values provided to `Executable::exec`. - pub fn from_this_and_base_proto( + pub fn new( + activation: &mut Activation<'_, 'gc, '_>, this: Object<'gc>, base_proto: Object<'gc>, - activation: &mut Activation<'_, 'gc, '_>, - ) -> Result> { - Ok(Self(GcCell::allocate( + ) -> Self { + Self(GcCell::allocate( activation.context.gc_context, SuperObjectData { child: this, base_proto, }, - ))) + )) } /// Retrieve the constructor associated with the super proto.