avm1: Fix binary operators not returning signed values

Also enabled AVM2 test that was forgotten before.
This commit is contained in:
Adrian Wielgosik 2021-03-20 22:49:55 +01:00 committed by GitHub
parent d7c53df8d5
commit 2d1c60e02e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 3185 additions and 6 deletions

View File

@ -709,8 +709,8 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
}
fn action_bit_and(&mut self) -> Result<FrameControl<'gc>, Error<'gc>> {
let a = self.context.avm1.pop().coerce_to_u32(self)?;
let b = self.context.avm1.pop().coerce_to_u32(self)?;
let a = self.context.avm1.pop().coerce_to_i32(self)?;
let b = self.context.avm1.pop().coerce_to_i32(self)?;
let result = a & b;
self.context.avm1.push(result);
Ok(FrameControl::Continue)
@ -725,8 +725,8 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
}
fn action_bit_or(&mut self) -> Result<FrameControl<'gc>, Error<'gc>> {
let a = self.context.avm1.pop().coerce_to_u32(self)?;
let b = self.context.avm1.pop().coerce_to_u32(self)?;
let a = self.context.avm1.pop().coerce_to_i32(self)?;
let b = self.context.avm1.pop().coerce_to_i32(self)?;
let result = a | b;
self.context.avm1.push(result);
Ok(FrameControl::Continue)
@ -749,8 +749,8 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
}
fn action_bit_xor(&mut self) -> Result<FrameControl<'gc>, Error<'gc>> {
let a = self.context.avm1.pop().coerce_to_u32(self)?;
let b = self.context.avm1.pop().coerce_to_u32(self)?;
let a = self.context.avm1.pop().coerce_to_i32(self)?;
let b = self.context.avm1.pop().coerce_to_i32(self)?;
let result = b ^ a;
self.context.avm1.push(result);
Ok(FrameControl::Continue)

View File

@ -86,6 +86,9 @@ swf_tests! {
(as_broadcaster, "avm1/as_broadcaster", 1),
(as_broadcaster_initialize, "avm1/as_broadcaster_initialize", 1),
(attach_movie, "avm1/attach_movie", 1),
(as2_bitor, "avm1/bitor", 1),
(as2_bitand, "avm1/bitand", 1),
(as2_bitxor, "avm1/bitxor", 1),
(function_base_clip, "avm1/function_base_clip", 2),
(call, "avm1/call", 2),
(color, "avm1/color", 1),
@ -400,8 +403,10 @@ swf_tests! {
(target_path, "avm1/target_path", 1),
(remove_movie_clip, "avm1/remove_movie_clip", 2),
(as3_add, "avm2/add", 1),
(as3_bitor, "avm2/bitor", 1),
(as3_bitand, "avm2/bitand", 1),
(as3_bitnot, "avm2/bitnot", 1),
(as3_bitxor, "avm2/bitxor", 1),
(as3_declocal, "avm2/declocal", 1),
(as3_declocal_i, "avm2/declocal_i", 1),
(as3_decrement, "avm2/decrement", 1),

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.