From 396ecfa2d79be73af9de3f9a1514925e99f02dd4 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 23 Apr 2020 15:43:10 +0100 Subject: LibJS: Implement bitwise unsigned right shift operator (>>>) --- Libraries/LibJS/AST.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Libraries/LibJS/AST.cpp') diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp index 198f1b297f..1fc0b29bf0 100644 --- a/Libraries/LibJS/AST.cpp +++ b/Libraries/LibJS/AST.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2020, Linus Groh * 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); -- cgit v1.2.3