ltm.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. ** $Id: ltm.h $
  3. ** Tag methods
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef ltm_h
  7. #define ltm_h
  8. #include "lobject.h"
  9. #include "lstate.h"
  10. /*
  11. * WARNING: if you change the order of this enumeration,
  12. * grep "ORDER TM" and "ORDER OP"
  13. */
  14. typedef enum {
  15. TM_INDEX,
  16. TM_NEWINDEX,
  17. TM_GC,
  18. TM_MODE,
  19. TM_LEN,
  20. TM_EQ, /* last tag method with fast access */
  21. TM_ADD,
  22. TM_SUB,
  23. TM_MUL,
  24. TM_MOD,
  25. TM_POW,
  26. TM_DIV,
  27. TM_IDIV,
  28. TM_BAND,
  29. TM_BOR,
  30. TM_BXOR,
  31. TM_SHL,
  32. TM_SHR,
  33. TM_UNM,
  34. TM_BNOT,
  35. TM_LT,
  36. TM_LE,
  37. TM_CONCAT,
  38. TM_CALL,
  39. TM_CLOSE,
  40. TM_N /* number of elements in the enum */
  41. } TMS;
  42. /*
  43. ** Mask with 1 in all fast-access methods. A 1 in any of these bits
  44. ** in the flag of a (meta)table means the metatable does not have the
  45. ** corresponding metamethod field. (Bit 7 of the flag is used for
  46. ** 'isrealasize'.)
  47. */
  48. #define maskflags (~(~0u << (TM_EQ + 1)))
  49. /*
  50. ** Test whether there is no tagmethod.
  51. ** (Because tagmethods use raw accesses, the result may be an "empty" nil.)
  52. */
  53. #define notm(tm) ttisnil(tm)
  54. #define gfasttm(g,et,e) ((et) == NULL ? NULL : \
  55. ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
  56. #define fasttm(l,et,e) gfasttm(G(l), et, e)
  57. #define ttypename(x) luaT_typenames_[(x) + 1]
  58. LUAI_DDEC(const char *const luaT_typenames_[LUA_TOTALTYPES];)
  59. LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o);
  60. LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
  61. LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
  62. TMS event);
  63. LUAI_FUNC void luaT_init (lua_State *L);
  64. LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
  65. const TValue *p2, const TValue *p3);
  66. LUAI_FUNC void luaT_callTMres (lua_State *L, const TValue *f,
  67. const TValue *p1, const TValue *p2, StkId p3);
  68. LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
  69. StkId res, TMS event);
  70. LUAI_FUNC void luaT_tryconcatTM (lua_State *L);
  71. LUAI_FUNC void luaT_trybinassocTM (lua_State *L, const TValue *p1,
  72. const TValue *p2, int inv, StkId res, TMS event);
  73. LUAI_FUNC void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2,
  74. int inv, StkId res, TMS event);
  75. LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1,
  76. const TValue *p2, TMS event);
  77. LUAI_FUNC int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2,
  78. int inv, int isfloat, TMS event);
  79. LUAI_FUNC void luaT_adjustvarargs (lua_State *L, int nfixparams,
  80. CallInfo *ci, const Proto *p);
  81. LUAI_FUNC void luaT_getvarargs (lua_State *L, CallInfo *ci,
  82. StkId where, int wanted);
  83. #endif