avm2: Move applytype next to other operations that create classes

This commit is contained in:
David Wendt 2021-03-16 21:00:05 -04:00 committed by kmeisthax
parent 074c093504
commit 65a23d5833
1 changed files with 16 additions and 16 deletions

View File

@ -782,11 +782,11 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
self.op_construct_prop(method, index, num_args) self.op_construct_prop(method, index, num_args)
} }
Op::ConstructSuper { num_args } => self.op_construct_super(num_args), Op::ConstructSuper { num_args } => self.op_construct_super(num_args),
Op::ApplyType { num_types } => self.op_apply_type(num_types),
Op::NewActivation => self.op_new_activation(), Op::NewActivation => self.op_new_activation(),
Op::NewObject { num_args } => self.op_new_object(num_args), Op::NewObject { num_args } => self.op_new_object(num_args),
Op::NewFunction { index } => self.op_new_function(method, index), Op::NewFunction { index } => self.op_new_function(method, index),
Op::NewClass { index } => self.op_new_class(method, index), Op::NewClass { index } => self.op_new_class(method, index),
Op::ApplyType { num_types } => self.op_apply_type(num_types),
Op::NewArray { num_args } => self.op_new_array(num_args), Op::NewArray { num_args } => self.op_new_array(num_args),
Op::CoerceA => self.op_coerce_a(), Op::CoerceA => self.op_coerce_a(),
Op::CoerceS => self.op_coerce_s(), Op::CoerceS => self.op_coerce_s(),
@ -1609,21 +1609,6 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
Ok(FrameControl::Continue) Ok(FrameControl::Continue)
} }
fn op_apply_type(&mut self, num_types: u32) -> Result<FrameControl<'gc>, Error> {
let args = self.context.avm2.pop_args(num_types);
let base = self.context.avm2.pop().coerce_to_object(self)?;
let mut args_classes = Vec::new();
for arg in args {
args_classes.push(arg.coerce_to_object(self)?)
}
let applied = base.apply(self, &args_classes[..])?;
self.context.avm2.push(applied);
Ok(FrameControl::Continue)
}
fn op_new_activation(&mut self) -> Result<FrameControl<'gc>, Error> { fn op_new_activation(&mut self) -> Result<FrameControl<'gc>, Error> {
let instance = if let Some(activation_class) = self.activation_class { let instance = if let Some(activation_class) = self.activation_class {
activation_class.construct(self, &[])? activation_class.construct(self, &[])?
@ -1693,6 +1678,21 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
Ok(FrameControl::Continue) Ok(FrameControl::Continue)
} }
fn op_apply_type(&mut self, num_types: u32) -> Result<FrameControl<'gc>, Error> {
let args = self.context.avm2.pop_args(num_types);
let base = self.context.avm2.pop().coerce_to_object(self)?;
let mut args_classes = Vec::new();
for arg in args {
args_classes.push(arg.coerce_to_object(self)?)
}
let applied = base.apply(self, &args_classes[..])?;
self.context.avm2.push(applied);
Ok(FrameControl::Continue)
}
fn op_new_array(&mut self, num_args: u32) -> Result<FrameControl<'gc>, Error> { fn op_new_array(&mut self, num_args: u32) -> Result<FrameControl<'gc>, Error> {
let args = self.context.avm2.pop_args(num_args); let args = self.context.avm2.pop_args(num_args);
let array = ArrayStorage::from_args(&args[..]); let array = ArrayStorage::from_args(&args[..]);