mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:37:35 +00:00
LibJS: Implement unary plus / minus
This commit is contained in:
parent
5e6e1fd482
commit
a62230770b
9 changed files with 73 additions and 25 deletions
|
@ -303,6 +303,10 @@ Value UnaryExpression::execute(Interpreter& interpreter) const
|
|||
return bitwise_not(lhs_result);
|
||||
case UnaryOp::Not:
|
||||
return Value(!lhs_result.to_boolean());
|
||||
case UnaryOp::Plus:
|
||||
return unary_plus(lhs_result);
|
||||
case UnaryOp::Minus:
|
||||
return unary_minus(lhs_result);
|
||||
case UnaryOp::Typeof:
|
||||
switch (lhs_result.type()) {
|
||||
case Value::Type::Undefined:
|
||||
|
@ -442,6 +446,12 @@ void UnaryExpression::dump(int indent) const
|
|||
case UnaryOp::Not:
|
||||
op_string = "!";
|
||||
break;
|
||||
case UnaryOp::Plus:
|
||||
op_string = "+";
|
||||
break;
|
||||
case UnaryOp::Minus:
|
||||
op_string = "-";
|
||||
break;
|
||||
case UnaryOp::Typeof:
|
||||
op_string = "typeof ";
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue