/// <summary> /// <para>Return a debug.traceback() call result (a multi-line string, containing a full stack trace, including C calls.</para> /// <para>Note: it won't return anything unless the interpreter is in the middle of execution - that is, it only makes sense to call it from a method called from Lua, or during a coroutine yield.</para> /// </summary> public string GetDebugTraceback() { int oldTop = luaState.GetTop(); luaState.GetGlobal("debug"); // stack: debug luaState.GetField(-1, "traceback"); // stack: debug,traceback luaState.Remove(-2); // stack: traceback luaState.PCall(0, -1, 0); return(translator.PopValues(luaState, oldTop)[0] as string); }
/// <summary> /// <para>Return a debug.traceback() call result (a multi-line string, containing a full stack trace, including C calls.</para> /// <para>Note: it won't return anything unless the interpreter is in the middle of execution - that is, it only makes sense to call it from a method called from Lua, or during a coroutine yield.</para> /// </summary> public string GetDebugTraceback() { int oldTop = LuaLib.LuaGetTop(luaState); LuaLib.LuaGetGlobal(luaState, "debug"); // stack: debug LuaLib.LuaGetField(luaState, -1, "traceback"); // stack: debug,traceback LuaLib.LuaRemove(luaState, -2); // stack: traceback LuaLib.LuaPCall(luaState, 0, -1, 0); return(translator.PopValues(luaState, oldTop)[0] as string); }
/// <summary> /// /// </summary> /// <param name = "chunk"></param> /// <param name = "name"></param> /// <returns></returns> public LuaFunction LoadString(string chunk, string name) { int oldTop = LuaLib.LuaGetTop(luaState); executing = true; try { if (LuaLib.LuaLLoadBuffer(luaState, chunk, name) != 0) { ThrowExceptionFromError(oldTop); } } finally { executing = false; } var result = translator.GetFunction(luaState, -1); translator.PopValues(luaState, oldTop); return(result); }