diff options
author | Eugene Sandulenko | 2019-12-01 14:02:26 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2019-12-01 14:25:01 +0100 |
commit | c3dde9220c03f46d76bfeed579cb0a1a833367d9 (patch) | |
tree | 474e110160c7093ae911dec96e581bee80cc3bb0 /engines | |
parent | c489e87bf3c47980cb18558c2d7862659ae47169 (diff) | |
download | scummvm-rg350-c3dde9220c03f46d76bfeed579cb0a1a833367d9.tar.gz scummvm-rg350-c3dde9220c03f46d76bfeed579cb0a1a833367d9.tar.bz2 scummvm-rg350-c3dde9220c03f46d76bfeed579cb0a1a833367d9.zip |
DIRECTOR: LINGO: Properly compile scripts with mixed immediate code and definitions
Diffstat (limited to 'engines')
-rw-r--r-- | engines/director/lingo/lingo-code.cpp | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo-codegen.cpp | 8 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index 05ad0ccfc3..b2607edd55 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -1002,7 +1002,7 @@ void Lingo::c_whencode() { int entity = g_lingo->_currentEntityId; g_lingo->_currentEntityId = 0; - Symbol *sym = g_lingo->define(eventname, start, 0, NULL, end); + Symbol *sym = g_lingo->define(eventname, start, 0, NULL, end, false); // Redefine, but not remove code g_lingo->_currentEntityId = entity; diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp index 2f31f5c1d9..2ba3c0940c 100644 --- a/engines/director/lingo/lingo-codegen.cpp +++ b/engines/director/lingo/lingo-codegen.cpp @@ -212,7 +212,7 @@ void Lingo::cleanLocalVars() { g_lingo->_localvars = 0; } -Symbol *Lingo::define(Common::String &name, int start, int nargs, Common::String *prefix, int end) { +Symbol *Lingo::define(Common::String &name, int start, int nargs, Common::String *prefix, int end, bool removeCode) { if (prefix) name = *prefix + "-" + name; @@ -244,6 +244,12 @@ Symbol *Lingo::define(Common::String &name, int start, int nargs, Common::String sym->nargs = nargs; sym->maxArgs = nargs; + // Now remove all defined code from the _currentScript + if (removeCode) + for (int i = end - 1; i >= start; i--) { + _currentScript->remove_at(i); + } + return sym; } diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 13dbc0a785..872ac214a8 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -214,7 +214,7 @@ public: void popContext(); Symbol *lookupVar(const char *name, bool create = true, bool putInGlobalList = false); void cleanLocalVars(); - Symbol *define(Common::String &s, int start, int nargs, Common::String *prefix = NULL, int end = -1); + Symbol *define(Common::String &s, int start, int nargs, Common::String *prefix = NULL, int end = -1, bool removeCode = true); void processIf(int elselabel, int endlabel); int alignTypes(Datum &d1, Datum &d2); |