mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 22:25:07 +00:00
LibJS: Implement bitwise unsigned right shift operator (>>>)
This commit is contained in:
parent
502d1f5165
commit
396ecfa2d7
6 changed files with 108 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2020, Linus Groh <mail@linusgroh.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -328,6 +329,8 @@ Value BinaryExpression::execute(Interpreter& interpreter) const
|
|||
return left_shift(interpreter, lhs_result, rhs_result);
|
||||
case BinaryOp::RightShift:
|
||||
return right_shift(interpreter, lhs_result, rhs_result);
|
||||
case BinaryOp::UnsignedRightShift:
|
||||
return unsigned_right_shift(interpreter, lhs_result, rhs_result);
|
||||
case BinaryOp::InstanceOf:
|
||||
return instance_of(interpreter, lhs_result, rhs_result);
|
||||
}
|
||||
|
@ -506,6 +509,9 @@ void BinaryExpression::dump(int indent) const
|
|||
case BinaryOp::RightShift:
|
||||
op_string = ">>";
|
||||
break;
|
||||
case BinaryOp::UnsignedRightShift:
|
||||
op_string = ">>>";
|
||||
break;
|
||||
case BinaryOp::InstanceOf:
|
||||
op_string = "instanceof";
|
||||
break;
|
||||
|
@ -761,6 +767,12 @@ Value AssignmentExpression::execute(Interpreter& interpreter) const
|
|||
return {};
|
||||
rhs_result = right_shift(interpreter, lhs_result, rhs_result);
|
||||
break;
|
||||
case AssignmentOp::UnsignedRightShiftAssignment:
|
||||
lhs_result = m_lhs->execute(interpreter);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
rhs_result = unsigned_right_shift(interpreter, lhs_result, rhs_result);
|
||||
break;
|
||||
}
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
|
@ -834,6 +846,9 @@ void AssignmentExpression::dump(int indent) const
|
|||
case AssignmentOp::RightShiftAssignment:
|
||||
op_string = ">>=";
|
||||
break;
|
||||
case AssignmentOp::UnsignedRightShiftAssignment:
|
||||
op_string = ">>>=";
|
||||
break;
|
||||
}
|
||||
|
||||
ASTNode::dump(indent);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue