DIRECTOR: Lingo: Fix 'if' statement

This commit is contained in:
Eugene Sandulenko 2016-06-20 19:40:56 +02:00
parent db2380077f
commit 34acb99ec5
4 changed files with 21 additions and 8 deletions

View File

@ -84,7 +84,12 @@ go to \"Chair\"\n\
set x = 2 + 3 * (4 / 2)\n\
put x\n", kMovieScript, 2);
_lingo->executeScript(kMovieScript, 2);
_lingo->addCode("set x = 5\n\
if 4 > 3 then x end if\n", kMovieScript, 3);
_lingo->executeScript(kMovieScript, 3);
return Common::kNoError;
//FIXME
_mainArchive = new RIFFArchive();

View File

@ -394,17 +394,25 @@ void Lingo::func_ifcode() {
Datum d;
int savepc = g_lingo->_pc; /* then part */
int then = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc]);
int elsep = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 1]);
int end = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 2]);
warning("cond: %d end: %d then: %d elesp: %d", savepc + 3, end, then, elsep);
g_lingo->execute(savepc + 3); /* condition */
d = g_lingo->pop();
warning("res: %d", d.val);
if (d.val)
g_lingo->execute(savepc);
else if ((*g_lingo->_currentScript)[savepc + 1]) /* else part? */
g_lingo->execute(savepc + 1);
if (d.val) {
g_lingo->execute(then);
} else if (elsep) { /* else part? */
g_lingo->execute(elsep);
}
//if (!returning)
g_lingo->_pc = savepc + 2; /* next stmt */
g_lingo->_pc = end; /* next stmt */
}
//************************

View File

@ -141,7 +141,7 @@
extern int yylex();
extern int yyparse();
void yyerror(char *s) { warning("%s", s); }
void yyerror(char *s) { error("%s", s); }
using namespace Director;

View File

@ -56,7 +56,7 @@
extern int yylex();
extern int yyparse();
void yyerror(char *s) { warning("%s", s); }
void yyerror(char *s) { error("%s", s); }
using namespace Director;