avm2: Use return type of `ConstructProp` in optimizer
This commit is contained in:
parent
604ac514b8
commit
ea0bbce184
|
@ -1161,17 +1161,41 @@ pub fn optimize<'gc>(
|
||||||
multiname,
|
multiname,
|
||||||
num_args,
|
num_args,
|
||||||
} => {
|
} => {
|
||||||
|
let mut stack_push_done = false;
|
||||||
|
|
||||||
// Arguments
|
// Arguments
|
||||||
stack.popn(*num_args);
|
stack.popn(*num_args);
|
||||||
|
|
||||||
stack.pop_for_multiname(*multiname);
|
stack.pop_for_multiname(*multiname);
|
||||||
|
|
||||||
// Then receiver.
|
// Then receiver.
|
||||||
stack.pop();
|
let stack_value = stack.pop_or_any();
|
||||||
|
|
||||||
// Avoid checking return value for now
|
if !multiname.has_lazy_component() {
|
||||||
|
if let Some(vtable) = stack_value.vtable() {
|
||||||
|
match vtable.get_trait(multiname) {
|
||||||
|
Some(Property::Slot { slot_id })
|
||||||
|
| Some(Property::ConstSlot { slot_id }) => {
|
||||||
|
let mut value_class = vtable.slot_classes()[slot_id as usize];
|
||||||
|
let resolved_value_class = value_class.get_class(activation);
|
||||||
|
|
||||||
|
if let Ok(Some(slot_class)) = resolved_value_class {
|
||||||
|
if let Some(instance_class) = slot_class.i_class() {
|
||||||
|
// ConstructProp on a c_class will construct its i_class
|
||||||
|
stack_push_done = true;
|
||||||
|
stack.push_class(instance_class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !stack_push_done {
|
||||||
stack.push_any();
|
stack.push_any();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Op::Call { num_args } => {
|
Op::Call { num_args } => {
|
||||||
// Arguments
|
// Arguments
|
||||||
stack.popn(*num_args);
|
stack.popn(*num_args);
|
||||||
|
|
Loading…
Reference in New Issue