hrev48116 adds 1 changeset to branch 'master' old head: 310f631263c46b099f5e50d1f18ddb1293e6a0ae new head: 31b213c5aef7798c821a926fd6666bdd430f64d7 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=31b213c+%5E310f631 ---------------------------------------------------------------------------- 31b213c: Debugger: Implement evaluation of logical operators. - CLanguageExpressionEvaluator now handles all the basic logical comparison operators. Bitwise operators still to come, as some of those may possibly require modifications to the MAPM library. [ Rene Gollent <rene@xxxxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev48116 Commit: 31b213c5aef7798c821a926fd6666bdd430f64d7 URL: http://cgit.haiku-os.org/haiku/commit/?id=31b213c Author: Rene Gollent <rene@xxxxxxxxxxx> Date: Mon Oct 27 03:44:24 2014 UTC ---------------------------------------------------------------------------- 1 file changed, 46 insertions(+), 5 deletions(-) .../CLanguageExpressionEvaluator.cpp | 51 ++++++++++++++++++-- ---------------------------------------------------------------------------- diff --git a/src/apps/debugger/source_language/expression_evaluators/CLanguageExpressionEvaluator.cpp b/src/apps/debugger/source_language/expression_evaluators/CLanguageExpressionEvaluator.cpp index 34721fb..4eacb5e 100644 --- a/src/apps/debugger/source_language/expression_evaluators/CLanguageExpressionEvaluator.cpp +++ b/src/apps/debugger/source_language/expression_evaluators/CLanguageExpressionEvaluator.cpp @@ -673,14 +673,17 @@ CLanguageExpressionEvaluator::_ParseProduct() case TOKEN_STAR: value = value * _ParsePower(); break; - case TOKEN_SLASH: { + case TOKEN_SLASH: + { MAPM rhs = _ParsePower(); if (rhs == MAPM(0)) throw ParseException("division by zero", token.position); value = value / rhs; break; } - case TOKEN_MODULO: { + + case TOKEN_MODULO: + { MAPM rhs = _ParsePower(); if (rhs == MAPM(0)) throw ParseException("modulo by zero", token.position); @@ -688,6 +691,38 @@ CLanguageExpressionEvaluator::_ParseProduct() break; } + case TOKEN_LOGICAL_AND: + value = (value != MAPM(0) && _ParsePower() != MAPM(0)); + break; + + case TOKEN_LOGICAL_OR: + value = (value != MAPM(0) || _ParsePower() != MAPM(0)); + break; + + case TOKEN_EQ: + value = (value == _ParsePower()); + break; + + case TOKEN_NE: + value = (value != _ParsePower()); + break; + + case TOKEN_GT: + value = (value > _ParsePower()); + break; + + case TOKEN_GE: + value = (value >= _ParsePower()); + break; + + case TOKEN_LT: + value = (value < _ParsePower()); + break; + + case TOKEN_LE: + value = (value <= _ParsePower()); + break; + default: fTokenizer->RewindToken(); return value; @@ -722,11 +757,17 @@ CLanguageExpressionEvaluator::_ParseUnary() switch (token.type) { case TOKEN_PLUS: return _ParseUnary(); + case TOKEN_MINUS: return -_ParseUnary(); -// TODO: Implement ! -// case TOKEN_NOT: -// return ~(uint64)_ParseUnary(); + + case TOKEN_BITWISE_AND: + case TOKEN_BITWISE_OR: + case TOKEN_BITWISE_NOT: + throw ParseException("Unimplemented bitwise operator", token.position); + + case TOKEN_LOGICAL_NOT: + return MAPM(_ParseUnary() == 0); case TOKEN_IDENTIFIER: return _ParseIdentifier();