Relocate some debug-related methods.
This commit is contained in:
@@ -298,23 +298,11 @@ public class DebugLib extends LFunction {
|
||||
return null;
|
||||
}
|
||||
|
||||
private LString getlocalname (LPrototype f, int local_number, int pc) {
|
||||
int i;
|
||||
for (i = 0; i<f.locvars.length && f.locvars[i].startpc <= pc; i++) {
|
||||
if (pc < f.locvars[i].endpc) { /* is variable active? */
|
||||
local_number--;
|
||||
if (local_number == 0)
|
||||
return f.locvars[i].varname;
|
||||
}
|
||||
}
|
||||
return null; /* not found */
|
||||
}
|
||||
|
||||
private LString findlocal(LuaState vm, int cc, int n) {
|
||||
CallInfo ci = vm.calls[cc];
|
||||
LString name;
|
||||
LPrototype fp = ci.closure.p;
|
||||
if ( fp!=null && (name = getlocalname(fp, n, ci.pc-1)) != null)
|
||||
if ( fp!=null && (name = fp.getlocalname(n, ci.pc-1)) != null)
|
||||
return name;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -40,4 +40,8 @@ public class CallInfo {
|
||||
this.pc = 0;
|
||||
}
|
||||
|
||||
public boolean isLua() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,4 +59,9 @@ public class LClosure extends LFunction {
|
||||
return env;
|
||||
}
|
||||
|
||||
/** Returns true if this is a lua closure, false otherwise */
|
||||
public boolean isClosure() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -97,4 +97,8 @@ public class LNumber extends LValue {
|
||||
luaAsString().luaConcatTo( baos );
|
||||
}
|
||||
|
||||
/** Returns true if this is or can be made into a number */
|
||||
public boolean isNumber() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,4 +52,21 @@ public class LPrototype {
|
||||
public int is_vararg;
|
||||
public int maxstacksize;
|
||||
|
||||
/** Get the name of a local variable.
|
||||
*
|
||||
* @param number the local variable number to look up
|
||||
* @param pc the program counter
|
||||
* @return the name, or null if not found
|
||||
*/
|
||||
public LString getlocalname(int number, int pc) {
|
||||
int i;
|
||||
for (i = 0; i<locvars.length && locvars[i].startpc <= pc; i++) {
|
||||
if (pc < locvars[i].endpc) { /* is variable active? */
|
||||
number--;
|
||||
if (number == 0)
|
||||
return locvars[i].varname;
|
||||
}
|
||||
}
|
||||
return null; /* not found */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,4 +456,10 @@ public class LString extends LValue {
|
||||
baos.write( m_bytes, m_offset, m_length );
|
||||
}
|
||||
|
||||
/** Returns true if this is or can be made into a number */
|
||||
public boolean isNumber() {
|
||||
return ! this.luaToNumber().isNil();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -350,4 +350,14 @@ public class LValue {
|
||||
public boolean isUserData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns true if this is or can be made into a number */
|
||||
public boolean isNumber() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns true if this is a lua closure, false otherwise */
|
||||
public boolean isClosure() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2524,4 +2524,6 @@ public class LuaState extends Lua {
|
||||
top = oldtop;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user