avm1: Correct ToInteger
* Coerce objects as well. * Wrap numbers around i32.
This commit is contained in:
parent
bdf693c9c4
commit
939d467897
|
@ -2194,14 +2194,8 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
|
|||
}
|
||||
|
||||
fn action_to_integer(&mut self) -> Result<FrameControl<'gc>, Error<'gc>> {
|
||||
let val = self.context.avm1.pop();
|
||||
|
||||
let value = match val {
|
||||
Value::Undefined | Value::Null | Value::Object(_) => 0.0,
|
||||
_ => val.coerce_to_f64(self)?,
|
||||
};
|
||||
|
||||
self.context.avm1.push(value.trunc());
|
||||
let val = self.context.avm1.pop().coerce_to_i32(self)?;
|
||||
self.context.avm1.push(val);
|
||||
Ok(FrameControl::Continue)
|
||||
}
|
||||
|
||||
|
|
|
@ -12,3 +12,17 @@
|
|||
-2147483648
|
||||
// int({})
|
||||
0
|
||||
// int(hello)
|
||||
0
|
||||
// int(ten)
|
||||
10
|
||||
// int(float)
|
||||
10
|
||||
// int(negative)
|
||||
-10
|
||||
// int(NaN)
|
||||
0
|
||||
// int(valof)
|
||||
42
|
||||
// int(0xffffffff)
|
||||
-2147483648
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue