avm2: Add more ops that are guaranteed to not throw errors to `verify::ops_can_throw_error`

This requires a minor change to `Activation::op_lookup_switch`
This commit is contained in:
Lord-McSweeney 2024-01-07 14:40:19 -08:00 committed by Lord-McSweeney
parent 6be4918d77
commit f99c5621ee
2 changed files with 22 additions and 2 deletions

View File

@ -2834,7 +2834,11 @@ impl<'a, 'gc> Activation<'a, 'gc> {
default_offset: i32,
case_offsets: &[i32],
) -> Result<FrameControl<'gc>, Error<'gc>> {
let index = self.pop_stack().coerce_to_i32(self)?;
let index = self.pop_stack().coerce_to_i32(self).map_err(|_| {
Error::from(
"VerifyError: Invalid value type on stack (should have been int) for LookupSwitch!",
)
})?;
let offset = case_offsets
.get(index as usize)

View File

@ -794,7 +794,10 @@ fn optimize<'gc>(
fn ops_can_throw_error(ops: &[AbcOp]) -> bool {
for op in ops {
match op {
AbcOp::PushByte { .. }
AbcOp::Bkpt
| AbcOp::BkptLine { .. }
| AbcOp::Timestamp
| AbcOp::PushByte { .. }
| AbcOp::PushDouble { .. }
| AbcOp::PushFalse
| AbcOp::PushInt { .. }
@ -807,10 +810,23 @@ fn ops_can_throw_error(ops: &[AbcOp]) -> bool {
| AbcOp::PushUint { .. }
| AbcOp::PushUndefined
| AbcOp::Dup
| AbcOp::Swap
| AbcOp::Pop
| AbcOp::TypeOf
| AbcOp::GetGlobalScope
| AbcOp::GetScopeObject { .. }
| AbcOp::GetOuterScope { .. }
| AbcOp::GetGlobalSlot { .. }
| AbcOp::GetLocal { .. }
| AbcOp::SetLocal { .. }
| AbcOp::Kill { .. }
| AbcOp::Label
| AbcOp::Jump { .. }
| AbcOp::IfTrue { .. }
| AbcOp::IfFalse { .. }
| AbcOp::IfStrictEq { .. }
| AbcOp::IfStrictNe { .. }
| AbcOp::LookupSwitch { .. }
| AbcOp::Nop
| AbcOp::Not
| AbcOp::PopScope