luau-src-rs/luau/VM/src/ltm.h

60 lines
1.4 KiB
C
Raw Normal View History

2022-02-23 07:12:51 -05:00
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
// This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
#pragma once
#include "lobject.h"
/*
* WARNING: if you change the order of this enumeration,
* grep "ORDER TM"
*/
// clang-format off
typedef enum
{
TM_INDEX,
TM_NEWINDEX,
TM_MODE,
TM_NAMECALL,
2022-05-06 20:10:54 -04:00
TM_CALL,
TM_ITER,
2022-07-09 17:39:46 -04:00
TM_LEN,
2022-02-23 07:12:51 -05:00
2022-08-23 05:35:40 -04:00
TM_EQ, // last tag method with `fast' access
2022-02-23 07:12:51 -05:00
TM_ADD,
TM_SUB,
TM_MUL,
TM_DIV,
TM_MOD,
TM_POW,
TM_UNM,
TM_LT,
TM_LE,
TM_CONCAT,
TM_TYPE,
2022-10-08 18:20:40 -04:00
TM_METATABLE,
2022-02-23 07:12:51 -05:00
2022-08-23 05:35:40 -04:00
TM_N // number of elements in the enum
2022-02-23 07:12:51 -05:00
} TMS;
// clang-format on
2022-06-27 08:26:42 -04:00
#define gfasttm(g, et, e) ((et) == NULL ? NULL : ((et)->tmcache & (1u << (e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
2022-02-23 07:12:51 -05:00
#define fasttm(l, et, e) gfasttm(l->global, et, e)
2022-06-27 08:26:42 -04:00
#define fastnotm(et, e) ((et) == NULL || ((et)->tmcache & (1u << (e))))
2022-02-23 07:12:51 -05:00
LUAI_DATA const char* const luaT_typenames[];
LUAI_DATA const char* const luaT_eventname[];
LUAI_FUNC const TValue* luaT_gettm(Table* events, TMS event, TString* ename);
LUAI_FUNC const TValue* luaT_gettmbyobj(lua_State* L, const TValue* o, TMS event);
LUAI_FUNC const TString* luaT_objtypenamestr(lua_State* L, const TValue* o);
LUAI_FUNC const char* luaT_objtypename(lua_State* L, const TValue* o);
LUAI_FUNC void luaT_init(lua_State* L);