DIRECTOR: Update scriptframe command to include cast ID

This commit is contained in:
Scott Percival 2022-09-18 22:34:23 +08:00 committed by Eugene Sandulenko
parent c1ebb4d52d
commit 29cc573d96
4 changed files with 21 additions and 11 deletions

View File

@ -1573,7 +1573,7 @@ ScriptContext *LingoCompiler::compileLingoV4(Common::SeekableReadStreamEndian &s
}
if (!skipdump && ConfMan.getBool("dump_scripts")) {
out.writeString(g_lingo->decodeFunctionBody(sym));
out.writeString(g_lingo->formatFunctionBody(sym));
}
_assemblyContext->_functionNames.push_back(*sym.name);

View File

@ -294,7 +294,7 @@ Symbol ScriptContext::define(const Common::String &name, ScriptData *code, Commo
sym.ctx = this;
if (debugChannelSet(1, kDebugCompile)) {
debugC(1, kDebugCompile, "%s", g_lingo->decodeFunctionBody(sym).c_str());
debugC(1, kDebugCompile, "%s", g_lingo->formatFunctionBody(sym).c_str());
debugC(1, kDebugCompile, "<end define code>");
}
@ -385,7 +385,7 @@ bool ScriptContext::setProp(const Common::String &propName, const Datum &value)
Common::String ScriptContext::formatFunctionList(const char *prefix) {
Common::String result;
for (auto it = _functionHandlers.begin(); it != _functionHandlers.end(); ++it) {
result += Common::String::format("%s%s\n", prefix, g_lingo->decodeFunctionName(it->_value).c_str());
result += Common::String::format("%s%s\n", prefix, g_lingo->formatFunctionName(it->_value).c_str());
}
return result;
}

View File

@ -383,17 +383,26 @@ void Lingo::printCallStack(uint pc) {
}
Common::String Lingo::formatFrame() {
Common::String result;
Common::Array<CFrame *> &callstack = _vm->getCurrentWindow()->_callstack;
if (callstack.size() == 0) {
return Common::String("End of execution");
}
if (_currentScriptContext->_id)
result += Common::String::format("%d:", _currentScriptContext->_id);
CFrame *frame = callstack[callstack.size() - 1];
const char *funcName = frame->sp.type == VOIDSYM ? "[unknown]" : frame->sp.name->c_str();
Common::String result = Common::String::format("%s:%d\n", funcName, _pc);
result += Common::String::format("[%3d]: %s", _pc, decodeInstruction(_currentScript, _pc).c_str());
if (frame->sp.type == VOIDSYM || !frame->sp.name)
result += "[unknown]";
else
result += frame->sp.name->c_str();
result += Common::String::format(" at [%3d]", _pc);
return result;
}
Common::String Lingo::formatCurrentInstruction() {
return Common::String::format("[%3d]: %s", _pc, decodeInstruction(_currentScript, _pc).c_str());
}
Common::String Lingo::decodeInstruction(ScriptData *sd, uint pc, uint *newPc) {
void *opcodeFunc;
Common::String res;
@ -482,7 +491,7 @@ Common::String Lingo::decodeScript(ScriptData *sd) {
return result;
}
Common::String Lingo::decodeFunctionName(Symbol &sym) {
Common::String Lingo::formatFunctionName(Symbol &sym) {
Common::String result;
if (sym.type != HANDLER)
return result;
@ -499,11 +508,11 @@ Common::String Lingo::decodeFunctionName(Symbol &sym) {
return result;
}
Common::String Lingo::decodeFunctionBody(Symbol &sym) {
Common::String Lingo::formatFunctionBody(Symbol &sym) {
Common::String result;
if (sym.type != HANDLER)
return result;
result += decodeFunctionName(sym);
result += formatFunctionName(sym);
result += "\n";
result += decodeScript(sym.u.defn);
result += "\n";

View File

@ -307,10 +307,11 @@ public:
Common::String formatCallStack(uint pc);
void printCallStack(uint pc);
Common::String formatFrame();
Common::String formatCurrentInstruction();
Common::String decodeInstruction(ScriptData *sd, uint pc, uint *newPC = NULL);
Common::String decodeScript(ScriptData *sd);
Common::String decodeFunctionName(Symbol &sym);
Common::String decodeFunctionBody(Symbol &sym);
Common::String formatFunctionName(Symbol &sym);
Common::String formatFunctionBody(Symbol &sym);
void reloadBuiltIns();
void initBuiltIns();