aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Milburn2013-04-19 00:36:45 +0200
committerAlyssa Milburn2013-04-19 00:36:45 +0200
commit73d629461994675abfbf2444594dcbd136ed9076 (patch)
tree43d8d0d1a59c0ade6d1d820583ea0db62e84158e
parent541a0b8c69d27b331b0f05d1eae4abb661c4d897 (diff)
downloadscummvm-rg350-73d629461994675abfbf2444594dcbd136ed9076.tar.gz
scummvm-rg350-73d629461994675abfbf2444594dcbd136ed9076.tar.bz2
scummvm-rg350-73d629461994675abfbf2444594dcbd136ed9076.zip
MOHAWK: Some LB bytecode improvements.
-rw-r--r--engines/mohawk/livingbooks_code.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 38719e5e00..dabf8676d4 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -519,9 +519,17 @@ void LBCode::parseMain() {
*val = _stack.pop();
_stack.push(*val);
} else
- _stack.push(LBValue());
- } else if (_currToken == kTokenAndEquals) {
- debugN(" &= ");
+ error("assignment failed, no dest");
+// _stack.push(LBValue());
+ } else if (_currToken == kTokenPlusEquals || _currToken == kTokenMinusEquals || _currToken == kTokenAndEquals) {
+ // FIXME: do +=/-= belong here?
+ byte token = _currToken;
+ if (_currToken == kTokenPlusEquals)
+ debugN(" += ");
+ else if (_currToken == kTokenMinusEquals)
+ debugN(" -= ");
+ else if (_currToken == kTokenAndEquals)
+ debugN(" &= ");
nextToken();
parseStatement();
if (!_stack.size())
@@ -532,9 +540,19 @@ void LBCode::parseMain() {
else
val = &_vm->_variables[varname];
if (val) {
- if (val->type != kLBValueString)
- error("operator &= used on non-string");
- val->string = val->string + _stack.pop().toString();
+ if (token == kTokenAndEquals) {
+ if (val->type != kLBValueString)
+ error("operator &= used on non-string");
+ val->string = val->string + _stack.pop().toString();
+ } else {
+ // FIXME: non-integers
+ if (val->type != kLBValueInteger)
+ error("operator used on non-integer");
+ if (token == kTokenPlusEquals)
+ val->integer = val->integer + _stack.pop().toInt();
+ else
+ val->integer = val->integer - _stack.pop().toInt();
+ }
_stack.push(*val);
} else
_stack.push(LBValue());
@@ -581,6 +599,7 @@ void LBCode::parseMain() {
debugN("--");
nextToken();
+ // FIXME: do we need to handle indexing?
if (_currToken != kTokenIdentifier)
error("expected identifier");
assert(_currValue.type == kLBValueString);
@@ -710,9 +729,7 @@ void LBCode::parseMain() {
assert(val.isNumeric());
// FIXME
if (prefix == kTokenMinus)
- val.integer--;
- else
- val.integer++;
+ val.integer = -val.integer;
_stack.push(val);
}
}