[Scummvm-cvs-logs] scummvm master -> f0c42f10bda5c8a489fe1ada356eb420c0fa3685

fuzzie fuzzie at fuzzie.org
Fri Apr 8 00:23:54 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f0c42f10bd MOHAWK: Implement LBCode logical operators.


Commit: f0c42f10bda5c8a489fe1ada356eb420c0fa3685
    https://github.com/scummvm/scummvm/commit/f0c42f10bda5c8a489fe1ada356eb420c0fa3685
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-04-07T15:22:04-07:00

Commit Message:
MOHAWK: Implement LBCode logical operators.

Changed paths:
    engines/mohawk/livingbooks_code.cpp



diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 661c238..48c48ba 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() {






More information about the Scummvm-git-logs mailing list