[Scummvm-git-logs] scummvm master -> b87b84a48dfef09383004fc62df0c14d8bcb904c
moralrecordings
code at moral.net.au
Wed Jun 10 16:03:55 UTC 2020
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:
b87b84a48d DIRECTOR: Use seperate script pointer for compiler operations
Commit: b87b84a48dfef09383004fc62df0c14d8bcb904c
https://github.com/scummvm/scummvm/commit/b87b84a48dfef09383004fc62df0c14d8bcb904c
Author: Scott Percival (code at moral.net.au)
Date: 2020-06-11T00:02:34+08:00
Commit Message:
DIRECTOR: Use seperate script pointer for compiler operations
Changed paths:
engines/director/lingo/lingo-bytecode.cpp
engines/director/lingo/lingo-codegen.cpp
engines/director/lingo/lingo-gr.cpp
engines/director/lingo/lingo-gr.h
engines/director/lingo/lingo-gr.y
engines/director/lingo/lingo-lex.cpp
engines/director/lingo/lingo.cpp
engines/director/lingo/lingo.h
diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index 692e17e4c9..4782579f3e 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -714,7 +714,6 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
}
_currentScriptContext = new ScriptContext;
- _currentScriptType = type;
_currentEntityId = id;
_archives[_archiveIndex].scriptContexts[type][id] = _currentScriptContext;
@@ -1028,8 +1027,7 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
}
}
- _currentScriptFunction = i;
- _currentScript = new ScriptData;
+ _currentAssembly = new ScriptData;
if (debugChannelSet(5, kDebugLoading)) {
debugC(5, kDebugLoading, "Function %d code:", i);
@@ -1045,7 +1043,7 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
if (opcode == 0x44 || opcode == 0x84) {
// push a constant
- offsetList.push_back(_currentScript->size());
+ offsetList.push_back(_currentAssembly->size());
int arg = 0;
if (opcode == 0x84) {
arg = (uint16)READ_BE_UINT16(&codeStore[pointer]);
@@ -1075,10 +1073,10 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
break;
}
if (opcode == 0x84) {
- offsetList.push_back(_currentScript->size());
- offsetList.push_back(_currentScript->size());
+ offsetList.push_back(_currentAssembly->size());
+ offsetList.push_back(_currentAssembly->size());
} else {
- offsetList.push_back(_currentScript->size());
+ offsetList.push_back(_currentAssembly->size());
}
switch (constant.type) {
case INT:
@@ -1095,7 +1093,7 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
break;
}
} else if (_lingoV4.contains(opcode)) {
- offsetList.push_back(_currentScript->size());
+ offsetList.push_back(_currentAssembly->size());
g_lingo->code1(_lingoV4[opcode]->func);
size_t argc = strlen(_lingoV4[opcode]->proto);
@@ -1105,14 +1103,14 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
switch (_lingoV4[opcode]->proto[c]) {
case 'b':
// read one uint8 as an argument
- offsetList.push_back(_currentScript->size());
+ offsetList.push_back(_currentAssembly->size());
arg = (uint8)codeStore[pointer];
pointer += 1;
break;
case 'w':
// read one uint16 as an argument
- offsetList.push_back(_currentScript->size());
- offsetList.push_back(_currentScript->size());
+ offsetList.push_back(_currentAssembly->size());
+ offsetList.push_back(_currentAssembly->size());
arg = (uint16)READ_BE_UINT16(&codeStore[pointer]);
pointer += 2;
break;
@@ -1159,25 +1157,25 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
// unimplemented instruction
if (opcode < 0x40) { // 1 byte instruction
debugC(5, kDebugCompile, "Unimplemented opcode: 0x%02x", opcode);
- offsetList.push_back(_currentScript->size());
+ offsetList.push_back(_currentAssembly->size());
g_lingo->code1(LC::cb_unk);
g_lingo->codeInt(opcode);
} else if (opcode < 0x80) { // 2 byte instruction
debugC(5, kDebugCompile, "Unimplemented opcode: 0x%02x (%d)", opcode, (uint)codeStore[pointer]);
- offsetList.push_back(_currentScript->size());
+ offsetList.push_back(_currentAssembly->size());
g_lingo->code1(LC::cb_unk1);
g_lingo->codeInt(opcode);
- offsetList.push_back(_currentScript->size());
+ offsetList.push_back(_currentAssembly->size());
g_lingo->codeInt((uint)codeStore[pointer]);
pointer += 1;
} else { // 3 byte instruction
debugC(5, kDebugCompile, "Unimplemented opcode: 0x%02x (%d, %d)", opcode, (uint)codeStore[pointer], (uint)codeStore[pointer+1]);
- offsetList.push_back(_currentScript->size());
+ offsetList.push_back(_currentAssembly->size());
g_lingo->code1(LC::cb_unk2);
g_lingo->codeInt(opcode);
- offsetList.push_back(_currentScript->size());
+ offsetList.push_back(_currentAssembly->size());
g_lingo->codeInt((uint)codeStore[pointer]);
- offsetList.push_back(_currentScript->size());
+ offsetList.push_back(_currentAssembly->size());
g_lingo->codeInt((uint)codeStore[pointer+1]);
pointer += 2;
}
@@ -1192,11 +1190,11 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
int originalJumpAddressLoc = jumpList[j];
int originalJumpInstructionLoc = originalJumpAddressLoc-1;
int jumpAddressPc = offsetList[originalJumpAddressLoc];
- int jump = getInt(jumpAddressPc);
+ int jump = (int)READ_UINT32(&((*_currentAssembly)[jumpAddressPc]));
int oldTarget = originalJumpInstructionLoc + jump;
if ((oldTarget >= 0) && (oldTarget < (int)offsetList.size())) {
int newJump = offsetList[oldTarget];
- WRITE_UINT32(&((*_currentScript)[jumpAddressPc]), newJump - jumpAddressPc + 1);
+ WRITE_UINT32(&((*_currentAssembly)[jumpAddressPc]), newJump - jumpAddressPc + 1);
} else {
warning("Jump of %d from position %d is outside the function!", jump, originalJumpAddressLoc);
}
@@ -1206,12 +1204,12 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
Symbol sym;
if (nameIndex < _archives[_archiveIndex].names.size()) {
debugC(5, kDebugLoading, "Function %d binding: %s()", i, _archives[_archiveIndex].names[nameIndex].c_str());
- sym = g_lingo->define(_archives[_archiveIndex].names[nameIndex], argCount, _currentScript, argNames, varNames);
+ sym = g_lingo->define(_archives[_archiveIndex].names[nameIndex], argCount, _currentAssembly, argNames, varNames);
} else {
warning("Function has unknown name id %d, skipping define", nameIndex);
sym.name = new Common::String();
sym.type = HANDLER;
- sym.u.defn = _currentScript;
+ sym.u.defn = _currentAssembly;
sym.nargs = argCount;
sym.maxArgs = argCount;
sym.argNames = argNames;
@@ -1225,16 +1223,16 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
out.writeString(Common::String::format("<noname>, %d args\n", argCount));
uint pc = 0;
- while (pc < _currentScript->size()) {
+ while (pc < _currentAssembly->size()) {
uint spc = pc;
- Common::String instr = decodeInstruction(_currentScript, pc, &pc);
+ Common::String instr = decodeInstruction(_currentAssembly, pc, &pc);
out.writeString(Common::String::format("[%5d] %s\n", spc, instr.c_str()));
}
out.writeString(Common::String::format("<end code>\n\n"));
}
_currentScriptContext->functions.push_back(sym);
-
+ _currentAssembly = nullptr;
}
if (!skipdump && ConfMan.getBool("dump_scripts")) {
diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp
index 2e0c8b6002..1dd0d8e613 100644
--- a/engines/director/lingo/lingo-codegen.cpp
+++ b/engines/director/lingo/lingo-codegen.cpp
@@ -108,13 +108,13 @@ Symbol Lingo::define(Common::String &name, int nargs, ScriptData *code, Common::
Symbol Lingo::codeDefine(Common::String &name, int start, int nargs, Object *factory, int end, bool removeCode) {
debugC(1, kDebugCompile, "codeDefine(\"%s\"(len: %d), %d, %d, \"%s\", %d) entity: %d",
- name.c_str(), _currentScript->size() - 1, start, nargs, (factory ? factory->name->c_str() : ""),
+ name.c_str(), _currentAssembly->size() - 1, start, nargs, (factory ? factory->name->c_str() : ""),
end, _currentEntityId);
if (end == -1)
- end = _currentScript->size();
+ end = _currentAssembly->size();
- ScriptData *code = new ScriptData(&(*_currentScript)[start], end - start);
+ ScriptData *code = new ScriptData(&(*_currentAssembly)[start], end - start);
Common::Array<Common::String> *argNames = new Common::Array<Common::String>;
for (uint i = 0; i < _argstack.size(); i++) {
argNames->push_back(Common::String(_argstack[i]->c_str()));
@@ -126,10 +126,10 @@ Symbol Lingo::codeDefine(Common::String &name, int start, int nargs, Object *fac
}
Symbol sym = define(name, nargs, code, argNames, varNames, factory);
- // Now remove all defined code from the _currentScript
+ // Now remove all defined code from the _currentAssembly
if (removeCode)
for (int i = end - 1; i >= start; i--) {
- _currentScript->remove_at(i);
+ _currentAssembly->remove_at(i);
}
return sym;
@@ -139,34 +139,34 @@ int Lingo::codeString(const char *str) {
int numInsts = calcStringAlignment(str);
// Where we copy the string over
- int pos = _currentScript->size();
+ int pos = _currentAssembly->size();
// Allocate needed space in script
for (int i = 0; i < numInsts; i++)
- _currentScript->push_back(0);
+ _currentAssembly->push_back(0);
- byte *dst = (byte *)&_currentScript->front() + pos * sizeof(inst);
+ byte *dst = (byte *)&_currentAssembly->front() + pos * sizeof(inst);
memcpy(dst, str, strlen(str) + 1);
- return _currentScript->size();
+ return _currentAssembly->size();
}
int Lingo::codeFloat(double f) {
int numInsts = calcCodeAlignment(sizeof(double));
// Where we copy the string over
- int pos = _currentScript->size();
+ int pos = _currentAssembly->size();
// Allocate needed space in script
for (int i = 0; i < numInsts; i++)
- _currentScript->push_back(0);
+ _currentAssembly->push_back(0);
- double *dst = (double *)((byte *)&_currentScript->front() + pos * sizeof(inst));
+ double *dst = (double *)((byte *)&_currentAssembly->front() + pos * sizeof(inst));
*dst = f;
- return _currentScript->size();
+ return _currentAssembly->size();
}
int Lingo::codeInt(int val) {
@@ -174,7 +174,7 @@ int Lingo::codeInt(int val) {
WRITE_UINT32(&i, val);
g_lingo->code1(i);
- return _currentScript->size();
+ return _currentAssembly->size();
}
bool Lingo::isInArgStack(Common::String *s) {
@@ -246,7 +246,7 @@ void Lingo::processIf(int toplabel, int endlabel) {
WRITE_UINT32(&iend, endlabel - label + 1);
- (*_currentScript)[label] = iend; /* end, if cond fails */
+ (*_currentAssembly)[label] = iend; /* end, if cond fails */
}
}
diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp
index c0c4197e55..83cd52daf9 100644
--- a/engines/director/lingo/lingo-gr.cpp
+++ b/engines/director/lingo/lingo-gr.cpp
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.6.3. */
+/* A Bison parser, made by GNU Bison 3.6.2. */
/* Bison implementation for Yacc-like parsers in C
@@ -49,7 +49,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "3.6.3"
+#define YYBISON_VERSION "3.6.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -860,7 +860,7 @@ static const yytype_int8 yytranslate[] =
};
#if YYDEBUG
- /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
+ /* YYRLINEYYN -- Source line where rule number YYN was defined. */
static const yytype_int16 yyrline[] =
{
0, 198, 198, 199, 201, 202, 203, 205, 212, 216,
@@ -955,7 +955,7 @@ static const yytype_int16 yytoknum[] =
#define yytable_value_is_error(Yyn) \
0
- /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ /* YYPACTSTATE-NUM -- Index in YYTABLE of the portion describing
STATE-NUM. */
static const yytype_int16 yypact[] =
{
@@ -998,7 +998,7 @@ static const yytype_int16 yypact[] =
-300, -300, 1110, 1532, -300, -300, -300, 1616, -300
};
- /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
+ /* YYDEFACTSTATE-NUM -- Default reduction number in state STATE-NUM.
Performed when YYTABLE does not specify something else to do. Zero
means the default is an error. */
static const yytype_uint8 yydefact[] =
@@ -1042,7 +1042,7 @@ static const yytype_uint8 yydefact[] =
53, 48, 0, 0, 53, 47, 29, 0, 33
};
- /* YYPGOTO[NTERM-NUM]. */
+ /* YYPGOTONTERM-NUM. */
static const yytype_int16 yypgoto[] =
{
-300, 98, -300, -300, -41, 15, -300, -300, -300, -300,
@@ -1053,7 +1053,7 @@ static const yytype_int16 yypgoto[] =
-300, 13, -32, -300, -300, -300, -300, 43
};
- /* YYDEFGOTO[NTERM-NUM]. */
+ /* YYDEFGOTONTERM-NUM. */
static const yytype_int16 yydefgoto[] =
{
-1, 45, 46, 47, 48, 313, 303, 330, 355, 304,
@@ -1064,7 +1064,7 @@ static const yytype_int16 yydefgoto[] =
61, 154, 77, 62, 121, 122, 123, 124
};
- /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
+ /* YYTABLEYYPACT[STATE-NUM] -- What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule whose
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_int16 yytable[] =
@@ -1593,7 +1593,7 @@ static const yytype_int16 yycheck[] =
89, 90, 91, 92, 93, 94
};
- /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ /* YYSTOSSTATE-NUM -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
@@ -1636,7 +1636,7 @@ static const yytype_uint8 yystos[] =
122, 114, 127, 127, 122, 123, 86, 127, 86
};
- /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+ /* YYR1YYN -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
0, 103, 104, 104, 105, 105, 105, 106, 106, 106,
@@ -1659,7 +1659,7 @@ static const yytype_uint8 yyr1[] =
157, 157, 158, 158, 159, 159, 160, 160
};
- /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
+ /* YYR2YYN -- Number of symbols on the right hand side of rule YYN. */
static const yytype_int8 yyr2[] =
{
0, 2, 1, 3, 0, 1, 1, 4, 4, 6,
@@ -2454,8 +2454,8 @@ yyreduce:
inst start = 0, end = 0;
WRITE_UINT32(&start, (yyvsp[-5].code) - (yyvsp[-1].code) + 1);
WRITE_UINT32(&end, (yyvsp[-1].code) - (yyvsp[-3].code) + 2);
- (*g_lingo->_currentScript)[(yyvsp[-3].code)] = end; /* end, if cond fails */
- (*g_lingo->_currentScript)[(yyvsp[-1].code)] = start; }
+ (*g_lingo->_currentAssembly)[(yyvsp[-3].code)] = end; /* end, if cond fails */
+ (*g_lingo->_currentAssembly)[(yyvsp[-1].code)] = start; }
#line 2460 "engines/director/lingo/lingo-gr.cpp"
break;
@@ -2493,13 +2493,13 @@ yyreduce:
g_lingo->codeString((yyvsp[-11].s)->c_str());
g_lingo->code1(LC::c_assign);
g_lingo->code2(LC::c_jump, 0);
- int pos = g_lingo->_currentScript->size() - 1;
+ int pos = g_lingo->_currentAssembly->size() - 1;
inst loop = 0, end = 0;
WRITE_UINT32(&loop, (yyvsp[-7].code) - pos + 2);
WRITE_UINT32(&end, pos - (yyvsp[-2].code) + 2);
- (*g_lingo->_currentScript)[pos] = loop; /* final count value */
- (*g_lingo->_currentScript)[(yyvsp[-2].code)] = end; }
+ (*g_lingo->_currentAssembly)[pos] = loop; /* final count value */
+ (*g_lingo->_currentAssembly)[(yyvsp[-2].code)] = end; }
#line 2504 "engines/director/lingo/lingo-gr.cpp"
break;
@@ -2537,13 +2537,13 @@ yyreduce:
g_lingo->codeString((yyvsp[-12].s)->c_str());
g_lingo->code1(LC::c_assign);
g_lingo->code2(LC::c_jump, 0);
- int pos = g_lingo->_currentScript->size() - 1;
+ int pos = g_lingo->_currentAssembly->size() - 1;
inst loop = 0, end = 0;
WRITE_UINT32(&loop, (yyvsp[-8].code) - pos + 2);
WRITE_UINT32(&end, pos - (yyvsp[-2].code) + 2);
- (*g_lingo->_currentScript)[pos] = loop; /* final count value */
- (*g_lingo->_currentScript)[(yyvsp[-2].code)] = end; }
+ (*g_lingo->_currentAssembly)[pos] = loop; /* final count value */
+ (*g_lingo->_currentAssembly)[(yyvsp[-2].code)] = end; }
#line 2548 "engines/director/lingo/lingo-gr.cpp"
break;
@@ -2600,8 +2600,8 @@ yyreduce:
WRITE_UINT32(&loop, (yyvsp[-5].code) - jump);
WRITE_UINT32(&end, end2 - (yyvsp[-3].code) + 1);
- (*g_lingo->_currentScript)[jump + 1] = loop; /* final count value */
- (*g_lingo->_currentScript)[(yyvsp[-3].code)] = end; }
+ (*g_lingo->_currentAssembly)[jump + 1] = loop; /* final count value */
+ (*g_lingo->_currentAssembly)[(yyvsp[-3].code)] = end; }
#line 2606 "engines/director/lingo/lingo-gr.cpp"
break;
@@ -2644,8 +2644,8 @@ yyreduce:
inst else1 = 0, end3 = 0;
WRITE_UINT32(&else1, (yyvsp[-3].code) + 1 - (yyvsp[-6].code) + 1);
WRITE_UINT32(&end3, (yyvsp[-1].code) - (yyvsp[-3].code) + 1);
- (*g_lingo->_currentScript)[(yyvsp[-6].code)] = else1; /* elsepart */
- (*g_lingo->_currentScript)[(yyvsp[-3].code)] = end3; /* end, if cond fails */
+ (*g_lingo->_currentAssembly)[(yyvsp[-6].code)] = else1; /* elsepart */
+ (*g_lingo->_currentAssembly)[(yyvsp[-3].code)] = end3; /* end, if cond fails */
g_lingo->processIf((yyvsp[-3].code), (yyvsp[-1].code)); }
#line 2651 "engines/director/lingo/lingo-gr.cpp"
break;
@@ -2656,8 +2656,8 @@ yyreduce:
inst else1 = 0, end = 0;
WRITE_UINT32(&else1, (yyvsp[-5].code) + 1 - (yyvsp[-8].code) + 1);
WRITE_UINT32(&end, (yyvsp[-1].code) - (yyvsp[-5].code) + 1);
- (*g_lingo->_currentScript)[(yyvsp[-8].code)] = else1; /* elsepart */
- (*g_lingo->_currentScript)[(yyvsp[-5].code)] = end; /* end, if cond fails */
+ (*g_lingo->_currentAssembly)[(yyvsp[-8].code)] = else1; /* elsepart */
+ (*g_lingo->_currentAssembly)[(yyvsp[-5].code)] = end; /* end, if cond fails */
g_lingo->processIf((yyvsp[-5].code), (yyvsp[-1].code)); }
#line 2663 "engines/director/lingo/lingo-gr.cpp"
break;
@@ -2667,7 +2667,7 @@ yyreduce:
{
inst else1 = 0;
WRITE_UINT32(&else1, (yyvsp[0].code) + 1 - (yyvsp[-3].code) + 1);
- (*g_lingo->_currentScript)[(yyvsp[-3].code)] = else1; /* end, if cond fails */
+ (*g_lingo->_currentAssembly)[(yyvsp[-3].code)] = else1; /* end, if cond fails */
g_lingo->codeLabel((yyvsp[0].code)); }
#line 2673 "engines/director/lingo/lingo-gr.cpp"
break;
@@ -2676,7 +2676,7 @@ yyreduce:
#line 449 "engines/director/lingo/lingo-gr.y"
{
g_lingo->code2(LC::c_jumpifz, 0);
- (yyval.code) = g_lingo->_currentScript->size() - 1; }
+ (yyval.code) = g_lingo->_currentAssembly->size() - 1; }
#line 2681 "engines/director/lingo/lingo-gr.cpp"
break;
@@ -2684,7 +2684,7 @@ yyreduce:
#line 453 "engines/director/lingo/lingo-gr.y"
{
g_lingo->code2(LC::c_jump, 0);
- (yyval.code) = g_lingo->_currentScript->size() - 1; }
+ (yyval.code) = g_lingo->_currentAssembly->size() - 1; }
#line 2689 "engines/director/lingo/lingo-gr.cpp"
break;
@@ -2692,7 +2692,7 @@ yyreduce:
#line 457 "engines/director/lingo/lingo-gr.y"
{
g_lingo->code1(LC::c_assign);
- (yyval.code) = g_lingo->_currentScript->size() - 1; }
+ (yyval.code) = g_lingo->_currentAssembly->size() - 1; }
#line 2697 "engines/director/lingo/lingo-gr.cpp"
break;
@@ -2705,13 +2705,13 @@ yyreduce:
case 52:
#line 464 "engines/director/lingo/lingo-gr.y"
- { (yyval.code) = g_lingo->_currentScript->size(); }
+ { (yyval.code) = g_lingo->_currentAssembly->size(); }
#line 2710 "engines/director/lingo/lingo-gr.cpp"
break;
case 53:
#line 466 "engines/director/lingo/lingo-gr.y"
- { (yyval.code) = g_lingo->_currentScript->size(); }
+ { (yyval.code) = g_lingo->_currentAssembly->size(); }
#line 2716 "engines/director/lingo/lingo-gr.cpp"
break;
diff --git a/engines/director/lingo/lingo-gr.h b/engines/director/lingo/lingo-gr.h
index fd848f68f9..4310d7d043 100644
--- a/engines/director/lingo/lingo-gr.h
+++ b/engines/director/lingo/lingo-gr.h
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.6.3. */
+/* A Bison parser, made by GNU Bison 3.6.2. */
/* Bison interface for Yacc-like parsers in C
diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y
index 87949fb80e..16a21955c1 100644
--- a/engines/director/lingo/lingo-gr.y
+++ b/engines/director/lingo/lingo-gr.y
@@ -299,8 +299,8 @@ stmt: stmtoneliner
inst start = 0, end = 0;
WRITE_UINT32(&start, $lbl - $end2 + 1);
WRITE_UINT32(&end, $end2 - $body + 2);
- (*g_lingo->_currentScript)[$body] = end; /* end, if cond fails */
- (*g_lingo->_currentScript)[$end2] = start; } /* looping back */
+ (*g_lingo->_currentAssembly)[$body] = end; /* end, if cond fails */
+ (*g_lingo->_currentAssembly)[$end2] = start; } /* looping back */
// repeat with index = start to end
// statements
@@ -325,13 +325,13 @@ stmt: stmtoneliner
g_lingo->codeString($ID->c_str());
g_lingo->code1(LC::c_assign);
g_lingo->code2(LC::c_jump, 0);
- int pos = g_lingo->_currentScript->size() - 1;
+ int pos = g_lingo->_currentAssembly->size() - 1;
inst loop = 0, end = 0;
WRITE_UINT32(&loop, $varassign - pos + 2);
WRITE_UINT32(&end, pos - $jumpifz + 2);
- (*g_lingo->_currentScript)[pos] = loop; /* final count value */
- (*g_lingo->_currentScript)[$jumpifz] = end; } /* end, if cond fails */
+ (*g_lingo->_currentAssembly)[pos] = loop; /* final count value */
+ (*g_lingo->_currentAssembly)[$jumpifz] = end; } /* end, if cond fails */
// repeat with index = high down to low
// statements
@@ -357,13 +357,13 @@ stmt: stmtoneliner
g_lingo->codeString($ID->c_str());
g_lingo->code1(LC::c_assign);
g_lingo->code2(LC::c_jump, 0);
- int pos = g_lingo->_currentScript->size() - 1;
+ int pos = g_lingo->_currentAssembly->size() - 1;
inst loop = 0, end = 0;
WRITE_UINT32(&loop, $varassign - pos + 2);
WRITE_UINT32(&end, pos - $jumpifz + 2);
- (*g_lingo->_currentScript)[pos] = loop; /* final count value */
- (*g_lingo->_currentScript)[$jumpifz] = end; } /* end, if cond fails */
+ (*g_lingo->_currentAssembly)[pos] = loop; /* final count value */
+ (*g_lingo->_currentAssembly)[$jumpifz] = end; } /* end, if cond fails */
// repeat with index in list
@@ -409,8 +409,8 @@ stmt: stmtoneliner
WRITE_UINT32(&loop, $lbl - jump);
WRITE_UINT32(&end, end2 - $jumpifz + 1);
- (*g_lingo->_currentScript)[jump + 1] = loop; /* final count value */
- (*g_lingo->_currentScript)[$jumpifz] = end; } /* end, if cond fails */
+ (*g_lingo->_currentAssembly)[jump + 1] = loop; /* final count value */
+ (*g_lingo->_currentAssembly)[$jumpifz] = end; } /* end, if cond fails */
| tNEXT tREPEAT {
g_lingo->code1(LC::c_nextRepeat); }
@@ -426,15 +426,15 @@ ifstmt: if expr jumpifz[then] tTHEN stmtlist jump[else1] elseifstmtlist lbl[end3
inst else1 = 0, end3 = 0;
WRITE_UINT32(&else1, $else1 + 1 - $then + 1);
WRITE_UINT32(&end3, $end3 - $else1 + 1);
- (*g_lingo->_currentScript)[$then] = else1; /* elsepart */
- (*g_lingo->_currentScript)[$else1] = end3; /* end, if cond fails */
+ (*g_lingo->_currentAssembly)[$then] = else1; /* elsepart */
+ (*g_lingo->_currentAssembly)[$else1] = end3; /* end, if cond fails */
g_lingo->processIf($else1, $end3); }
| if expr jumpifz[then] tTHEN stmtlist jump[else1] elseifstmtlist tELSE stmtlist lbl[end3] tENDIF {
inst else1 = 0, end = 0;
WRITE_UINT32(&else1, $else1 + 1 - $then + 1);
WRITE_UINT32(&end, $end3 - $else1 + 1);
- (*g_lingo->_currentScript)[$then] = else1; /* elsepart */
- (*g_lingo->_currentScript)[$else1] = end; /* end, if cond fails */
+ (*g_lingo->_currentAssembly)[$then] = else1; /* elsepart */
+ (*g_lingo->_currentAssembly)[$else1] = end; /* end, if cond fails */
g_lingo->processIf($else1, $end3); }
elseifstmtlist: /* nothing */
@@ -443,27 +443,27 @@ elseifstmtlist: /* nothing */
elseifstmt: tELSIF expr jumpifz[then] tTHEN stmtlist jump[end3] {
inst else1 = 0;
WRITE_UINT32(&else1, $end3 + 1 - $then + 1);
- (*g_lingo->_currentScript)[$then] = else1; /* end, if cond fails */
+ (*g_lingo->_currentAssembly)[$then] = else1; /* end, if cond fails */
g_lingo->codeLabel($end3); }
jumpifz: /* nothing */ {
g_lingo->code2(LC::c_jumpifz, 0);
- $$ = g_lingo->_currentScript->size() - 1; }
+ $$ = g_lingo->_currentAssembly->size() - 1; }
jump: /* nothing */ {
g_lingo->code2(LC::c_jump, 0);
- $$ = g_lingo->_currentScript->size() - 1; }
+ $$ = g_lingo->_currentAssembly->size() - 1; }
varassign: /* nothing */ {
g_lingo->code1(LC::c_assign);
- $$ = g_lingo->_currentScript->size() - 1; }
+ $$ = g_lingo->_currentAssembly->size() - 1; }
if: tIF {
g_lingo->codeLabel(0); } // Mark beginning of the if() statement
-lbl: /* nothing */ { $$ = g_lingo->_currentScript->size(); }
+lbl: /* nothing */ { $$ = g_lingo->_currentAssembly->size(); }
-stmtlist: { $$ = g_lingo->_currentScript->size(); }
+stmtlist: { $$ = g_lingo->_currentAssembly->size(); }
| stmtlist '\n'
| stmtlist stmt
diff --git a/engines/director/lingo/lingo-lex.cpp b/engines/director/lingo/lingo-lex.cpp
index ffd626ec20..0167fdda9f 100644
--- a/engines/director/lingo/lingo-lex.cpp
+++ b/engines/director/lingo/lingo-lex.cpp
@@ -427,7 +427,7 @@ static const YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 2, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 437a5b3544..2ffe060891 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -146,9 +146,7 @@ Lingo::Lingo(DirectorEngine *vm) : _vm(vm) {
g_lingo = this;
_currentScript = 0;
- _currentScriptType = kMovieScript;
_currentScriptContext = nullptr;
- _currentScriptFunction = 0;
_currentMeObj = nullptr;
_currentEntityId = 0;
@@ -290,14 +288,10 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) {
}
_currentScriptContext = new ScriptContext;
- _currentScript = new ScriptData;
- _currentScriptType = type;
+ _currentAssembly = new ScriptData;
_currentEntityId = id;
_archives[_archiveIndex].scriptContexts[type][id] = _currentScriptContext;
- // FIXME: unpack into seperate functions
- _currentScriptFunction = 0;
-
_methodVars = new Common::HashMap<Common::String, VarType, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo>();
_linenumber = _colnumber = 1;
_hadError = false;
@@ -335,9 +329,9 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) {
if (debugChannelSet(3, kDebugCompile)) {
debugC(2, kDebugCompile, "<current code>");
uint pc = 0;
- while (pc < _currentScript->size()) {
+ while (pc < _currentAssembly->size()) {
uint spc = pc;
- Common::String instr = decodeInstruction(_currentScript, pc, &pc);
+ Common::String instr = decodeInstruction(_currentAssembly, pc, &pc);
debugC(2, kDebugCompile, "[%5d] %s", spc, instr.c_str());
}
debugC(2, kDebugCompile, "<end code>");
@@ -362,14 +356,14 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) {
_inFactory = false;
if (debugChannelSet(3, kDebugCompile)) {
- if (_currentScript->size() && !_hadError)
- Common::hexdump((byte *)&_currentScript->front(), _currentScript->size() * sizeof(inst));
+ if (_currentAssembly->size() && !_hadError)
+ Common::hexdump((byte *)&_currentAssembly->front(), _currentAssembly->size() * sizeof(inst));
debugC(2, kDebugCompile, "<resulting code>");
uint pc = 0;
- while (pc < _currentScript->size()) {
+ while (pc < _currentAssembly->size()) {
uint spc = pc;
- Common::String instr = decodeInstruction(_currentScript, pc, &pc);
+ Common::String instr = decodeInstruction(_currentAssembly, pc, &pc);
debugC(2, kDebugCompile, "[%5d] %s", spc, instr.c_str());
}
debugC(2, kDebugCompile, "<end code>");
@@ -382,7 +376,7 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) {
Symbol currentFunc;
currentFunc.type = HANDLER;
- currentFunc.u.defn = _currentScript;
+ currentFunc.u.defn = _currentAssembly;
// guess the name. don't actually bind it to the event, there's a seperate
// triggering mechanism for that.
if (type == kFrameScript) {
@@ -410,6 +404,7 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) {
currentFunc.argNames = argNames;
currentFunc.varNames = varNames;
_currentScriptContext->functions.push_back(currentFunc);
+ _currentAssembly = nullptr;
}
void Lingo::printStack(const char *s, uint pc) {
@@ -560,7 +555,7 @@ void Lingo::execute(uint pc) {
printAllVars();
}
- if (_pc >= (*_currentScript).size()) {
+ if (!_abort && _pc >= (*_currentScript).size()) {
warning("Lingo::execute(): Bad PC (%d)", _pc);
break;
}
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 64e2e3a508..c0a5a8e247 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -444,7 +444,7 @@ public:
bool isInArgStack(Common::String *s);
void clearArgStack();
- int code1(inst code) { _currentScript->push_back(code); return _currentScript->size() - 1; }
+ int code1(inst code) { _currentAssembly->push_back(code); return _currentAssembly->size() - 1; }
int code2(inst code_1, inst code_2) { int o = code1(code_1); code1(code_2); return o; }
int code3(inst code_1, inst code_2, inst code_3) { int o = code1(code_1); code1(code_2); code1(code_3); return o; }
int code4(inst code_1, inst code_2, inst code_3, inst code_4) { int o = code1(code_1); code1(code_2); code1(code_3); code1(code_4); return o; }
@@ -460,6 +460,7 @@ public:
void processIf(int toplabel, int endlabel);
void varCreate(const Common::String &name, bool global, SymbolHash *localvars = nullptr);
+ ScriptData *_currentAssembly;
LexerDefineState _indef;
int _linenumber;
int _colnumber;
@@ -477,11 +478,9 @@ public:
Common::HashMap<Common::String, VarType, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> *_methodVarsStash;
public:
- ScriptType _currentScriptType;
uint16 _currentEntityId;
int _currentChannelId;
ScriptContext *_currentScriptContext;
- uint16 _currentScriptFunction;
ScriptData *_currentScript;
Object *_currentMeObj;
More information about the Scummvm-git-logs
mailing list