2
** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
4
** See Copyright Notice in lua.h
24
const char *const luaT_typenames[] = {
25
"nil", "boolean", "userdata", "number",
26
"string", "table", "function", "userdata", "thread",
31
void luaT_init (lua_State *L) {
32
static const char *const luaT_eventname[] = { /* ORDER TM */
33
"__index", "__newindex",
34
"__gc", "__mode", "__eq",
35
"__add", "__sub", "__mul", "__div", "__mod",
36
"__pow", "__unm", "__len", "__lt", "__le",
40
for (i=0; i<TM_N; i++) {
41
G(L)->tmname[i] = luaS_new(L, luaT_eventname[i]);
42
luaS_fix(G(L)->tmname[i]); /* never collect these names */
48
** function to be used with macro "fasttm": optimized for absence of
51
const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
52
const TValue *tm = luaH_getstr(events, ename);
53
lua_assert(event <= TM_EQ);
54
if (ttisnil(tm)) { /* no tag method? */
55
events->flags |= cast_byte(1u<<event); /* cache this fact */
62
const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
66
mt = hvalue(o)->metatable;
69
mt = uvalue(o)->metatable;
72
mt = G(L)->mt[ttype(o)];
74
return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject);