mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:57:45 +00:00
LibJS: Convert to_i8() to ThrowCompletionOr
This commit is contained in:
parent
7bbb92dfe9
commit
1b7dbb6b3b
3 changed files with 4 additions and 4 deletions
|
@ -173,7 +173,7 @@ static ByteBuffer numeric_to_raw_bytes(GlobalObject& global_object, Value value,
|
|||
else if constexpr (sizeof(UnderlyingBufferDataType) == 2)
|
||||
int_value = MUST(value.to_i16(global_object));
|
||||
else
|
||||
int_value = value.to_i8(global_object);
|
||||
int_value = MUST(value.to_i8(global_object));
|
||||
} else {
|
||||
if constexpr (sizeof(UnderlyingBufferDataType) == 4)
|
||||
int_value = MUST(value.to_u32(global_object));
|
||||
|
|
|
@ -639,9 +639,9 @@ ThrowCompletionOr<u16> Value::to_u16(GlobalObject& global_object) const
|
|||
}
|
||||
|
||||
// 7.1.10 ToInt8 ( argument ), https://tc39.es/ecma262/#sec-toint8
|
||||
i8 Value::to_i8(GlobalObject& global_object) const
|
||||
ThrowCompletionOr<i8> Value::to_i8(GlobalObject& global_object) const
|
||||
{
|
||||
double value = TRY_OR_DISCARD(to_number(global_object)).as_double();
|
||||
double value = TRY(to_number(global_object)).as_double();
|
||||
if (!isfinite(value) || value == 0)
|
||||
return 0;
|
||||
auto abs = fabs(value);
|
||||
|
|
|
@ -319,7 +319,7 @@ public:
|
|||
ThrowCompletionOr<u32> to_u32(GlobalObject&) const;
|
||||
ThrowCompletionOr<i16> to_i16(GlobalObject&) const;
|
||||
ThrowCompletionOr<u16> to_u16(GlobalObject&) const;
|
||||
i8 to_i8(GlobalObject&) const;
|
||||
ThrowCompletionOr<i8> to_i8(GlobalObject&) const;
|
||||
u8 to_u8(GlobalObject&) const;
|
||||
u8 to_u8_clamp(GlobalObject&) const;
|
||||
size_t to_length(GlobalObject&) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue