| 2108 | const char *fixupnames[] = { "null", "fix_gldata", "fix_func", "fix_string", "fix_import", "fix_datadata", "fix_stack" }; |
| 2109 | |
| 2110 | void ScriptExecutor::DumpInstruction(const ScriptOperation &op) const |
| 2111 | { |
| 2112 | assert(_execWriter); |
| 2113 | if (!_execWriter) |
| 2114 | return; |
| 2115 | |
| 2116 | // line_num local var should be shared between all the instances |
| 2117 | static int line_num = 0; // FIXME, don't use local static variable |
| 2118 | |
| 2119 | if (op.Instruction.Code == SCMD_LINENUM) |
| 2120 | { |
| 2121 | line_num = op.Args[0].IValue; |
| 2122 | return; |
| 2123 | } |
| 2124 | |
| 2125 | _execWriter->WriteFormat("Line %3d, IP:%8d (SP:%p) ", line_num, _pc, _registers[SREG_SP].RValue); |
| 2126 | |
| 2127 | const ScriptCommandInfo &cmd_info = sccmd_info[op.Instruction.Code]; |
| 2128 | _execWriter->WriteString(cmd_info.CmdName); |
| 2129 | |
| 2130 | String value_buf; |
| 2131 | for (int i = 0; i < cmd_info.ArgCount; ++i) |
| 2132 | { |
| 2133 | if (i > 0) |
| 2134 | { |
| 2135 | _execWriter->WriteChar(','); |
| 2136 | } |
| 2137 | |
| 2138 | RuntimeScriptValue arg = op.Args[i]; |
| 2139 | if (cmd_info.ArgIsReg[i]) |
| 2140 | { |
| 2141 | _execWriter->WriteFormat(" %s", regnames[op.Args[i].IValue]); |
| 2142 | arg = _registers[arg.IValue]; |
| 2143 | } |
| 2144 | |
| 2145 | { |
| 2146 | if (arg.Type == kScValStackPtr || arg.Type == kScValGlobalVar) |
| 2147 | { |
| 2148 | arg = *arg.RValue; |
| 2149 | } |
| 2150 | |
| 2151 | switch (arg.Type) |
| 2152 | { |
| 2153 | case kScValInteger: |
| 2154 | case kScValPluginArg: |
| 2155 | value_buf.Format("%d", arg.IValue); |
| 2156 | break; |
| 2157 | case kScValFloat: |
| 2158 | value_buf.Format("%f", arg.FValue); |
| 2159 | break; |
| 2160 | case kScValStringLiteral: |
| 2161 | value_buf.Format("\"%s\"", arg.Ptr); |
| 2162 | break; |
| 2163 | case kScValStackPtr: |
| 2164 | case kScValGlobalVar: |
| 2165 | value_buf.Format("%p", arg.RValue); |
| 2166 | break; |
| 2167 | case kScValData: |
nothing calls this directly
no test coverage detected