diff options
author | Linus Groh <mail@linusgroh.de> | 2020-04-23 15:43:10 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-23 19:38:13 +0200 |
commit | 396ecfa2d79be73af9de3f9a1514925e99f02dd4 (patch) | |
tree | ca98f21f5d8ff4e3954afe5361fc47439892a3c3 /Libraries/LibJS/AST.cpp | |
parent | 502d1f5165d623818d04851b1bacf327709b9007 (diff) | |
download | serenity-396ecfa2d79be73af9de3f9a1514925e99f02dd4.zip |
LibJS: Implement bitwise unsigned right shift operator (>>>)
Diffstat (limited to 'Libraries/LibJS/AST.cpp')
-rw-r--r-- | Libraries/LibJS/AST.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
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 <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); |