mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibJS: Update spec steps / links for the Float16Array proposal
This proposal has reached stage 4 and been merged into the main ECMA-262
spec. See:
d430ace
This commit is contained in:
parent
adf6024805
commit
9674210ef8
Notes:
github-actions[bot]
2025-04-29 11:34:45 +00:00
Author: https://github.com/trflynn89
Commit: 9674210ef8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4514
3 changed files with 46 additions and 47 deletions
|
@ -171,7 +171,6 @@ inline size_t array_buffer_byte_length(ArrayBuffer const& array_buffer, ArrayBuf
|
|||
}
|
||||
|
||||
// 25.1.3.14 RawBytesToNumeric ( type, rawBytes, isLittleEndian ), https://tc39.es/ecma262/#sec-rawbytestonumeric
|
||||
// 5 RawBytesToNumeric ( type, rawBytes, isLittleEndian ), https://tc39.es/proposal-float16array/#sec-rawbytestonumeric
|
||||
template<typename T>
|
||||
static Value raw_bytes_to_numeric(VM& vm, Bytes raw_value, bool is_little_endian)
|
||||
{
|
||||
|
@ -305,7 +304,6 @@ Value ArrayBuffer::get_value(size_t byte_index, [[maybe_unused]] bool is_typed_a
|
|||
}
|
||||
|
||||
// 25.1.3.17 NumericToRawBytes ( type, value, isLittleEndian ), https://tc39.es/ecma262/#sec-numerictorawbytes
|
||||
// 6 NumericToRawBytes ( type, value, isLittleEndian ), https://tc39.es/proposal-float16array/#sec-numerictorawbytes
|
||||
template<typename T>
|
||||
static void numeric_to_raw_bytes(VM& vm, Value value, bool is_little_endian, Bytes raw_bytes)
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@ void DataViewPrototype::initialize(Realm& realm)
|
|||
define_native_accessor(realm, vm.names.byteLength, byte_length_getter, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.byteOffset, byte_offset_getter, {}, Attribute::Configurable);
|
||||
|
||||
// 25.3.4.25 DataView.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-dataview.prototype-@@tostringtag
|
||||
// 25.3.4.27 DataView.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-dataview.prototype-@@tostringtag
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.DataView.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_big_uint_64)
|
|||
return get_view_value<u64>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 7.1 DataView.prototype.getFloat16 ( byteOffset [ , littleEndian ] ), https://tc39.es/proposal-float16array/#sec-dataview.prototype.getfloat16
|
||||
// 25.3.4.7 DataView.prototype.getFloat16 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getfloat16
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_float_16)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -247,7 +247,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_float_16)
|
|||
return get_view_value<f16>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.7 DataView.prototype.getFloat32 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getfloat32
|
||||
// 25.3.4.8 DataView.prototype.getFloat32 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getfloat32
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_float_32)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -256,7 +256,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_float_32)
|
|||
return get_view_value<float>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.8 DataView.prototype.getFloat64 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getfloat64
|
||||
// 25.3.4.9 DataView.prototype.getFloat64 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getfloat64
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_float_64)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -265,7 +265,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_float_64)
|
|||
return get_view_value<double>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.9 DataView.prototype.getInt8 ( byteOffset ), https://tc39.es/ecma262/#sec-dataview.prototype.getint8
|
||||
// 25.3.4.10 DataView.prototype.getInt8 ( byteOffset ), https://tc39.es/ecma262/#sec-dataview.prototype.getint8
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_int_8)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -273,7 +273,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_int_8)
|
|||
return get_view_value<i8>(vm, vm.argument(0), Value(true));
|
||||
}
|
||||
|
||||
// 25.3.4.10 DataView.prototype.getInt16 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getint16
|
||||
// 25.3.4.11 DataView.prototype.getInt16 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getint16
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_int_16)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -282,7 +282,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_int_16)
|
|||
return get_view_value<i16>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.11 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getint32
|
||||
// 25.3.4.12 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getint32
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_int_32)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -291,7 +291,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_int_32)
|
|||
return get_view_value<i32>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.12 DataView.prototype.getUint8 ( byteOffset ), https://tc39.es/ecma262/#sec-dataview.prototype.getuint8
|
||||
// 25.3.4.13 DataView.prototype.getUint8 ( byteOffset ), https://tc39.es/ecma262/#sec-dataview.prototype.getuint8
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_uint_8)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -299,7 +299,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_uint_8)
|
|||
return get_view_value<u8>(vm, vm.argument(0), Value(true));
|
||||
}
|
||||
|
||||
// 25.3.4.13 DataView.prototype.getUint16 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getuint16
|
||||
// 25.3.4.14 DataView.prototype.getUint16 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getuint16
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_uint_16)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -308,7 +308,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_uint_16)
|
|||
return get_view_value<u16>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.14 DataView.prototype.getUint32 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getuint32
|
||||
// 25.3.4.15 DataView.prototype.getUint32 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getuint32
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_uint_32)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -317,7 +317,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_uint_32)
|
|||
return get_view_value<u32>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.15 DataView.prototype.setBigInt64 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setbigint64
|
||||
// 25.3.4.16 DataView.prototype.setBigInt64 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setbigint64
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_big_int_64)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -325,7 +325,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_big_int_64)
|
|||
return set_view_value<i64>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.16 DataView.prototype.setBigUint64 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setbiguint64
|
||||
// 25.3.4.17 DataView.prototype.setBigUint64 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setbiguint64
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_big_uint_64)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -333,7 +333,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_big_uint_64)
|
|||
return set_view_value<u64>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
// 7.2 DataView.prototype.setFloat16 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/proposal-float16array/#sec-dataview.prototype.setfloat16
|
||||
// 25.3.4.18 DataView.prototype.setFloat16 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setfloat16
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_float_16)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -342,7 +342,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_float_16)
|
|||
return set_view_value<f16>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.17 DataView.prototype.setFloat32 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setfloat32
|
||||
// 25.3.4.19 DataView.prototype.setFloat32 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setfloat32
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_float_32)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -351,7 +351,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_float_32)
|
|||
return set_view_value<float>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.18 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setfloat64
|
||||
// 25.3.4.20 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setfloat64
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_float_64)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -360,7 +360,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_float_64)
|
|||
return set_view_value<double>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.19 DataView.prototype.setInt8 ( byteOffset, value ), https://tc39.es/ecma262/#sec-dataview.prototype.setint8
|
||||
// 25.3.4.21 DataView.prototype.setInt8 ( byteOffset, value ), https://tc39.es/ecma262/#sec-dataview.prototype.setint8
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_int_8)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -368,7 +368,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_int_8)
|
|||
return set_view_value<i8>(vm, vm.argument(0), Value(true), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.20 DataView.prototype.setInt16 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setint16
|
||||
// 25.3.4.22 DataView.prototype.setInt16 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setint16
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_int_16)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -377,7 +377,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_int_16)
|
|||
return set_view_value<i16>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.21 DataView.prototype.setInt32 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setint32
|
||||
// 25.3.4.23 DataView.prototype.setInt32 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setint32
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_int_32)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -386,7 +386,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_int_32)
|
|||
return set_view_value<i32>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.22 DataView.prototype.setUint8 ( byteOffset, value ), https://tc39.es/ecma262/#sec-dataview.prototype.setuint8
|
||||
// 25.3.4.24 DataView.prototype.setUint8 ( byteOffset, value ), https://tc39.es/ecma262/#sec-dataview.prototype.setuint8
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_uint_8)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -394,7 +394,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_uint_8)
|
|||
return set_view_value<u8>(vm, vm.argument(0), Value(true), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.23 DataView.prototype.setUint16 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setuint16
|
||||
// 25.3.4.25 DataView.prototype.setUint16 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setuint16
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_uint_16)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
@ -403,7 +403,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_uint_16)
|
|||
return set_view_value<u16>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.24 DataView.prototype.setUint32 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setuint32
|
||||
// 25.3.4.26 DataView.prototype.setUint32 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setuint32
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_uint_32)
|
||||
{
|
||||
// 1. Let v be the this value.
|
||||
|
|
|
@ -30,6 +30,7 @@ void MathObject::initialize(Realm& realm)
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
Base::initialize(realm);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.abs, abs, 1, attr, Bytecode::Builtin::MathAbs);
|
||||
define_native_function(realm, vm.names.random, random, 0, attr, Bytecode::Builtin::MathRandom);
|
||||
|
@ -517,7 +518,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::fround)
|
|||
return Value((float)number.as_double());
|
||||
}
|
||||
|
||||
// 3.1 Math.f16round ( x ), https://tc39.es/proposal-float16array/#sec-math.f16round
|
||||
// 21.3.2.18 Math.f16round ( x ), https://tc39.es/ecma262/#sec-math.f16round
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::f16round)
|
||||
{
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
|
@ -537,7 +538,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::f16round)
|
|||
return Value(static_cast<f16>(number.as_double()));
|
||||
}
|
||||
|
||||
// 21.3.2.18 Math.hypot ( ...args ), https://tc39.es/ecma262/#sec-math.hypot
|
||||
// 21.3.2.19 Math.hypot ( ...args ), https://tc39.es/ecma262/#sec-math.hypot
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::hypot)
|
||||
{
|
||||
// 1. Let coerced be a new empty List.
|
||||
|
@ -586,7 +587,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::hypot)
|
|||
return Value(::sqrt(sum_of_squares));
|
||||
}
|
||||
|
||||
// 21.3.2.19 Math.imul ( x, y ), https://tc39.es/ecma262/#sec-math.imul
|
||||
// 21.3.2.20 Math.imul ( x, y ), https://tc39.es/ecma262/#sec-math.imul
|
||||
ThrowCompletionOr<Value> MathObject::imul_impl(VM& vm, Value arg_a, Value arg_b)
|
||||
{
|
||||
// 1. Let a be ℝ(? ToUint32(x)).
|
||||
|
@ -600,13 +601,13 @@ ThrowCompletionOr<Value> MathObject::imul_impl(VM& vm, Value arg_a, Value arg_b)
|
|||
return Value(static_cast<i32>(a * b));
|
||||
}
|
||||
|
||||
// 21.3.2.19 Math.imul ( x, y ), https://tc39.es/ecma262/#sec-math.imul
|
||||
// 21.3.2.20 Math.imul ( x, y ), https://tc39.es/ecma262/#sec-math.imul
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::imul)
|
||||
{
|
||||
return imul_impl(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 21.3.2.20 Math.log ( x ), https://tc39.es/ecma262/#sec-math.log
|
||||
// 21.3.2.21 Math.log ( x ), https://tc39.es/ecma262/#sec-math.log
|
||||
ThrowCompletionOr<Value> MathObject::log_impl(VM& vm, Value x)
|
||||
{
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
|
@ -632,13 +633,13 @@ ThrowCompletionOr<Value> MathObject::log_impl(VM& vm, Value x)
|
|||
return Value(::log(number.as_double()));
|
||||
}
|
||||
|
||||
// 21.3.2.20 Math.log ( x ), https://tc39.es/ecma262/#sec-math.log
|
||||
// 21.3.2.21 Math.log ( x ), https://tc39.es/ecma262/#sec-math.log
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::log)
|
||||
{
|
||||
return log_impl(vm, vm.argument(0));
|
||||
}
|
||||
|
||||
// 21.3.2.21 Math.log1p ( x ), https://tc39.es/ecma262/#sec-math.log1p
|
||||
// 21.3.2.22 Math.log1p ( x ), https://tc39.es/ecma262/#sec-math.log1p
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::log1p)
|
||||
{
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
|
@ -660,7 +661,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::log1p)
|
|||
return Value(::log1p(number.as_double()));
|
||||
}
|
||||
|
||||
// 21.3.2.22 Math.log10 ( x ), https://tc39.es/ecma262/#sec-math.log10
|
||||
// 21.3.2.23 Math.log10 ( x ), https://tc39.es/ecma262/#sec-math.log10
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::log10)
|
||||
{
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
|
@ -686,7 +687,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::log10)
|
|||
return Value(::log10(number.as_double()));
|
||||
}
|
||||
|
||||
// 21.3.2.23 Math.log2 ( x ), https://tc39.es/ecma262/#sec-math.log2
|
||||
// 21.3.2.24 Math.log2 ( x ), https://tc39.es/ecma262/#sec-math.log2
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::log2)
|
||||
{
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
|
@ -712,7 +713,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::log2)
|
|||
return Value(::log2(number.as_double()));
|
||||
}
|
||||
|
||||
// 21.3.2.24 Math.max ( ...args ), https://tc39.es/ecma262/#sec-math.max
|
||||
// 21.3.2.25 Math.max ( ...args ), https://tc39.es/ecma262/#sec-math.max
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::max)
|
||||
{
|
||||
// 1. Let coerced be a new empty List.
|
||||
|
@ -746,7 +747,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::max)
|
|||
return highest;
|
||||
}
|
||||
|
||||
// 21.3.2.25 Math.min ( ...args ), https://tc39.es/ecma262/#sec-math.min
|
||||
// 21.3.2.26 Math.min ( ...args ), https://tc39.es/ecma262/#sec-math.min
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::min)
|
||||
{
|
||||
// 1. Let coerced be a new empty List.
|
||||
|
@ -780,7 +781,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::min)
|
|||
return lowest;
|
||||
}
|
||||
|
||||
// 21.3.2.26 Math.pow ( base, exponent ), https://tc39.es/ecma262/#sec-math.pow
|
||||
// 21.3.2.27 Math.pow ( base, exponent ), https://tc39.es/ecma262/#sec-math.pow
|
||||
ThrowCompletionOr<Value> MathObject::pow_impl(VM& vm, Value base, Value exponent)
|
||||
{
|
||||
// Set base to ? ToNumber(base).
|
||||
|
@ -793,7 +794,7 @@ ThrowCompletionOr<Value> MathObject::pow_impl(VM& vm, Value base, Value exponent
|
|||
return JS::exp(vm, base, exponent);
|
||||
}
|
||||
|
||||
// 21.3.2.26 Math.pow ( base, exponent ), https://tc39.es/ecma262/#sec-math.pow
|
||||
// 21.3.2.27 Math.pow ( base, exponent ), https://tc39.es/ecma262/#sec-math.pow
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::pow)
|
||||
{
|
||||
return pow_impl(vm, vm.argument(0), vm.argument(1));
|
||||
|
@ -849,13 +850,13 @@ Value MathObject::random_impl()
|
|||
return Value(rng.get());
|
||||
}
|
||||
|
||||
// 21.3.2.27 Math.random ( ), https://tc39.es/ecma262/#sec-math.random
|
||||
// 21.3.2.28 Math.random ( ), https://tc39.es/ecma262/#sec-math.random
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::random)
|
||||
{
|
||||
return random_impl();
|
||||
}
|
||||
|
||||
// 21.3.2.28 Math.round ( x ), https://tc39.es/ecma262/#sec-math.round
|
||||
// 21.3.2.29 Math.round ( x ), https://tc39.es/ecma262/#sec-math.round
|
||||
ThrowCompletionOr<Value> MathObject::round_impl(VM& vm, Value x)
|
||||
{
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
|
@ -874,13 +875,13 @@ ThrowCompletionOr<Value> MathObject::round_impl(VM& vm, Value x)
|
|||
return Value(integer);
|
||||
}
|
||||
|
||||
// 21.3.2.28 Math.round ( x ), https://tc39.es/ecma262/#sec-math.round
|
||||
// 21.3.2.29 Math.round ( x ), https://tc39.es/ecma262/#sec-math.round
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::round)
|
||||
{
|
||||
return round_impl(vm, vm.argument(0));
|
||||
}
|
||||
|
||||
// 21.3.2.29 Math.sign ( x ), https://tc39.es/ecma262/#sec-math.sign
|
||||
// 21.3.2.30 Math.sign ( x ), https://tc39.es/ecma262/#sec-math.sign
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::sign)
|
||||
{
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
|
@ -898,7 +899,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::sign)
|
|||
return Value(1);
|
||||
}
|
||||
|
||||
// 21.3.2.30 Math.sin ( x ), https://tc39.es/ecma262/#sec-math.sin
|
||||
// 21.3.2.31 Math.sin ( x ), https://tc39.es/ecma262/#sec-math.sin
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::sin)
|
||||
{
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
|
@ -916,7 +917,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::sin)
|
|||
return Value(::sin(number.as_double()));
|
||||
}
|
||||
|
||||
// 21.3.2.31 Math.sinh ( x ), https://tc39.es/ecma262/#sec-math.sinh
|
||||
// 21.3.2.32 Math.sinh ( x ), https://tc39.es/ecma262/#sec-math.sinh
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::sinh)
|
||||
{
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
|
@ -930,7 +931,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::sinh)
|
|||
return Value(::sinh(number.as_double()));
|
||||
}
|
||||
|
||||
// 21.3.2.32 Math.sqrt ( x ), https://tc39.es/ecma262/#sec-math.sqrt
|
||||
// 21.3.2.33 Math.sqrt ( x ), https://tc39.es/ecma262/#sec-math.sqrt
|
||||
ThrowCompletionOr<Value> MathObject::sqrt_impl(VM& vm, Value x)
|
||||
{
|
||||
// Let n be ? ToNumber(x).
|
||||
|
@ -948,13 +949,13 @@ ThrowCompletionOr<Value> MathObject::sqrt_impl(VM& vm, Value x)
|
|||
return Value(::sqrt(number.as_double()));
|
||||
}
|
||||
|
||||
// 21.3.2.32 Math.sqrt ( x ), https://tc39.es/ecma262/#sec-math.sqrt
|
||||
// 21.3.2.33 Math.sqrt ( x ), https://tc39.es/ecma262/#sec-math.sqrt
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::sqrt)
|
||||
{
|
||||
return sqrt_impl(vm, vm.argument(0));
|
||||
}
|
||||
|
||||
// 21.3.2.33 Math.tan ( x ), https://tc39.es/ecma262/#sec-math.tan
|
||||
// 21.3.2.34 Math.tan ( x ), https://tc39.es/ecma262/#sec-math.tan
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::tan)
|
||||
{
|
||||
// Let n be ? ToNumber(x).
|
||||
|
@ -972,7 +973,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::tan)
|
|||
return Value(::tan(number.as_double()));
|
||||
}
|
||||
|
||||
// 21.3.2.34 Math.tanh ( x ), https://tc39.es/ecma262/#sec-math.tanh
|
||||
// 21.3.2.35 Math.tanh ( x ), https://tc39.es/ecma262/#sec-math.tanh
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::tanh)
|
||||
{
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
|
@ -994,7 +995,7 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::tanh)
|
|||
return Value(::tanh(number.as_double()));
|
||||
}
|
||||
|
||||
// 21.3.2.35 Math.trunc ( x ), https://tc39.es/ecma262/#sec-math.trunc
|
||||
// 21.3.2.36 Math.trunc ( x ), https://tc39.es/ecma262/#sec-math.trunc
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::trunc)
|
||||
{
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue