diff --git a/swf/src/avm1/write.rs b/swf/src/avm1/write.rs index c6f43ff55..f9017fc19 100644 --- a/swf/src/avm1/write.rs +++ b/swf/src/avm1/write.rs @@ -78,109 +78,107 @@ impl Writer { pub fn write_action(&mut self, action: &Action) -> Result<()> { match action { - Action::Add => self.write_small_action(OpCode::Add)?, - Action::Add2 => self.write_small_action(OpCode::Add2)?, - Action::And => self.write_small_action(OpCode::And)?, - Action::AsciiToChar => self.write_small_action(OpCode::AsciiToChar)?, - Action::BitAnd => self.write_small_action(OpCode::BitAnd)?, - Action::BitLShift => self.write_small_action(OpCode::BitLShift)?, - Action::BitOr => self.write_small_action(OpCode::BitOr)?, - Action::BitRShift => self.write_small_action(OpCode::BitRShift)?, - Action::BitURShift => self.write_small_action(OpCode::BitURShift)?, - Action::BitXor => self.write_small_action(OpCode::BitXor)?, - Action::Call => self.write_small_action(OpCode::Call)?, - Action::CallFunction => self.write_small_action(OpCode::CallFunction)?, - Action::CallMethod => self.write_small_action(OpCode::CallMethod)?, - Action::CastOp => self.write_small_action(OpCode::CastOp)?, - Action::CharToAscii => self.write_small_action(OpCode::CharToAscii)?, - Action::CloneSprite => self.write_small_action(OpCode::CloneSprite)?, - Action::ConstantPool(action) => self.write_constant_pool(action)?, - Action::Decrement => self.write_small_action(OpCode::Decrement)?, - Action::DefineFunction(action) => self.write_define_function(action)?, - Action::DefineFunction2(action) => self.write_define_function_2(action)?, - Action::DefineLocal => self.write_small_action(OpCode::DefineLocal)?, - Action::DefineLocal2 => self.write_small_action(OpCode::DefineLocal2)?, - Action::Divide => self.write_small_action(OpCode::Divide)?, - Action::Delete => self.write_small_action(OpCode::Delete)?, - Action::Delete2 => self.write_small_action(OpCode::Delete2)?, - Action::EndDrag => self.write_small_action(OpCode::EndDrag)?, - Action::Enumerate => self.write_small_action(OpCode::Enumerate)?, - Action::Enumerate2 => self.write_small_action(OpCode::Enumerate2)?, - Action::Equals => self.write_small_action(OpCode::Equals)?, - Action::Equals2 => self.write_small_action(OpCode::Equals2)?, - Action::Extends => self.write_small_action(OpCode::Extends)?, - Action::GetMember => self.write_small_action(OpCode::GetMember)?, - Action::GetProperty => self.write_small_action(OpCode::GetProperty)?, - Action::GetTime => self.write_small_action(OpCode::GetTime)?, - Action::GetUrl(action) => self.write_get_url(action)?, - Action::GetUrl2(action) => self.write_get_url_2(action)?, - Action::GetVariable => self.write_small_action(OpCode::GetVariable)?, - Action::GotoFrame(action) => self.write_goto_frame(action)?, - Action::GotoFrame2(action) => self.write_goto_frame_2(action)?, - Action::GotoLabel(action) => self.write_goto_label(action)?, - Action::Greater => self.write_small_action(OpCode::Greater)?, - Action::If(action) => self.write_if(action)?, - Action::ImplementsOp => self.write_small_action(OpCode::ImplementsOp)?, - Action::Increment => self.write_small_action(OpCode::Increment)?, - Action::InitArray => self.write_small_action(OpCode::InitArray)?, - Action::InitObject => self.write_small_action(OpCode::InitObject)?, - Action::InstanceOf => self.write_small_action(OpCode::InstanceOf)?, - Action::Jump(action) => self.write_jump(action)?, - Action::Less => self.write_small_action(OpCode::Less)?, - Action::Less2 => self.write_small_action(OpCode::Less2)?, - Action::MBAsciiToChar => self.write_small_action(OpCode::MBAsciiToChar)?, - Action::MBCharToAscii => self.write_small_action(OpCode::MBCharToAscii)?, - Action::MBStringExtract => self.write_small_action(OpCode::MBStringExtract)?, - Action::MBStringLength => self.write_small_action(OpCode::MBStringLength)?, - Action::Modulo => self.write_small_action(OpCode::Modulo)?, - Action::Multiply => self.write_small_action(OpCode::Multiply)?, - Action::NewMethod => self.write_small_action(OpCode::NewMethod)?, - Action::NewObject => self.write_small_action(OpCode::NewObject)?, - Action::NextFrame => self.write_small_action(OpCode::NextFrame)?, - Action::Not => self.write_small_action(OpCode::Not)?, - Action::Or => self.write_small_action(OpCode::Or)?, - Action::Play => self.write_small_action(OpCode::Play)?, - Action::Pop => self.write_small_action(OpCode::Pop)?, - Action::PreviousFrame => self.write_small_action(OpCode::PreviousFrame)?, - Action::Push(action) => self.write_push(action)?, - Action::PushDuplicate => self.write_small_action(OpCode::PushDuplicate)?, - Action::RandomNumber => self.write_small_action(OpCode::RandomNumber)?, - Action::RemoveSprite => self.write_small_action(OpCode::RemoveSprite)?, - Action::Return => self.write_small_action(OpCode::Return)?, - Action::SetMember => self.write_small_action(OpCode::SetMember)?, - Action::SetProperty => self.write_small_action(OpCode::SetProperty)?, - Action::SetTarget(action) => self.write_set_target(action)?, - Action::SetTarget2 => self.write_small_action(OpCode::SetTarget2)?, - Action::SetVariable => self.write_small_action(OpCode::SetVariable)?, - Action::StackSwap => self.write_small_action(OpCode::StackSwap)?, - Action::StartDrag => self.write_small_action(OpCode::StartDrag)?, - Action::Stop => self.write_small_action(OpCode::Stop)?, - Action::StopSounds => self.write_small_action(OpCode::StopSounds)?, - Action::StoreRegister(action) => self.write_store_register(action)?, - Action::StrictEquals => self.write_small_action(OpCode::StrictEquals)?, - Action::StringAdd => self.write_small_action(OpCode::StringAdd)?, - Action::StringEquals => self.write_small_action(OpCode::StringEquals)?, - Action::StringExtract => self.write_small_action(OpCode::StringExtract)?, - Action::StringGreater => self.write_small_action(OpCode::StringGreater)?, - Action::StringLength => self.write_small_action(OpCode::StringLength)?, - Action::StringLess => self.write_small_action(OpCode::StringLess)?, - Action::Subtract => self.write_small_action(OpCode::Subtract)?, - Action::TargetPath => self.write_small_action(OpCode::TargetPath)?, - Action::Throw => self.write_small_action(OpCode::Throw)?, - Action::ToggleQuality => self.write_small_action(OpCode::ToggleQuality)?, - Action::ToInteger => self.write_small_action(OpCode::ToInteger)?, - Action::ToNumber => self.write_small_action(OpCode::ToNumber)?, - Action::ToString => self.write_small_action(OpCode::ToString)?, - Action::Trace => self.write_small_action(OpCode::Trace)?, - Action::Try(action) => self.write_try(action)?, - Action::TypeOf => self.write_small_action(OpCode::TypeOf)?, - Action::WaitForFrame(action) => self.write_wait_for_frame(action)?, - Action::WaitForFrame2(action) => self.write_wait_for_frame_2(action)?, - Action::With(action) => self.write_with(action)?, - Action::Unknown(action) => self.write_unknown(action)?, + Action::Add => self.write_small_action(OpCode::Add), + Action::Add2 => self.write_small_action(OpCode::Add2), + Action::And => self.write_small_action(OpCode::And), + Action::AsciiToChar => self.write_small_action(OpCode::AsciiToChar), + Action::BitAnd => self.write_small_action(OpCode::BitAnd), + Action::BitLShift => self.write_small_action(OpCode::BitLShift), + Action::BitOr => self.write_small_action(OpCode::BitOr), + Action::BitRShift => self.write_small_action(OpCode::BitRShift), + Action::BitURShift => self.write_small_action(OpCode::BitURShift), + Action::BitXor => self.write_small_action(OpCode::BitXor), + Action::Call => self.write_small_action(OpCode::Call), + Action::CallFunction => self.write_small_action(OpCode::CallFunction), + Action::CallMethod => self.write_small_action(OpCode::CallMethod), + Action::CastOp => self.write_small_action(OpCode::CastOp), + Action::CharToAscii => self.write_small_action(OpCode::CharToAscii), + Action::CloneSprite => self.write_small_action(OpCode::CloneSprite), + Action::ConstantPool(action) => self.write_constant_pool(action), + Action::Decrement => self.write_small_action(OpCode::Decrement), + Action::DefineFunction(action) => self.write_define_function(action), + Action::DefineFunction2(action) => self.write_define_function_2(action), + Action::DefineLocal => self.write_small_action(OpCode::DefineLocal), + Action::DefineLocal2 => self.write_small_action(OpCode::DefineLocal2), + Action::Divide => self.write_small_action(OpCode::Divide), + Action::Delete => self.write_small_action(OpCode::Delete), + Action::Delete2 => self.write_small_action(OpCode::Delete2), + Action::EndDrag => self.write_small_action(OpCode::EndDrag), + Action::Enumerate => self.write_small_action(OpCode::Enumerate), + Action::Enumerate2 => self.write_small_action(OpCode::Enumerate2), + Action::Equals => self.write_small_action(OpCode::Equals), + Action::Equals2 => self.write_small_action(OpCode::Equals2), + Action::Extends => self.write_small_action(OpCode::Extends), + Action::GetMember => self.write_small_action(OpCode::GetMember), + Action::GetProperty => self.write_small_action(OpCode::GetProperty), + Action::GetTime => self.write_small_action(OpCode::GetTime), + Action::GetUrl(action) => self.write_get_url(action), + Action::GetUrl2(action) => self.write_get_url_2(action), + Action::GetVariable => self.write_small_action(OpCode::GetVariable), + Action::GotoFrame(action) => self.write_goto_frame(action), + Action::GotoFrame2(action) => self.write_goto_frame_2(action), + Action::GotoLabel(action) => self.write_goto_label(action), + Action::Greater => self.write_small_action(OpCode::Greater), + Action::If(action) => self.write_if(action), + Action::ImplementsOp => self.write_small_action(OpCode::ImplementsOp), + Action::Increment => self.write_small_action(OpCode::Increment), + Action::InitArray => self.write_small_action(OpCode::InitArray), + Action::InitObject => self.write_small_action(OpCode::InitObject), + Action::InstanceOf => self.write_small_action(OpCode::InstanceOf), + Action::Jump(action) => self.write_jump(action), + Action::Less => self.write_small_action(OpCode::Less), + Action::Less2 => self.write_small_action(OpCode::Less2), + Action::MBAsciiToChar => self.write_small_action(OpCode::MBAsciiToChar), + Action::MBCharToAscii => self.write_small_action(OpCode::MBCharToAscii), + Action::MBStringExtract => self.write_small_action(OpCode::MBStringExtract), + Action::MBStringLength => self.write_small_action(OpCode::MBStringLength), + Action::Modulo => self.write_small_action(OpCode::Modulo), + Action::Multiply => self.write_small_action(OpCode::Multiply), + Action::NewMethod => self.write_small_action(OpCode::NewMethod), + Action::NewObject => self.write_small_action(OpCode::NewObject), + Action::NextFrame => self.write_small_action(OpCode::NextFrame), + Action::Not => self.write_small_action(OpCode::Not), + Action::Or => self.write_small_action(OpCode::Or), + Action::Play => self.write_small_action(OpCode::Play), + Action::Pop => self.write_small_action(OpCode::Pop), + Action::PreviousFrame => self.write_small_action(OpCode::PreviousFrame), + Action::Push(action) => self.write_push(action), + Action::PushDuplicate => self.write_small_action(OpCode::PushDuplicate), + Action::RandomNumber => self.write_small_action(OpCode::RandomNumber), + Action::RemoveSprite => self.write_small_action(OpCode::RemoveSprite), + Action::Return => self.write_small_action(OpCode::Return), + Action::SetMember => self.write_small_action(OpCode::SetMember), + Action::SetProperty => self.write_small_action(OpCode::SetProperty), + Action::SetTarget(action) => self.write_set_target(action), + Action::SetTarget2 => self.write_small_action(OpCode::SetTarget2), + Action::SetVariable => self.write_small_action(OpCode::SetVariable), + Action::StackSwap => self.write_small_action(OpCode::StackSwap), + Action::StartDrag => self.write_small_action(OpCode::StartDrag), + Action::Stop => self.write_small_action(OpCode::Stop), + Action::StopSounds => self.write_small_action(OpCode::StopSounds), + Action::StoreRegister(action) => self.write_store_register(action), + Action::StrictEquals => self.write_small_action(OpCode::StrictEquals), + Action::StringAdd => self.write_small_action(OpCode::StringAdd), + Action::StringEquals => self.write_small_action(OpCode::StringEquals), + Action::StringExtract => self.write_small_action(OpCode::StringExtract), + Action::StringGreater => self.write_small_action(OpCode::StringGreater), + Action::StringLength => self.write_small_action(OpCode::StringLength), + Action::StringLess => self.write_small_action(OpCode::StringLess), + Action::Subtract => self.write_small_action(OpCode::Subtract), + Action::TargetPath => self.write_small_action(OpCode::TargetPath), + Action::Throw => self.write_small_action(OpCode::Throw), + Action::ToggleQuality => self.write_small_action(OpCode::ToggleQuality), + Action::ToInteger => self.write_small_action(OpCode::ToInteger), + Action::ToNumber => self.write_small_action(OpCode::ToNumber), + Action::ToString => self.write_small_action(OpCode::ToString), + Action::Trace => self.write_small_action(OpCode::Trace), + Action::Try(action) => self.write_try(action), + Action::TypeOf => self.write_small_action(OpCode::TypeOf), + Action::WaitForFrame(action) => self.write_wait_for_frame(action), + Action::WaitForFrame2(action) => self.write_wait_for_frame_2(action), + Action::With(action) => self.write_with(action), + Action::Unknown(action) => self.write_unknown(action), } - - Ok(()) } pub fn write_action_header(&mut self, opcode: OpCode, length: usize) -> Result<()> {