Fixed issue: #86
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -173,10 +173,16 @@ public class DebugLib extends TwoArgFunction {
|
|||||||
// find the stack info
|
// find the stack info
|
||||||
DebugLib.CallFrame frame;
|
DebugLib.CallFrame frame;
|
||||||
if ( func.isnumber() ) {
|
if ( func.isnumber() ) {
|
||||||
frame = callstack.getCallFrame(func.toint());
|
int level = func.toint();
|
||||||
|
if (level == 0) {
|
||||||
|
frame = null;
|
||||||
|
func = this;
|
||||||
|
} else {
|
||||||
|
frame = callstack.getCallFrame(level);
|
||||||
if (frame == null)
|
if (frame == null)
|
||||||
return NONE;
|
return NONE;
|
||||||
func = frame.f;
|
func = frame.f;
|
||||||
|
}
|
||||||
} else if ( func.isfunction() ) {
|
} else if ( func.isfunction() ) {
|
||||||
frame = callstack.findCallFrame(func);
|
frame = callstack.findCallFrame(func);
|
||||||
} else {
|
} else {
|
||||||
@@ -453,12 +459,14 @@ public class DebugLib extends TwoArgFunction {
|
|||||||
if (s.inhook || s.hookfunc == null) return;
|
if (s.inhook || s.hookfunc == null) return;
|
||||||
s.inhook = true;
|
s.inhook = true;
|
||||||
try {
|
try {
|
||||||
|
callstack().onCall(s.hookfunc.checkfunction());
|
||||||
s.hookfunc.call(type, arg);
|
s.hookfunc.call(type, arg);
|
||||||
} catch (LuaError e) {
|
} catch (LuaError e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
throw new LuaError(e);
|
throw new LuaError(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
callstack().onReturn();
|
||||||
s.inhook = false;
|
s.inhook = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,6 +140,28 @@ public class FragmentsTest extends TestSuite {
|
|||||||
"return sum\n");
|
"return sum\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDebugGetInfoLevelZeroReturnsGetInfoFunction() {
|
||||||
|
runFragment(
|
||||||
|
LuaValue.TRUE,
|
||||||
|
"return debug.getinfo(0, 'f').func == debug.getinfo\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDebugGetInfoInsideHookSeesHookFunction() {
|
||||||
|
runFragment(
|
||||||
|
LuaValue.TRUE,
|
||||||
|
"local ok = false\n" +
|
||||||
|
"local hook\n" +
|
||||||
|
"hook = function()\n" +
|
||||||
|
" local info = debug.getinfo(1, 'f')\n" +
|
||||||
|
" ok = info ~= nil and info.func == hook\n" +
|
||||||
|
" debug.sethook()\n" +
|
||||||
|
"end\n" +
|
||||||
|
"debug.sethook(hook, 'c')\n" +
|
||||||
|
"local function foo() end\n" +
|
||||||
|
"foo()\n" +
|
||||||
|
"return ok\n");
|
||||||
|
}
|
||||||
|
|
||||||
public void testLongIntegerLiteralPrecision() {
|
public void testLongIntegerLiteralPrecision() {
|
||||||
runFragment(
|
runFragment(
|
||||||
LuaValue.varargsOf(new LuaValue[] {
|
LuaValue.varargsOf(new LuaValue[] {
|
||||||
|
|||||||
Reference in New Issue
Block a user