Skip to content

Commit

Permalink
avm2: Replace PushNaN with PushDouble and PushByte with PushShort
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-McSweeney authored and Lord-McSweeney committed Jan 29, 2025
1 parent db6ed91 commit efac363
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 31 deletions.
12 changes: 0 additions & 12 deletions core/src/avm2/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,12 +800,10 @@ impl<'a, 'gc> Activation<'a, 'gc> {

{
let result = match op {
Op::PushByte { value } => self.op_push_byte(*value),
Op::PushDouble { value } => self.op_push_double(*value),
Op::PushFalse => self.op_push_false(),
Op::PushInt { value } => self.op_push_int(*value),
Op::PushNamespace { value } => self.op_push_namespace(method, *value),
Op::PushNaN => self.op_push_nan(),
Op::PushNull => self.op_push_null(),
Op::PushShort { value } => self.op_push_short(*value),
Op::PushString { string } => self.op_push_string(*string),
Expand Down Expand Up @@ -996,11 +994,6 @@ impl<'a, 'gc> Activation<'a, 'gc> {
}
}

fn op_push_byte(&mut self, value: i8) -> Result<FrameControl<'gc>, Error<'gc>> {
self.push_stack(value as i32);
Ok(FrameControl::Continue)
}

fn op_push_double(&mut self, value: f64) -> Result<FrameControl<'gc>, Error<'gc>> {
self.push_stack(value);
Ok(FrameControl::Continue)
Expand Down Expand Up @@ -1028,11 +1021,6 @@ impl<'a, 'gc> Activation<'a, 'gc> {
Ok(FrameControl::Continue)
}

fn op_push_nan(&mut self) -> Result<FrameControl<'gc>, Error<'gc>> {
self.push_stack(f64::NAN);
Ok(FrameControl::Continue)
}

fn op_push_null(&mut self) -> Result<FrameControl<'gc>, Error<'gc>> {
self.push_stack(Value::Null);
Ok(FrameControl::Continue)
Expand Down
6 changes: 0 additions & 6 deletions core/src/avm2/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,6 @@ pub enum Op<'gc> {
Not,
Pop,
PopScope,
PushByte {
value: i8,
},
PushDouble {
value: f64,
},
Expand All @@ -278,7 +275,6 @@ pub enum Op<'gc> {
#[collect(require_static)]
value: Index<Namespace>,
},
PushNaN,
PushNull,
PushScope,
PushShort {
Expand Down Expand Up @@ -355,12 +351,10 @@ impl Op<'_> {
Op::Bkpt
| Op::BkptLine { .. }
| Op::Timestamp
| Op::PushByte { .. }
| Op::PushDouble { .. }
| Op::PushFalse
| Op::PushInt { .. }
| Op::PushNamespace { .. }
| Op::PushNaN
| Op::PushNull
| Op::PushShort { .. }
| Op::PushString { .. }
Expand Down
11 changes: 0 additions & 11 deletions core/src/avm2/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,17 +778,6 @@ pub fn optimize<'gc>(
Op::PushUndefined => {
stack.push_class(activation, types.void)?;
}
Op::PushNaN => {
stack.push_class(activation, types.number)?;
}
Op::PushByte { value } => {
let mut new_value = OptValue::of_type(types.int);
new_value.contains_valid_integer = true;
if *value >= 0 {
new_value.contains_valid_unsigned = true;
}
stack.push(activation, new_value)?;
}
Op::PushShort { value } => {
let mut new_value = OptValue::of_type(types.int);
new_value.contains_valid_integer = true;
Expand Down
6 changes: 4 additions & 2 deletions core/src/avm2/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,9 @@ fn resolve_op<'gc>(
op: AbcOp,
) -> Result<Op<'gc>, Error<'gc>> {
Ok(match op {
AbcOp::PushByte { value } => Op::PushByte { value: value as i8 },
AbcOp::PushByte { value } => Op::PushShort {
value: value as i8 as i16,
},
AbcOp::PushDouble { value } => {
let value = pool_double(activation, translation_unit, value)?;

Expand All @@ -923,7 +925,7 @@ fn resolve_op<'gc>(
Op::PushInt { value }
}
AbcOp::PushNamespace { value } => Op::PushNamespace { value },
AbcOp::PushNaN => Op::PushNaN,
AbcOp::PushNaN => Op::PushDouble { value: f64::NAN },
AbcOp::PushNull => Op::PushNull,
AbcOp::PushShort { value } => Op::PushShort { value },
AbcOp::PushString { value } => {
Expand Down

0 comments on commit efac363

Please sign in to comment.