aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/livingbooks_code.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mohawk/livingbooks_code.cpp')
-rw-r--r--engines/mohawk/livingbooks_code.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 165ca4a328..e72318d86a 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -32,6 +32,10 @@ bool LBValue::operator==(const LBValue &x) const {
if (type != x.type) {
if (isNumeric() && x.isNumeric())
return toDouble() == x.toDouble();
+ else if (type == kLBValueString && x.type == kLBValueItemPtr)
+ return string == x.item->getName();
+ else if (type == kLBValueItemPtr && x.type == kLBValueString)
+ return item->getName() == x.string;
else
return false;
}
@@ -246,8 +250,10 @@ LBValue LBCode::runCode(byte terminator) {
parseStatement();
if (_stack.size())
result = _stack.pop();
- if (_currToken == terminator || _currToken == kTokenEndOfFile)
+ if (_currToken == terminator || _currToken == kTokenEndOfFile) {
+ debugN("\n");
break;
+ }
if (_currToken != kTokenEndOfStatement && _currToken != kTokenEndOfFile)
error("missing EOS (got %02x)", _currToken);
debugN("\n");
@@ -437,6 +443,33 @@ void LBCode::parseMain() {
}
break;
+ case kTokenPlusPlus:
+ case kTokenMinusMinus:
+ {
+ byte token = _currToken;
+ if (token == kTokenPlusPlus)
+ debugN("++");
+ else
+ debugN("--");
+ nextToken();
+
+ if (_currToken != kTokenIdentifier)
+ error("expected identifier");
+ assert(_currValue.type == kLBValueString);
+ Common::String varname = _currValue.string;
+ debugN("%s", varname.c_str());
+ LBValue &val = _vm->_variables[varname];
+
+ // FIXME: pre/postincrement for non-integers
+ if (token == kTokenPlusPlus)
+ val.integer++;
+ else
+ val.integer--;
+ _stack.push(val);
+ nextToken();
+ }
+ break;
+
case kTokenLiteral:
case kTokenConstMode:
case kTokenConstEventId: