Ints are signed in avm1

This commit is contained in:
Nathan Adams 2019-08-26 23:54:09 +02:00 committed by Mike Welsh
parent e788381200
commit 89fee4c580
4 changed files with 8 additions and 3 deletions

View File

@ -236,7 +236,7 @@ impl<R: Read> Reader<R> {
4 => Value::Register(self.read_u8()?),
5 => Value::Bool(self.read_u8()? != 0),
6 => Value::Double(self.read_f64()?),
7 => Value::Int(self.read_u32()?),
7 => Value::Int(self.read_i32()?),
8 => Value::ConstantPool(self.read_u8()?.into()),
9 => Value::ConstantPool(self.read_u16()?),
_ => {

View File

@ -135,7 +135,7 @@ pub enum Value {
Undefined,
Null,
Bool(bool),
Int(u32),
Int(i32),
Float(f32),
Double(f64),
Str(String),

View File

@ -407,7 +407,7 @@ impl<W: Write> Writer<W> {
}
Value::Int(v) => {
self.write_u8(7)?;
self.write_u32(v)?;
self.write_i32(v)?;
}
Value::ConstantPool(v) => {
if v < 256 {

View File

@ -2438,6 +2438,11 @@ pub fn avm1_tests() -> Vec<Avm1TestData> {
Action::Push(vec![Value::Int(31)]),
vec![0x96, 5, 0, 7, 31, 0, 0, 0],
),
(
5,
Action::Push(vec![Value::Int(-50)]),
vec![0x96, 5, 0, 7, 206, 255, 255, 255],
),
(
5,
Action::Push(vec![Value::ConstantPool(77)]),