swf: `CallMethod` takes a `disp_id`, not any sort of `Index`
This commit is contained in:
parent
028a61e744
commit
b5f7fa0cd0
|
@ -1192,7 +1192,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
|
||||||
|
|
||||||
fn op_call_method(
|
fn op_call_method(
|
||||||
&mut self,
|
&mut self,
|
||||||
index: Index<AbcMethod>,
|
index: u32,
|
||||||
arg_count: u32,
|
arg_count: u32,
|
||||||
) -> Result<FrameControl<'gc>, Error<'gc>> {
|
) -> Result<FrameControl<'gc>, Error<'gc>> {
|
||||||
// The entire implementation of VTable assumes that
|
// The entire implementation of VTable assumes that
|
||||||
|
@ -1205,7 +1205,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
|
||||||
let args = self.pop_stack_args(arg_count);
|
let args = self.pop_stack_args(arg_count);
|
||||||
let receiver = self.pop_stack().coerce_to_object_or_typeerror(self, None)?;
|
let receiver = self.pop_stack().coerce_to_object_or_typeerror(self, None)?;
|
||||||
|
|
||||||
let value = receiver.call_method(index.0, &args, self)?;
|
let value = receiver.call_method(index, &args, self)?;
|
||||||
|
|
||||||
self.push_stack(value);
|
self.push_stack(value);
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,7 @@ pub enum Op<'gc> {
|
||||||
num_args: u32,
|
num_args: u32,
|
||||||
},
|
},
|
||||||
CallMethod {
|
CallMethod {
|
||||||
#[collect(require_static)]
|
index: u32,
|
||||||
index: Index<Method>,
|
|
||||||
|
|
||||||
num_args: u32,
|
num_args: u32,
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,7 +8,6 @@ use crate::avm2::property::Property;
|
||||||
|
|
||||||
use gc_arena::{Gc, GcCell};
|
use gc_arena::{Gc, GcCell};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use swf::avm2::types::Index;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
enum ValueType<'gc> {
|
enum ValueType<'gc> {
|
||||||
|
@ -623,10 +622,10 @@ pub fn optimize<'gc>(
|
||||||
value_class,
|
value_class,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Some(Property::Virtual { get: Some(get), .. }) => {
|
Some(Property::Virtual { get: Some(disp_id), .. }) => {
|
||||||
*op = Op::CallMethod {
|
*op = Op::CallMethod {
|
||||||
num_args: 0,
|
num_args: 0,
|
||||||
index: Index::new(get),
|
index: disp_id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -737,7 +736,7 @@ pub fn optimize<'gc>(
|
||||||
Some(Property::Method { disp_id }) => {
|
Some(Property::Method { disp_id }) => {
|
||||||
*op = Op::CallMethod {
|
*op = Op::CallMethod {
|
||||||
num_args: *num_args,
|
num_args: *num_args,
|
||||||
index: Index::new(disp_id),
|
index: disp_id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -247,7 +247,7 @@ pub fn verify_method<'gc>(
|
||||||
|
|
||||||
// Misc opcode verification
|
// Misc opcode verification
|
||||||
AbcOp::CallMethod { index, .. } => {
|
AbcOp::CallMethod { index, .. } => {
|
||||||
return Err(Error::AvmError(if index.as_u30() == 0 {
|
return Err(Error::AvmError(if index == 0 {
|
||||||
verify_error(activation, "Error #1072: Disp_id 0 is illegal.", 1072)?
|
verify_error(activation, "Error #1072: Disp_id 0 is illegal.", 1072)?
|
||||||
} else {
|
} else {
|
||||||
verify_error(
|
verify_error(
|
||||||
|
|
|
@ -544,7 +544,7 @@ impl<'a> Reader<'a> {
|
||||||
num_args: self.read_u30()?,
|
num_args: self.read_u30()?,
|
||||||
},
|
},
|
||||||
OpCode::CallMethod => Op::CallMethod {
|
OpCode::CallMethod => Op::CallMethod {
|
||||||
index: self.read_index()?,
|
index: self.read_u30()?,
|
||||||
num_args: self.read_u30()?,
|
num_args: self.read_u30()?,
|
||||||
},
|
},
|
||||||
OpCode::CallProperty => Op::CallProperty {
|
OpCode::CallProperty => Op::CallProperty {
|
||||||
|
|
|
@ -275,7 +275,7 @@ pub enum Op {
|
||||||
num_args: u32,
|
num_args: u32,
|
||||||
},
|
},
|
||||||
CallMethod {
|
CallMethod {
|
||||||
index: Index<Method>,
|
index: u32,
|
||||||
num_args: u32,
|
num_args: u32,
|
||||||
},
|
},
|
||||||
CallProperty {
|
CallProperty {
|
||||||
|
|
|
@ -615,12 +615,9 @@ impl<W: Write> Writer<W> {
|
||||||
self.write_opcode(OpCode::Call)?;
|
self.write_opcode(OpCode::Call)?;
|
||||||
self.write_u30(num_args)?;
|
self.write_u30(num_args)?;
|
||||||
}
|
}
|
||||||
Op::CallMethod {
|
Op::CallMethod { index, num_args } => {
|
||||||
ref index,
|
|
||||||
num_args,
|
|
||||||
} => {
|
|
||||||
self.write_opcode(OpCode::CallMethod)?;
|
self.write_opcode(OpCode::CallMethod)?;
|
||||||
self.write_index(index)?;
|
self.write_u30(index)?;
|
||||||
self.write_u30(num_args)?;
|
self.write_u30(num_args)?;
|
||||||
}
|
}
|
||||||
Op::CallProperty {
|
Op::CallProperty {
|
||||||
|
@ -1119,7 +1116,7 @@ pub mod tests {
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
write(Op::CallMethod {
|
write(Op::CallMethod {
|
||||||
index: Index::new(1),
|
index: 1,
|
||||||
num_args: 2
|
num_args: 2
|
||||||
}),
|
}),
|
||||||
b"\x43\x01\x02"
|
b"\x43\x01\x02"
|
||||||
|
|
Loading…
Reference in New Issue