57 static int printMessage (lua_State *lua)
59 assert (lua_isstring (lua,1));
61 const char *msg = lua_tostring (lua, 1);
65 memset (&ar, 0,
sizeof(ar));
66 lua_getstack (lua, 1, &ar);
67 lua_getinfo (lua,
"Snl", &ar);
70 const char *str = ar.source;
71 printf (
"script: %s -- at %s(%d)\n", msg, str, ar.currentline);
130 lua_getstack (lua, 0, &ar);
163 lua_pushcclosure (
m_pState, printMessage, 0);
216 bool fSuccess =
false;
219 if ((iErr = luaL_loadfile (
m_pState, strFilename)) == 0)
222 if ((iErr = lua_pcall (
m_pState, 0, LUA_MULTRET, 0)) == 0)
228 if (fSuccess ==
false)
254 bool fSuccess =
false;
262 if ((iErr = luaL_loadbuffer (
m_pState, (
const char *) pbBuffer, szLen, strName)) == 0)
265 if ((iErr = lua_pcall (
m_pState, 0, LUA_MULTRET, 0)) == 0)
271 if (fSuccess ==
false)
297 bool fSuccess =
false;
299 if (lua_isfunction (
m_pState, -nArgs-1))
302 iErr = lua_pcall (
m_pState, nArgs, nReturns, 0);
318 static void LuaHookCall (lua_State *lua)
321 printf (
"---- Call Stack ----\n");
327 for (
int iLevel = 0; lua_getstack (lua, iLevel, &ar) != 0; ++iLevel)
329 if (lua_getinfo (lua,
"Snlu", &ar) != 0)
331 printf (
"%d %s %s %d @%d %s\n", iLevel, ar.namewhat, ar.name, ar.nups, ar.linedefined, ar.short_src);
336 static void LuaHookRet (lua_State *lua)
341 static void LuaHookLine (lua_State *lua)
344 lua_getstack (lua, 0, &ar);
347 if (lua_getinfo (lua,
"Sl", &ar) != 0)
349 printf (
"exe %s on line %d\n", ar.short_src, ar.currentline);
353 static void LuaHookCount (lua_State *lua)
358 static void LuaHook (lua_State *lua, lua_Debug *ar)
364 #ifdef LUA_HOOKTAILCALL
365 case LUA_HOOKTAILCALL:
421 printf (
"LUA_ERRRUN\n");
425 printf (
"LUA_ERRMEM\n");
429 printf (
"LUA_ERRERR\n");
436 printf (
"LUA Error: %s\n", lua_tostring ((lua_State *)
m_vm, -1));
void Error(moText p_text)
Anuncia y registra un error.
moLuaVirtualMachine & m_vm
static void Error(moText p_text)
Anuncia un error.
void SetHooksFlag(int iMask)
moLuaDebugger(moLuaVirtualMachine &vm)
moLuaVirtualMachine(void)
void AttachDebugger(moLuaDebugger *dbg)
void ErrorRun(int iErrorCode)
bool CallFunction(int nArgs, int nReturns=0)
static moDebug * MODebug2
Clase de impresión de errores para depuración
bool RunBuffer(const unsigned char *pbBuffer, size_t szLen, const char *strName=NULL)
virtual ~moLuaVirtualMachine(void)
static void Panic(lua_State *lua)
bool RunFile(const char *strFilename)
virtual ~moLuaDebugger(void)