diff options
author | Eugene Sandulenko | 2019-12-01 14:24:05 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2019-12-01 14:25:01 +0100 |
commit | f430e3318aa491ba1c126aea570fcf65bf9e5ec6 (patch) | |
tree | 52d8f884c1c3ef1beae339d1a715e1a23bc8668c /engines/director | |
parent | c3dde9220c03f46d76bfeed579cb0a1a833367d9 (diff) | |
download | scummvm-rg350-f430e3318aa491ba1c126aea570fcf65bf9e5ec6.tar.gz scummvm-rg350-f430e3318aa491ba1c126aea570fcf65bf9e5ec6.tar.bz2 scummvm-rg350-f430e3318aa491ba1c126aea570fcf65bf9e5ec6.zip |
DIRECTOR: LINGO: Fix compilation of the mixed code, and add relevant test
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/lingo/lingo-codegen.cpp | 8 | ||||
-rw-r--r-- | engines/director/lingo/lingo.cpp | 21 | ||||
-rw-r--r-- | engines/director/lingo/tests/mixed-code.lingo | 14 |
3 files changed, 26 insertions, 17 deletions
diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp index 2ba3c0940c..0b974771c9 100644 --- a/engines/director/lingo/lingo-codegen.cpp +++ b/engines/director/lingo/lingo-codegen.cpp @@ -250,6 +250,14 @@ Symbol *Lingo::define(Common::String &name, int start, int nargs, Common::String _currentScript->remove_at(i); } + if (debugChannelSet(1, kDebugLingoExec)) { + uint pc = 0; + while (pc < sym->u.defn->size()) { + Common::String instr = g_lingo->decodeInstruction(sym->u.defn, pc, &pc); + debugC(1, kDebugLingoExec, "[%5d] %s", pc, instr.c_str()); + } + } + return sym; } diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index 703a5b28c4..d009893747 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -155,17 +155,11 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) { // Strip comments for ease of the parser Common::String codeNorm = stripComments(code); code = codeNorm.c_str(); + begin = code; // macros and factories have conflicting grammar. Thus we ease life for the parser. - if ((begin = findNextDefinition(code))) { - bool first = true; - - while ((end = findNextDefinition(begin + 1))) { - - if (first) { - begin = code; - first = false; - } + if ((end = findNextDefinition(code))) { + do { Common::String chunk(begin, end); if (chunk.hasPrefix("factory") || chunk.hasPrefix("method")) @@ -187,15 +181,8 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) { } } - _currentScript->clear(); - begin = end; - } - - // Do not execute event handlers, macros and factories - // A side effect of it is that if you had those in your test script, - // then the whole script will not be executed - _hadError = true; + } while ((end = findNextDefinition(begin + 1))); debugC(1, kDebugLingoCompile, "Code chunk:\n#####\n%s\n#####", begin); parse(begin); diff --git a/engines/director/lingo/tests/mixed-code.lingo b/engines/director/lingo/tests/mixed-code.lingo new file mode 100644 index 0000000000..6f03e0b043 --- /dev/null +++ b/engines/director/lingo/tests/mixed-code.lingo @@ -0,0 +1,14 @@ +put "ONE" + +on two + put "TWO" +end two + +put "THREE" + +on four + put "FOUR" +end FOUR + +four +two |