[Scummvm-git-logs] scummvm master -> aff4813a59dc1835cb5e9c5519988fe9387f5a0d
sev-
noreply at scummvm.org
Tue May 30 21:37:16 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
85f9e5239e DIRECTOR: LINGO: Implement Datum::isArray()
aff4813a59 DIRECTOR: LINGO: Fix POINT/RECT comparison op
Commit: 85f9e5239e20ae7cf8dd4f818d066f67fb1d5ec3
https://github.com/scummvm/scummvm/commit/85f9e5239e20ae7cf8dd4f818d066f67fb1d5ec3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-05-30T23:29:33+02:00
Commit Message:
DIRECTOR: LINGO: Implement Datum::isArray()
Changed paths:
engines/director/lingo/lingo.cpp
engines/director/lingo/lingo.h
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index afc3f4b1fc0..d25ed674633 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -1206,6 +1206,10 @@ bool Datum::isCastRef() const {
return (type == CASTREF || type == FIELDREF);
}
+bool Datum::isArray() const {
+ return (type == ARRAY || type == POINT || type == RECT);
+}
+
const char *Datum::type2str(bool ilk) const {
static char res[20];
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index fca4f4841ee..46da22f4dce 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -177,6 +177,7 @@ struct Datum { /* interpreter stack type */
bool isRef() const;
bool isVarRef() const;
bool isCastRef() const;
+ bool isArray() const;
const char *type2str(bool ilk = false) const;
Commit: aff4813a59dc1835cb5e9c5519988fe9387f5a0d
https://github.com/scummvm/scummvm/commit/aff4813a59dc1835cb5e9c5519988fe9387f5a0d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-05-30T23:35:36+02:00
Commit Message:
DIRECTOR: LINGO: Fix POINT/RECT comparison op
Changed paths:
engines/director/lingo/lingo-code.cpp
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 5daddac0d89..4274a5657aa 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -661,13 +661,6 @@ void LC::c_swap() {
g_lingo->push(d1);
}
-static bool isArray(Datum &d1) {
- if (d1.type == ARRAY || d1.type == POINT || d1.type == RECT)
- return true;
-
- return false;
-}
-
static DatumType getArrayAlignedType(Datum &d1, Datum &d2) {
if (d1.type == POINT && d2.type == ARRAY && d2.u.farr->arr.size() < 2)
return ARRAY;
@@ -681,7 +674,7 @@ static DatumType getArrayAlignedType(Datum &d1, Datum &d2) {
if (d1.type == RECT)
return RECT;
- if (!isArray(d1))
+ if (!d1.isArray())
return d2.type;
return ARRAY;
@@ -690,9 +683,9 @@ static DatumType getArrayAlignedType(Datum &d1, Datum &d2) {
Datum LC::mapBinaryOp(Datum (*mapFunc)(Datum &, Datum &), Datum &d1, Datum &d2) {
// At least one of d1 and d2 must be an array
uint arraySize;
- if (isArray(d1) && isArray(d2)) {
+ if (d1.isArray() && d2.isArray()) {
arraySize = MIN(d1.u.farr->arr.size(), d2.u.farr->arr.size());
- } else if (isArray(d1)) {
+ } else if (d1.isArray()) {
arraySize = d1.u.farr->arr.size();
} else {
arraySize = d2.u.farr->arr.size();
@@ -703,10 +696,10 @@ Datum LC::mapBinaryOp(Datum (*mapFunc)(Datum &, Datum &), Datum &d1, Datum &d2)
Datum a = d1;
Datum b = d2;
for (uint i = 0; i < arraySize; i++) {
- if (isArray(d1)) {
+ if (d1.isArray()) {
a = d1.u.farr->arr[i];
}
- if (isArray(d2)) {
+ if (d2.isArray()) {
b = d2.u.farr->arr[i];
}
res.u.farr->arr[i] = mapFunc(a, b);
@@ -715,7 +708,7 @@ Datum LC::mapBinaryOp(Datum (*mapFunc)(Datum &, Datum &), Datum &d1, Datum &d2)
}
Datum LC::addData(Datum &d1, Datum &d2) {
- if (isArray(d1) || isArray(d2)) {
+ if (d1.isArray() || d2.isArray()) {
return LC::mapBinaryOp(LC::addData, d1, d2);
}
@@ -739,7 +732,7 @@ void LC::c_add() {
}
Datum LC::subData(Datum &d1, Datum &d2) {
- if (isArray(d1) || isArray(d2)) {
+ if (d1.isArray() || d2.isArray()) {
return LC::mapBinaryOp(LC::subData, d1, d2);
}
@@ -763,7 +756,7 @@ void LC::c_sub() {
}
Datum LC::mulData(Datum &d1, Datum &d2) {
- if (isArray(d1) || isArray(d2)) {
+ if (d1.isArray() || d2.isArray()) {
return LC::mapBinaryOp(LC::mulData, d1, d2);
}
@@ -787,7 +780,7 @@ void LC::c_mul() {
}
Datum LC::divData(Datum &d1, Datum &d2) {
- if (isArray(d1) || isArray(d2)) {
+ if (d1.isArray() || d2.isArray()) {
return LC::mapBinaryOp(LC::divData, d1, d2);
}
@@ -821,7 +814,7 @@ void LC::c_div() {
}
Datum LC::modData(Datum &d1, Datum &d2) {
- if (isArray(d1) || isArray(d2)) {
+ if (d1.isArray() || d2.isArray()) {
return LC::mapBinaryOp(LC::modData, d1, d2);
}
@@ -843,7 +836,7 @@ void LC::c_mod() {
}
Datum LC::negateData(Datum &d) {
- if (isArray(d)) {
+ if (d.isArray()) {
uint arraySize = d.u.farr->arr.size();
Datum res;
res.type = d.type;
@@ -1245,15 +1238,15 @@ void LC::c_not() {
Datum LC::compareArrays(Datum (*compareFunc)(Datum, Datum), Datum d1, Datum d2, bool location, bool value) {
// At least one of d1 and d2 must be an array
uint arraySize;
- if (d1.type == ARRAY && d2.type == ARRAY) {
+ if (d1.isArray() && d2.isArray()) {
arraySize = MIN(d1.u.farr->arr.size(), d2.u.farr->arr.size());
} else if (d1.type == PARRAY && d2.type == PARRAY) {
arraySize = MIN(d1.u.parr->arr.size(), d2.u.parr->arr.size());
- } else if (d1.type == ARRAY) {
+ } else if (d1.isArray()) {
arraySize = d1.u.farr->arr.size();
} else if (d1.type == PARRAY) {
arraySize = d1.u.parr->arr.size();
- } else if (d2.type == ARRAY) {
+ } else if (d2.isArray()) {
arraySize = d2.u.farr->arr.size();
} else if (d2.type == PARRAY) {
arraySize = d2.u.parr->arr.size();
@@ -1267,14 +1260,14 @@ Datum LC::compareArrays(Datum (*compareFunc)(Datum, Datum), Datum d1, Datum d2,
Datum a = d1;
Datum b = d2;
for (uint i = 0; i < arraySize; i++) {
- if (d1.type == ARRAY) {
+ if (d1.isArray()) {
a = d1.u.farr->arr[i];
} else if (d1.type == PARRAY) {
PCell t = d1.u.parr->arr[i];
a = value ? t.v : t.p;
}
- if (d2.type == ARRAY) {
+ if (d2.isArray()) {
b = d2.u.farr->arr[i];
} else if (d2.type == PARRAY) {
PCell t = d2.u.parr->arr[i];
@@ -1299,7 +1292,7 @@ Datum LC::compareArrays(Datum (*compareFunc)(Datum, Datum), Datum d1, Datum d2,
Datum LC::eqData(Datum d1, Datum d2) {
// Lingo doesn't bother checking list equality if the left is longer
- if (d1.type == ARRAY && d2.type == ARRAY &&
+ if (d1.isArray() && d2.isArray() &&
d1.u.farr->arr.size() > d2.u.farr->arr.size()) {
return Datum(0);
}
@@ -1307,7 +1300,7 @@ Datum LC::eqData(Datum d1, Datum d2) {
d1.u.parr->arr.size() > d2.u.parr->arr.size()) {
return Datum(0);
}
- if (d1.type == ARRAY || d2.type == ARRAY ||
+ if (d1.isArray() || d2.isArray() ||
d1.type == PARRAY || d2.type == PARRAY) {
return LC::compareArrays(LC::eqData, d1, d2, false, true);
}
@@ -1323,7 +1316,7 @@ void LC::c_eq() {
}
Datum LC::neqData(Datum d1, Datum d2) {
- if (d1.type == ARRAY || d2.type == ARRAY ||
+ if (d1.isArray() || d2.isArray() ||
d1.type == PARRAY || d2.type == PARRAY) {
return LC::compareArrays(LC::neqData, d1, d2, false, true);
}
@@ -1339,7 +1332,7 @@ void LC::c_neq() {
}
Datum LC::gtData(Datum d1, Datum d2) {
- if (d1.type == ARRAY || d2.type == ARRAY ||
+ if (d1.isArray() || d2.isArray() ||
d1.type == PARRAY || d2.type == PARRAY) {
return LC::compareArrays(LC::gtData, d1, d2, false, true);
}
@@ -1355,7 +1348,7 @@ void LC::c_gt() {
}
Datum LC::ltData(Datum d1, Datum d2) {
- if (d1.type == ARRAY || d2.type == ARRAY ||
+ if (d1.isArray() || d2.isArray() ||
d1.type == PARRAY || d2.type == PARRAY) {
return LC::compareArrays(LC::ltData, d1, d2, false, true);
}
@@ -1371,7 +1364,7 @@ void LC::c_lt() {
}
Datum LC::geData(Datum d1, Datum d2) {
- if (d1.type == ARRAY || d2.type == ARRAY ||
+ if (d1.isArray() || d2.isArray() ||
d1.type == PARRAY || d2.type == PARRAY) {
return LC::compareArrays(LC::geData, d1, d2, false, true);
}
@@ -1387,7 +1380,7 @@ void LC::c_ge() {
}
Datum LC::leData(Datum d1, Datum d2) {
- if (d1.type == ARRAY || d2.type == ARRAY ||
+ if (d1.isArray() || d2.isArray() ||
d1.type == PARRAY || d2.type == PARRAY) {
return LC::compareArrays(LC::leData, d1, d2, false, true);
}
More information about the Scummvm-git-logs
mailing list