DIRECTOR: Lingo: Implemented 'me' function support for factories

This commit is contained in:
Eugene Sandulenko 2016-08-02 21:28:47 +03:00
parent 8a29870a8a
commit 0bda622337
3 changed files with 18 additions and 5 deletions

View File

@ -207,12 +207,25 @@ void Lingo::codeArgStore() {
}
int Lingo::codeFunc(Common::String *s, int numpar) {
g_lingo->code1(g_lingo->c_call);
g_lingo->codeString(s->c_str());
int ret = g_lingo->code1(g_lingo->c_call);
if (s->equalsIgnoreCase("me")) {
if (!g_lingo->_currentFactory.empty()) {
g_lingo->codeString(g_lingo->_currentFactory.c_str());
debug(2, "Repaced 'me' with %s", g_lingo->_currentFactory.c_str());
} else {
warning("'me' out of factory method");
g_lingo->codeString(s->c_str());
}
} else {
g_lingo->codeString(s->c_str());
}
inst num = 0;
WRITE_UINT32(&num, numpar);
g_lingo->code1(num);
return ret;
}
void Lingo::codeLabel(int label) {
@ -239,7 +252,7 @@ void Lingo::processIf(int elselabel, int endlabel) {
break;
WRITE_UINT32(&ielse1, else1);
(*_currentScript)[label + 2] = ielse1; /* elsepart */
(*_currentScript)[label + 2] = ielse1; /* elsepart */
(*_currentScript)[label + 3] = iend; /* end, if cond fails */
else1 = label;

View File

@ -2377,7 +2377,7 @@ yyreduce:
case 105:
#line 480 "engines/director/lingo/lingo-gr.y"
{ g_lingo->_indef = true; ;}
{ g_lingo->_indef = true; g_lingo->_currentFactory.clear(); ;}
break;
case 106:

View File

@ -477,7 +477,7 @@ gotomovie: tOF tMOVIE STRING { $$ = $3; }
//
// See also:
// on keyword
defn: tMACRO ID { g_lingo->_indef = true; }
defn: tMACRO ID { g_lingo->_indef = true; g_lingo->_currentFactory.clear(); }
begin argdef nl argstore stmtlist {
g_lingo->code2(g_lingo->c_constpush, (inst)0); // Push fake value on stack
g_lingo->code1(g_lingo->c_procret);