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 super_object: Option<Object<'gc>> =
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
};

View File

@ -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<Self, Error<'gc>> {
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.