static const char *varinfo (lua_State *L, const TValue *o) { const char *name = NULL; /* to avoid warnings */ CallInfo *ci = L->ci; const char *kind = NULL; if (isLua(ci)) { kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ if (!kind && isinstack(ci, o)) /* no? try a register */ kind = getobjname(ci_func(ci)->p, currentpc(ci), cast_int(o - ci->u.l.base), &name); } return (kind) ? luaO_pushfstring(L, " (%s '%s')", kind, name) : ""; }
l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { CallInfo *ci = L->ci; const char *name = NULL; const char *t = objtypename(o); const char *kind = NULL; if (isLua(ci)) { kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ if (!kind && isinstack(ci, o)) /* no? try a register */ kind = getobjname(ci_func(ci)->p, currentpc(ci), cast_int(o - ci->u.l.base), &name); } if (kind) luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", op, kind, name, t); else luaG_runerror(L, "attempt to %s a %s value", op, t); }
LuaResult luaG_typeerror (const LuaValue *o, const char *op) { LuaThread*L = thread_L; LuaStackFrame *ci = L->stack_.callinfo_; std::string name; const char *t = objtypename(o); const char *kind = NULL; if (ci->isLua()) { kind = getupvalname(ci, o, name); /* check whether 'o' is an upvalue */ if (!kind && isinstack(ci, o)) { /* no? try a register */ kind = getobjname2(ci->getFunc()->getLClosure()->proto_, ci->getCurrentPC(), cast_int(o - ci->getBase()), name); } } if (kind) { return luaG_runerror("attempt to %s %s " LUA_QS " (a %s value)", op, kind, name.c_str(), t); } else { return luaG_runerror("attempt to %s a %s value", op, t); } }