aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorAlyssa Milburn2011-04-08 00:21:49 +0200
committerAlyssa Milburn2011-04-08 00:22:04 +0200
commitf0c42f10bda5c8a489fe1ada356eb420c0fa3685 (patch)
treee5f150ce0ba195780746d73bcaeae368f6903a6e /engines
parentb6a4d3e3918e0db611e5075ac6b080e1ceb1d9d4 (diff)
downloadscummvm-rg350-f0c42f10bda5c8a489fe1ada356eb420c0fa3685.tar.gz
scummvm-rg350-f0c42f10bda5c8a489fe1ada356eb420c0fa3685.tar.bz2
scummvm-rg350-f0c42f10bda5c8a489fe1ada356eb420c0fa3685.zip
MOHAWK: Implement LBCode logical operators.
Diffstat (limited to 'engines')
-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() {