avm1: Simplify `SuperObject::from_this_and_base_proto`

This commit is contained in:
relrelb 2021-08-25 01:50:39 +03:00 committed by relrelb
parent 1bd46c6d59
commit dff74dcb92
2 changed files with 6 additions and 13 deletions

View File

@ -268,14 +268,7 @@ impl<'gc> Executable<'gc> {
let argcell = arguments.into(); let argcell = arguments.into();
let super_object: Option<Object<'gc>> = let super_object: Option<Object<'gc>> =
if !af.flags.contains(FunctionFlags::SUPPRESS_SUPER) { if !af.flags.contains(FunctionFlags::SUPPRESS_SUPER) {
Some( Some(SuperObject::new(activation, this, base_proto.unwrap_or(this)).into())
SuperObject::from_this_and_base_proto(
this,
base_proto.unwrap_or(this),
activation,
)?
.into(),
)
} else { } else {
None None
}; };

View File

@ -35,18 +35,18 @@ impl<'gc> SuperObject<'gc> {
/// Construct a `super` for an incoming stack frame. /// Construct a `super` for an incoming stack frame.
/// ///
/// `this` and `base_proto` must be the values provided to `Executable::exec`. /// `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>, this: Object<'gc>,
base_proto: Object<'gc>, base_proto: Object<'gc>,
activation: &mut Activation<'_, 'gc, '_>, ) -> Self {
) -> Result<Self, Error<'gc>> { Self(GcCell::allocate(
Ok(Self(GcCell::allocate(
activation.context.gc_context, activation.context.gc_context,
SuperObjectData { SuperObjectData {
child: this, child: this,
base_proto, base_proto,
}, },
))) ))
} }
/// Retrieve the constructor associated with the super proto. /// Retrieve the constructor associated with the super proto.