mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 10:09:14 +00:00
LibJS: Implement unary plus / minus
This commit is contained in:
parent
5e6e1fd482
commit
a62230770b
Notes:
sideshowbarker
2024-07-19 07:59:16 +09:00
Author: https://github.com/linusg
Commit: a62230770b
Pull-request: https://github.com/SerenityOS/serenity/pull/1587
9 changed files with 73 additions and 25 deletions
|
@ -191,6 +191,18 @@ Value bitwise_not(Value lhs)
|
|||
return Value(~(i32)lhs.to_number().as_double());
|
||||
}
|
||||
|
||||
Value unary_plus(Value lhs)
|
||||
{
|
||||
return lhs.to_number();
|
||||
}
|
||||
|
||||
Value unary_minus(Value lhs)
|
||||
{
|
||||
if (lhs.to_number().is_nan())
|
||||
return js_nan();
|
||||
return Value(-lhs.to_number().as_double());
|
||||
}
|
||||
|
||||
Value left_shift(Value lhs, Value rhs)
|
||||
{
|
||||
return Value((i32)lhs.to_number().as_double() << (i32)rhs.to_number().as_double());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue