Fix line number reporting in debug stack traces (fixes issue #30).

This commit is contained in:
James Roseborough
2014-07-04 03:22:09 +00:00
parent 83d54e9d77
commit 54788cdc71
2 changed files with 7 additions and 5 deletions

View File

@@ -970,7 +970,9 @@ Files are no longer hosted at LuaForge.
<li>Rename Globals.FINDER to Globals.finder.</li> <li>Rename Globals.FINDER to Globals.finder.</li>
<li>Fix bug in Globals.UTF8Stream affecting loading from Readers.</li> <li>Fix bug in Globals.UTF8Stream affecting loading from Readers.</li>
<li>Add buffered input for compiling and loading of scripts.</li> <li>Add buffered input for compiling and loading of scripts.</li>
<li>Coerce byte[] to LuaString, pass LuaValue as-is in CoerceJavaToLua.coerce().</li> <li>In CoerceJavaToLua.coerse(), coerce byte[] to LuaString (fixes issue #31).</li>
<li>In CoerceJavaToLua.coerse(), coerce LuaValue to same value (fixes issue #29).</li>
<li>Fix line number reporting in debug stack traces (fixes issue #30).</li>
</ul></td></tr> </ul></td></tr>
</table></td></tr></table> </table></td></tr></table>

View File

@@ -195,12 +195,12 @@ public class LuaClosure extends LuaFunction {
// process instructions // process instructions
try { try {
while ( true ) { for (; true; ++pc) {
if (globals != null && globals.debuglib != null) if (globals != null && globals.debuglib != null)
globals.debuglib.onInstruction( pc, v, top ); globals.debuglib.onInstruction( pc, v, top );
// pull out instruction // pull out instruction
i = code[pc++]; i = code[pc];
a = ((i>>6) & 0xff); a = ((i>>6) & 0xff);
// process the op code // process the op code
@@ -217,7 +217,7 @@ public class LuaClosure extends LuaFunction {
case Lua.OP_LOADBOOL:/* A B C R(A):= (Bool)B: if (C) pc++ */ case Lua.OP_LOADBOOL:/* A B C R(A):= (Bool)B: if (C) pc++ */
stack[a] = (i>>>23!=0)? LuaValue.TRUE: LuaValue.FALSE; stack[a] = (i>>>23!=0)? LuaValue.TRUE: LuaValue.FALSE;
if ((i&(0x1ff<<14)) != 0) if ((i&(0x1ff<<14)) != 0)
pc++; /* skip next instruction (if C) */ ++pc; /* skip next instruction (if C) */
continue; continue;
case Lua.OP_LOADNIL: /* A B R(A):= ...:= R(A+B):= nil */ case Lua.OP_LOADNIL: /* A B R(A):= ...:= R(A+B):= nil */
@@ -444,7 +444,7 @@ public class LuaClosure extends LuaFunction {
case Lua.OP_SETLIST: /* A B C R(A)[(C-1)*FPF+i]:= R(A+i), 1 <= i <= B */ case Lua.OP_SETLIST: /* A B C R(A)[(C-1)*FPF+i]:= R(A+i), 1 <= i <= B */
{ {
if ( (c=(i>>14)&0x1ff) == 0 ) if ( (c=(i>>14)&0x1ff) == 0 )
c = code[pc++]; c = code[++pc];
int offset = (c-1) * Lua.LFIELDS_PER_FLUSH; int offset = (c-1) * Lua.LFIELDS_PER_FLUSH;
o = stack[a]; o = stack[a];
if ( (b=i>>>23) == 0 ) { if ( (b=i>>>23) == 0 ) {