Ejemplo n.º 1
0
static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
                       Closure *f, CallInfo *ci) {
    int status = 1;
    for (; *what; what++) {
        switch (*what) {
        case 'S': {
            funcinfo(ar, f);
            break;
        }
        case 'l': {
            ar->currentline = (ci && isLua(ci)) ? currentline(ci) : -1;
            break;
        }
        case 'u': {
            ar->nups = (f == NULL) ? 0 : f->c.nupvalues;
            if (noLuaClosure(f)) {
                ar->isvararg = 1;
                ar->nparams = 0;
            }
            else {
                ar->isvararg = f->l.p->is_vararg;
                ar->nparams = f->l.p->numparams;
            }
            break;
        }
        case 't': {
            ar->istailcall = (ci) ? ci->callstatus & CIST_TAIL : 0;
            break;
        }
        case 'n': {
            /* calling function is a known Lua function? */
            if (ci && !(ci->callstatus & CIST_TAIL) && isLua(ci->previous))
                ar->namewhat = getfuncname(L, ci->previous, &ar->name);
            else
                ar->namewhat = NULL;
            if (ar->namewhat == NULL) {
                ar->namewhat = "";  /* not found */
                ar->name = NULL;
            }
            break;
        }
        case 'L':
        case 'f':  /* handled by lua_getinfo */
            break;
        default:
            status = 0;  /* invalid option */
        }
    }
    return status;
}
Ejemplo n.º 2
0
static void funcinfo (lua_Debug *ar, Closure *cl) {
	if (noLuaClosure(cl)) {
	ar->source = "=[C]";
	ar->linedefined = -1;
	ar->lastlinedefined = -1;
	ar->what = "C";
	}
	else {
	Proto *p = cl->l.p;
	ar->source = p->source ? getstr(p->source) : "=?";
	ar->linedefined = p->linedefined;
	ar->lastlinedefined = p->lastlinedefined;
	ar->what = (ar->linedefined == 0) ? "main" : "Lua";
	}
	luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
}
Ejemplo n.º 3
0
static void collectvalidlines (lua_State *L, Closure *f) {
	if (noLuaClosure(f)) {
	setnilvalue(L->top);
	api_incr_top(L);
	}
	else {
	int i;
	TValue v;
	int *lineinfo = f->l.p->lineinfo;
	Table *t = luaH_new(L);  /* new table to store active lines */
	sethvalue(L, L->top, t);  /* push it on stack */
	api_incr_top(L);
	setbvalue(&v, 1);  /* boolean 'true' to be the value of all indices */
	for (i = 0; i < f->l.p->sizelineinfo; i++)  /* for all lines with code */
		luaH_setint(L, t, lineinfo[i], &v);  /* table[line] = true */
	}
}