aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mohawk/livingbooks_code.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 661c2385f8..48c48ba917 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -257,8 +257,29 @@ LBValue LBCode::runCode(byte terminator) {
}
void LBCode::parseStatement() {
- // FIXME: logical operators
parseComparisons();
+
+ if (_currToken != kTokenAnd && _currToken != kTokenOr)
+ return;
+ byte op = _currToken;
+ if (op == kTokenAnd)
+ debugN(" && ");
+ else
+ debugN(" || ");
+
+ nextToken();
+ parseComparisons();
+
+ LBValue val2 = _stack.pop();
+ LBValue val1 = _stack.pop();
+ bool result;
+ if (op == kTokenAnd)
+ result = !val1.isZero() && !val2.isZero();
+ else
+ result = !val1.isZero() || !val2.isZero();
+
+ debugN(" [--> %s]", result ? "true" : "false");
+ _stack.push(result);
}
void LBCode::parseComparisons() {
@@ -320,7 +341,7 @@ void LBCode::parseComparisons() {
}
debugN(" [--> %s]", result ? "true" : "false");
- _stack.push(result ? 1 : 0);
+ _stack.push(result);
}
void LBCode::parseConcat() {