Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/VM/src/ltm.h
2725 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
// This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3
#pragma once
4
5
#include "lobject.h"
6
7
/*
8
* WARNING: if you change the order of this enumeration,
9
* grep "ORDER TM"
10
*/
11
// clang-format off
12
typedef enum
13
{
14
TM_INDEX,
15
TM_NEWINDEX,
16
TM_MODE,
17
TM_NAMECALL,
18
TM_CALL,
19
TM_ITER,
20
TM_LEN,
21
22
TM_EQ, // last tag method with `fast' access
23
24
TM_ADD,
25
TM_SUB,
26
TM_MUL,
27
TM_DIV,
28
TM_IDIV,
29
TM_MOD,
30
TM_POW,
31
TM_UNM,
32
33
TM_LT,
34
TM_LE,
35
TM_CONCAT,
36
TM_TYPE,
37
TM_METATABLE,
38
39
TM_N // number of elements in the enum
40
} TMS;
41
// clang-format on
42
43
#define gfasttm(g, et, e) ((et) == NULL ? NULL : ((et)->tmcache & (1u << (e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
44
45
#define fasttm(l, et, e) gfasttm(l->global, et, e)
46
#define fastnotm(et, e) ((et) == NULL || ((et)->tmcache & (1u << (e))))
47
48
LUAI_DATA const char* const luaT_typenames[];
49
LUAI_DATA const char* const luaT_eventname[];
50
51
LUAI_FUNC const TValue* luaT_gettm(LuaTable* events, TMS event, TString* ename);
52
LUAI_FUNC const TValue* luaT_gettmbyobj(lua_State* L, const TValue* o, TMS event);
53
54
LUAI_FUNC const TString* luaT_objtypenamestr(lua_State* L, const TValue* o);
55
LUAI_FUNC const char* luaT_objtypename(lua_State* L, const TValue* o);
56
57
LUAI_FUNC void luaT_init(lua_State* L);
58
59