diff --git a/include/lua.h b/include/lua.h index b03339c..7f0f64c 100644 --- a/include/lua.h +++ b/include/lua.h @@ -392,6 +392,7 @@ struct lua_Debug { /* private part */ int i_ci; /* active function */ int instruction; /* (i) current instruction offset */ + int istailcall; /* (t) whether the stack entry is a tail call */ }; /* }====================================================================== */ diff --git a/src/ldblib.c b/src/ldblib.c index 3bb3079..9db270c 100644 --- a/src/ldblib.c +++ b/src/ldblib.c @@ -134,6 +134,10 @@ static int db_getinfo (lua_State *L) { lua_pushboolean(L, ar.isvararg); lua_setfield(L, -2, "isvararg"); } + if (strchr(options, 't')) { + lua_pushboolean(L, ar.istailcall); + lua_setfield(L, -2, "istailcall"); + } if (strchr(options, 'n')) { settabss(L, "name", ar.name); settabss(L, "namewhat", ar.namewhat); diff --git a/src/ldebug.c b/src/ldebug.c index b4a2e20..cba8a44 100644 --- a/src/ldebug.c +++ b/src/ldebug.c @@ -228,6 +228,10 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, } break; } + case 't': { + ar->istailcall = (ci) ? ci->tailcalls > 0 : 0; + break; + } case 'n': { ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; if (ar->namewhat == NULL) { diff --git a/src/lua.h b/src/lua.h index 8cc04c3..44457bd 100644 --- a/src/lua.h +++ b/src/lua.h @@ -392,6 +392,7 @@ struct lua_Debug { /* private part */ int i_ci; /* active function */ int instruction; /* (i) current instruction offset */ + int istailcall; /* (t) whether the stack entry is a tail call */ }; /* }====================================================================== */