mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
remove luaL_traceback
This commit is contained in:
@@ -248,96 +248,6 @@ luaL_tolstring (lua_State *L, int idx, size_t *len) {
|
|||||||
return lua_tolstring(L, -1, len);
|
return lua_tolstring(L, -1, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** {======================================================
|
|
||||||
** Traceback
|
|
||||||
** =======================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define LEVELS1 12 /* size of the first part of the stack */
|
|
||||||
#define LEVELS2 10 /* size of the second part of the stack */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
** search for 'objidx' in table at index -1.
|
|
||||||
** return 1 + string at top if find a good name.
|
|
||||||
*/
|
|
||||||
static int findfield (lua_State *L, int objidx, int level) {
|
|
||||||
if (level == 0 || !lua_istable(L, -1))
|
|
||||||
return 0; /* not found */
|
|
||||||
lua_pushnil(L); /* start 'next' loop */
|
|
||||||
while (lua_next(L, -2)) { /* for each pair in table */
|
|
||||||
if (lua_type(L, -2) == LUA_TSTRING) { /* ignore non-string keys */
|
|
||||||
if (lua_rawequal(L, objidx, -1)) { /* found object? */
|
|
||||||
lua_pop(L, 1); /* remove value (but keep name) */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (findfield(L, objidx, level - 1)) { /* try recursively */
|
|
||||||
lua_remove(L, -2); /* remove table (but keep name) */
|
|
||||||
lua_pushliteral(L, ".");
|
|
||||||
lua_insert(L, -2); /* place '.' between the two names */
|
|
||||||
lua_concat(L, 3);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lua_pop(L, 1); /* remove value */
|
|
||||||
}
|
|
||||||
return 0; /* not found */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
|
|
||||||
int top = lua_gettop(L);
|
|
||||||
lua_getinfo(L, "f", ar); /* push function */
|
|
||||||
lua_pushglobaltable(L);
|
|
||||||
if (findfield(L, top + 1, 2)) {
|
|
||||||
lua_copy(L, -1, top + 1); /* move name to proper place */
|
|
||||||
lua_pop(L, 2); /* remove pushed values */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
lua_settop(L, top); /* remove function and global table */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pushfuncname (lua_State *L, lua_Debug *ar) {
|
|
||||||
if (*ar->namewhat != '\0') /* is there a name? */
|
|
||||||
lua_pushfstring(L, "function " LUA_QS, ar->name);
|
|
||||||
else if (*ar->what == 'm') /* main? */
|
|
||||||
lua_pushfstring(L, "main chunk");
|
|
||||||
else if (*ar->what == 'C') {
|
|
||||||
if (pushglobalfuncname(L, ar)) {
|
|
||||||
lua_pushfstring(L, "function " LUA_QS, lua_tostring(L, -1));
|
|
||||||
lua_remove(L, -2); /* remove name */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
lua_pushliteral(L, "?");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
lua_pushfstring(L, "function <%s:%d>", ar->short_src, ar->linedefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int countlevels (lua_State *L) {
|
|
||||||
lua_Debug ar;
|
|
||||||
int li = 1, le = 1;
|
|
||||||
/* find an upper bound */
|
|
||||||
while (lua_getstack(L, le, &ar)) { li = le; le *= 2; }
|
|
||||||
/* do a binary search */
|
|
||||||
while (li < le) {
|
|
||||||
int m = (li + le)/2;
|
|
||||||
if (lua_getstack(L, m, &ar)) li = m + 1;
|
|
||||||
else le = m;
|
|
||||||
}
|
|
||||||
return le - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* }====================================================== */
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
LUALIB_API void
|
LUALIB_API void
|
||||||
|
|||||||
Reference in New Issue
Block a user