mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibJS: Implement multiplication and division operators
This commit is contained in:
parent
9f3f0d9983
commit
fdf7f81ba9
Notes:
sideshowbarker
2024-07-19 08:45:11 +09:00
Author: https://github.com/deoxxa
Commit: fdf7f81ba9
Pull-request: https://github.com/SerenityOS/serenity/pull/1425
Reviewed-by: https://github.com/sunverwerth
5 changed files with 34 additions and 1 deletions
|
@ -145,7 +145,6 @@ Value right_shift(Value lhs, Value rhs)
|
|||
}
|
||||
|
||||
Value add(Value lhs, Value rhs)
|
||||
|
||||
{
|
||||
ASSERT(lhs.is_number());
|
||||
ASSERT(rhs.is_number());
|
||||
|
@ -159,6 +158,20 @@ Value sub(Value lhs, Value rhs)
|
|||
return Value(lhs.as_double() - rhs.as_double());
|
||||
}
|
||||
|
||||
Value mul(Value lhs, Value rhs)
|
||||
{
|
||||
ASSERT(lhs.is_number());
|
||||
ASSERT(rhs.is_number());
|
||||
return Value(lhs.as_double() * rhs.as_double());
|
||||
}
|
||||
|
||||
Value div(Value lhs, Value rhs)
|
||||
{
|
||||
ASSERT(lhs.is_number());
|
||||
ASSERT(rhs.is_number());
|
||||
return Value(lhs.as_double() / rhs.as_double());
|
||||
}
|
||||
|
||||
Value typed_eq(Value lhs, Value rhs)
|
||||
{
|
||||
if (rhs.type() != lhs.type())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue