mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 01:05:08 +00:00
LibJS: Implement multiplication and division operators
This commit is contained in:
parent
9f3f0d9983
commit
fdf7f81ba9
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