Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:37:57

0001 /*
0002 ** $Id: ltm.h $
0003 ** Tag methods
0004 ** See Copyright Notice in lua.h
0005 */
0006 
0007 #ifndef ltm_h
0008 #define ltm_h
0009 
0010 
0011 #include "lobject.h"
0012 
0013 
0014 /*
0015 * WARNING: if you change the order of this enumeration,
0016 * grep "ORDER TM" and "ORDER OP"
0017 */
0018 typedef enum {
0019   TM_INDEX,
0020   TM_NEWINDEX,
0021   TM_GC,
0022   TM_MODE,
0023   TM_LEN,
0024   TM_EQ,  /* last tag method with fast access */
0025   TM_ADD,
0026   TM_SUB,
0027   TM_MUL,
0028   TM_MOD,
0029   TM_POW,
0030   TM_DIV,
0031   TM_IDIV,
0032   TM_BAND,
0033   TM_BOR,
0034   TM_BXOR,
0035   TM_SHL,
0036   TM_SHR,
0037   TM_UNM,
0038   TM_BNOT,
0039   TM_LT,
0040   TM_LE,
0041   TM_CONCAT,
0042   TM_CALL,
0043   TM_CLOSE,
0044   TM_N      /* number of elements in the enum */
0045 } TMS;
0046 
0047 
0048 /*
0049 ** Mask with 1 in all fast-access methods. A 1 in any of these bits
0050 ** in the flag of a (meta)table means the metatable does not have the
0051 ** corresponding metamethod field. (Bit 7 of the flag is used for
0052 ** 'isrealasize'.)
0053 */
0054 #define maskflags   (~(~0u << (TM_EQ + 1)))
0055 
0056 
0057 /*
0058 ** Test whether there is no tagmethod.
0059 ** (Because tagmethods use raw accesses, the result may be an "empty" nil.)
0060 */
0061 #define notm(tm)    ttisnil(tm)
0062 
0063 
0064 #define gfasttm(g,et,e) ((et) == NULL ? NULL : \
0065   ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
0066 
0067 #define fasttm(l,et,e)  gfasttm(G(l), et, e)
0068 
0069 #define ttypename(x)    luaT_typenames_[(x) + 1]
0070 
0071 LUAI_DDEC(const char *const luaT_typenames_[LUA_TOTALTYPES];)
0072 
0073 
0074 LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o);
0075 
0076 LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
0077 LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
0078                                                        TMS event);
0079 LUAI_FUNC void luaT_init (lua_State *L);
0080 
0081 LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
0082                             const TValue *p2, const TValue *p3);
0083 LUAI_FUNC void luaT_callTMres (lua_State *L, const TValue *f,
0084                             const TValue *p1, const TValue *p2, StkId p3);
0085 LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
0086                               StkId res, TMS event);
0087 LUAI_FUNC void luaT_tryconcatTM (lua_State *L);
0088 LUAI_FUNC void luaT_trybinassocTM (lua_State *L, const TValue *p1,
0089        const TValue *p2, int inv, StkId res, TMS event);
0090 LUAI_FUNC void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2,
0091                                int inv, StkId res, TMS event);
0092 LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1,
0093                                 const TValue *p2, TMS event);
0094 LUAI_FUNC int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2,
0095                                  int inv, int isfloat, TMS event);
0096 
0097 LUAI_FUNC void luaT_adjustvarargs (lua_State *L, int nfixparams,
0098                                    struct CallInfo *ci, const Proto *p);
0099 LUAI_FUNC void luaT_getvarargs (lua_State *L, struct CallInfo *ci,
0100                                               StkId where, int wanted);
0101 
0102 
0103 #endif