mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibJS: Use CallBuiltin for Math.tan()
This commit is contained in:
parent
878cc16d7a
commit
1647d7b34c
Notes:
github-actions[bot]
2025-05-26 19:53:42 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 1647d7b34c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4884
Reviewed-by: https://github.com/awesomekling ✅
4 changed files with 13 additions and 4 deletions
|
@ -44,7 +44,7 @@ void MathObject::initialize(Realm& realm)
|
|||
define_native_function(realm, vm.names.trunc, trunc, 1, attr);
|
||||
define_native_function(realm, vm.names.sin, sin, 1, attr, Bytecode::Builtin::MathSin);
|
||||
define_native_function(realm, vm.names.cos, cos, 1, attr, Bytecode::Builtin::MathCos);
|
||||
define_native_function(realm, vm.names.tan, tan, 1, attr);
|
||||
define_native_function(realm, vm.names.tan, tan, 1, attr, Bytecode::Builtin::MathTan);
|
||||
define_native_function(realm, vm.names.pow, pow, 2, attr, Bytecode::Builtin::MathPow);
|
||||
define_native_function(realm, vm.names.exp, exp, 1, attr, Bytecode::Builtin::MathExp);
|
||||
define_native_function(realm, vm.names.expm1, expm1, 1, attr);
|
||||
|
@ -971,10 +971,10 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::sqrt)
|
|||
}
|
||||
|
||||
// 21.3.2.34 Math.tan ( x ), https://tc39.es/ecma262/#sec-math.tan
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::tan)
|
||||
ThrowCompletionOr<Value> MathObject::tan_impl(VM& vm, Value value)
|
||||
{
|
||||
// Let n be ? ToNumber(x).
|
||||
auto number = TRY(vm.argument(0).to_number(vm));
|
||||
auto number = TRY(value.to_number(vm));
|
||||
|
||||
// 2. If n is NaN, n is +0𝔽, or n is -0𝔽, return n.
|
||||
if (number.is_nan() || number.is_positive_zero() || number.is_negative_zero())
|
||||
|
@ -988,6 +988,11 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::tan)
|
|||
return Value(::tan(number.as_double()));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::tan)
|
||||
{
|
||||
return tan_impl(vm, vm.argument(0));
|
||||
}
|
||||
|
||||
// 21.3.2.35 Math.tanh ( x ), https://tc39.es/ecma262/#sec-math.tanh
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::tanh)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue