Fix getobjname for get constant name if it stored on register.

This commit is contained in:
Enyby
2019-10-14 14:11:38 +03:00
parent edfe1a5fde
commit 2f5aa594bd

View File

@@ -796,8 +796,8 @@ public class DebugLib extends TwoArgFunction {
LuaString vn = (Lua.GET_OPCODE(i) == Lua.OP_GETTABLE) /* name of indexed variable */ LuaString vn = (Lua.GET_OPCODE(i) == Lua.OP_GETTABLE) /* name of indexed variable */
? p.getlocalname(t + 1, pc) ? p.getlocalname(t + 1, pc)
: (t < p.upvalues.length ? p.upvalues[t].name : QMARK); : (t < p.upvalues.length ? p.upvalues[t].name : QMARK);
name = kname(p, k); String jname = kname(p, pc, k);
return new NameWhat( name.tojstring(), vn != null && vn.eq_b(ENV)? "global": "field" ); return new NameWhat( jname, vn != null && vn.eq_b(ENV)? "global": "field" );
} }
case Lua.OP_GETUPVAL: { case Lua.OP_GETUPVAL: {
int u = Lua.GETARG_B(i); /* upvalue index */ int u = Lua.GETARG_B(i); /* upvalue index */
@@ -816,8 +816,8 @@ public class DebugLib extends TwoArgFunction {
} }
case Lua.OP_SELF: { case Lua.OP_SELF: {
int k = Lua.GETARG_C(i); /* key index */ int k = Lua.GETARG_C(i); /* key index */
name = kname(p, k); String jname = kname(p, pc, k);
return new NameWhat( name.tojstring(), "method" ); return new NameWhat( jname, "method" );
} }
default: default:
break; break;
@@ -826,11 +826,20 @@ public class DebugLib extends TwoArgFunction {
return null; /* no useful name found */ return null; /* no useful name found */
} }
static LuaString kname(Prototype p, int c) { static String kname(Prototype p, int pc, int c) {
if (Lua.ISK(c) && p.k[Lua.INDEXK(c)].isstring()) if (Lua.ISK(c)) { /* is 'c' a constant? */
return p.k[Lua.INDEXK(c)].strvalue(); LuaValue k = p.k[Lua.INDEXK(c)];
else if (k.isstring()) { /* literal constant? */
return QMARK; return k.tojstring(); /* it is its own name */
} /* else no reasonable name found */
} else { /* 'c' is a register */
NameWhat what = getobjname(p, pc, c); /* search for 'c' */
if (what != null && "constant".equals(what.namewhat)) { /* found a constant name? */
return what.name; /* 'name' already filled */
}
/* else no reasonable name found */
}
return "?"; /* no reasonable name found */
} }
/* /*