Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions core/src/avm2/globals/Number.as
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,80 @@ package {
[API("680")]
public static const LOG10E:Number = 0.4342944819032518;

[API("680")]
[Ruffle(FastCall)]
public static native function abs(x:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function acos(x:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function asin(x:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function atan(x:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function atan2(y:Number, x:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function ceil(x:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function cos(x:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function exp(x:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function floor(x:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function log(x:Number):Number;

// NOTE: See the the comment in Math.as for why max and min are marked as FastCall

[API("680")]
[Ruffle(FastCall)]
public static native function max(x:Number = NEGATIVE_INFINITY, y:Number = NEGATIVE_INFINITY, ...rest):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function min(x:Number = POSITIVE_INFINITY, y:Number = POSITIVE_INFINITY, ...rest):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function pow(x:Number, y:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function random():Number;

[API("680")]
[Ruffle(FastCall)]
public static native function round(x:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function sin(x:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function sqrt(x:Number):Number;

[API("680")]
[Ruffle(FastCall)]
public static native function tan(x:Number):Number;

{
prototype.toExponential = function(digits:* = 0):String {
var self:Number = this;
Expand Down
19 changes: 19 additions & 0 deletions core/src/avm2/globals/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ pub fn number_constructor<'gc>(
Ok(number_value.into())
}

macro_rules! define_math_functions {
($($name:ident),* $(,)?) => {
$(
pub fn $name<'gc>(
activation: &mut Activation<'_, 'gc>,
this: Value<'gc>,
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
crate::avm2::globals::math::$name(activation, this, args)
}
)*
};
}

define_math_functions!(
abs, acos, asin, atan, atan2, ceil, cos, exp, floor, log, max, min, pow, random, round, sin,
sqrt, tan
);

pub fn call_handler<'gc>(
activation: &mut Activation<'_, 'gc>,
_this: Value<'gc>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Loading