1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-30 03:12:12 +00:00

LibJS: Implement bitwise assignment operators (&=, |=, ^=)

This commit is contained in:
Linus Groh 2020-05-04 22:34:45 +01:00 committed by Andreas Kling
parent 8e4301dea6
commit 3e754a15d4
8 changed files with 62 additions and 2 deletions

View file

@ -850,6 +850,24 @@ Value AssignmentExpression::execute(Interpreter& interpreter) const
return {};
rhs_result = div(interpreter, lhs_result, rhs_result);
break;
case AssignmentOp::BitwiseAndAssignment:
lhs_result = m_lhs->execute(interpreter);
if (interpreter.exception())
return {};
rhs_result = bitwise_and(interpreter, lhs_result, rhs_result);
break;
case AssignmentOp::BitwiseOrAssignment:
lhs_result = m_lhs->execute(interpreter);
if (interpreter.exception())
return {};
rhs_result = bitwise_or(interpreter, lhs_result, rhs_result);
break;
case AssignmentOp::BitwiseXorAssignment:
lhs_result = m_lhs->execute(interpreter);
if (interpreter.exception())
return {};
rhs_result = bitwise_xor(interpreter, lhs_result, rhs_result);
break;
case AssignmentOp::LeftShiftAssignment:
lhs_result = m_lhs->execute(interpreter);
if (interpreter.exception())
@ -936,6 +954,15 @@ void AssignmentExpression::dump(int indent) const
case AssignmentOp::DivisionAssignment:
op_string = "/=";
break;
case AssignmentOp::BitwiseAndAssignment:
op_string = "&=";
break;
case AssignmentOp::BitwiseOrAssignment:
op_string = "|=";
break;
case AssignmentOp::BitwiseXorAssignment:
op_string = "^=";
break;
case AssignmentOp::LeftShiftAssignment:
op_string = "<<=";
break;