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

fuzzie fuzzie at fuzzie.org
Sun Jul 3 14:20:36 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:
d7f50b925e MOHAWK: Fix associativity of LBCode operators.


Commit: d7f50b925e1d03416638d38195137401c45d8a2d
    https://github.com/scummvm/scummvm/commit/d7f50b925e1d03416638d38195137401c45d8a2d
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-07-03T05:18:17-07:00

Commit Message:
MOHAWK: Fix associativity of LBCode operators.

Changed paths:
    engines/mohawk/livingbooks_code.cpp



diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 95f3261..83b801e 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -277,27 +277,27 @@ LBValue LBCode::runCode(byte terminator) {
 void LBCode::parseStatement() {
 	parseComparisons();
 
-	if (_currToken != kTokenAnd && _currToken != kTokenOr)
-		return;
-	byte op = _currToken;
-	if (op == kTokenAnd)
-		debugN(" && ");
-	else
-		debugN(" || ");
+	while (_currToken == kTokenAnd || _currToken == kTokenOr) {
+		byte op = _currToken;
+		if (op == kTokenAnd)
+			debugN(" && ");
+		else
+			debugN(" || ");
 
-	nextToken();
-	parseComparisons();
+		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();
+		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);
+		debugN(" [--> %s]", result ? "true" : "false");
+		_stack.push(result);
+	}
 }
 
 void LBCode::parseComparisons() {
@@ -365,44 +365,43 @@ void LBCode::parseComparisons() {
 void LBCode::parseConcat() {
 	parseArithmetic1();
 
-	if (_currToken != kTokenConcat)
-		return;
-
-	debugN(" & ");
-	nextToken();
-	parseArithmetic1();
+	while (_currToken == kTokenConcat) {
+		debugN(" & ");
+		nextToken();
+		parseArithmetic1();
 
-	LBValue val2 = _stack.pop();
-	LBValue val1 = _stack.pop();
-	Common::String result = val1.toString() + val2.toString();
-	debugN(" [--> \"%s\"]", result.c_str());
-	_stack.push(result);
+		LBValue val2 = _stack.pop();
+		LBValue val1 = _stack.pop();
+		Common::String result = val1.toString() + val2.toString();
+		debugN(" [--> \"%s\"]", result.c_str());
+		_stack.push(result);
+	}
 }
 
 void LBCode::parseArithmetic1() {
 	parseArithmetic2();
 
-	if (_currToken != kTokenMinus && _currToken != kTokenPlus)
-		return;
-
-	byte op = _currToken;
-	if (op == kTokenMinus)
-		debugN(" - ");
-	else if (op == kTokenPlus)
-		debugN(" + ");
-
-	nextToken();
-	parseArithmetic2();
+	while (_currToken == kTokenMinus || _currToken == kTokenPlus) {
+		byte op = _currToken;
+		if (op == kTokenMinus)
+			debugN(" - ");
+		else if (op == kTokenPlus)
+			debugN(" + ");
 
-	LBValue val2 = _stack.pop();
-	LBValue val1 = _stack.pop();
-	LBValue result;
-	// TODO: cope with non-integers
-	if (op == kTokenMinus)
-		result = val1.toInt() - val2.toInt();
-	else
-		result = val1.toInt() + val2.toInt();
-	_stack.push(result);
+		nextToken();
+		parseArithmetic2();
+
+		LBValue val2 = _stack.pop();
+		LBValue val1 = _stack.pop();
+		LBValue result;
+		// TODO: cope with non-integers
+		if (op == kTokenMinus)
+			result = val1.toInt() - val2.toInt();
+		else
+			result = val1.toInt() + val2.toInt();
+		debugN(" [--> %d]", result.toInt());
+		_stack.push(result);
+	}
 }
 
 void LBCode::parseArithmetic2() {






More information about the Scummvm-git-logs mailing list