Relocate some debug-related methods.
This commit is contained in:
@@ -298,23 +298,11 @@ public class DebugLib extends LFunction {
|
|||||||
return null;
|
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) {
|
private LString findlocal(LuaState vm, int cc, int n) {
|
||||||
CallInfo ci = vm.calls[cc];
|
CallInfo ci = vm.calls[cc];
|
||||||
LString name;
|
LString name;
|
||||||
LPrototype fp = ci.closure.p;
|
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 name;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,4 +40,8 @@ public class CallInfo {
|
|||||||
this.pc = 0;
|
this.pc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLua() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,4 +59,9 @@ public class LClosure extends LFunction {
|
|||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns true if this is a lua closure, false otherwise */
|
||||||
|
public boolean isClosure() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,5 +96,9 @@ public class LNumber extends LValue {
|
|||||||
public void luaConcatTo(ByteArrayOutputStream baos) {
|
public void luaConcatTo(ByteArrayOutputStream baos) {
|
||||||
luaAsString().luaConcatTo( baos );
|
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 is_vararg;
|
||||||
public int maxstacksize;
|
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 */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -455,5 +455,11 @@ public class LString extends LValue {
|
|||||||
public void luaConcatTo(ByteArrayOutputStream baos) {
|
public void luaConcatTo(ByteArrayOutputStream baos) {
|
||||||
baos.write( m_bytes, m_offset, m_length );
|
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() {
|
public boolean isUserData() {
|
||||||
return false;
|
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;
|
top = oldtop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user