Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/CodeGen/src/NativeState.cpp
2725 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
#include "NativeState.h"
3
4
#include "Luau/UnwindBuilder.h"
5
6
#include "CodeGenUtils.h"
7
8
#include "lbuiltins.h"
9
#include "lgc.h"
10
#include "ltable.h"
11
#include "lfunc.h"
12
#include "lvm.h"
13
14
#include <math.h>
15
#include <string.h>
16
17
namespace Luau
18
{
19
namespace CodeGen
20
{
21
22
void initFunctions(NativeContext& context)
23
{
24
static_assert(sizeof(context.luauF_table) == sizeof(luauF_table), "fastcall tables are not of the same length");
25
memcpy(context.luauF_table, luauF_table, sizeof(luauF_table));
26
27
context.luaV_lessthan = luaV_lessthan;
28
context.luaV_lessequal = luaV_lessequal;
29
context.luaV_equalval = luaV_equalval;
30
31
context.luaV_doarithadd = luaV_doarithimpl<TM_ADD>;
32
context.luaV_doarithsub = luaV_doarithimpl<TM_SUB>;
33
context.luaV_doarithmul = luaV_doarithimpl<TM_MUL>;
34
context.luaV_doarithdiv = luaV_doarithimpl<TM_DIV>;
35
context.luaV_doarithidiv = luaV_doarithimpl<TM_IDIV>;
36
context.luaV_doarithmod = luaV_doarithimpl<TM_MOD>;
37
context.luaV_doarithpow = luaV_doarithimpl<TM_POW>;
38
context.luaV_doarithunm = luaV_doarithimpl<TM_UNM>;
39
40
context.luaV_dolen = luaV_dolen;
41
context.luaV_gettable = luaV_gettable;
42
context.luaV_settable = luaV_settable;
43
context.luaV_concat = luaV_concat;
44
45
context.luaH_getn = luaH_getn;
46
context.luaH_new = luaH_new;
47
context.luaH_clone = luaH_clone;
48
context.luaH_resizearray = luaH_resizearray;
49
context.luaH_setnum = luaH_setnum;
50
51
context.luaC_barriertable = luaC_barriertable;
52
context.luaC_barrierf = luaC_barrierf;
53
context.luaC_barrierback = luaC_barrierback;
54
context.luaC_step = luaC_step;
55
56
context.luaF_close = luaF_close;
57
context.luaF_findupval = luaF_findupval;
58
context.luaF_newLclosure = luaF_newLclosure;
59
60
context.luaT_gettm = luaT_gettm;
61
context.luaT_objtypenamestr = luaT_objtypenamestr;
62
63
context.libm_exp = exp;
64
context.libm_pow = pow;
65
context.libm_fmod = fmod;
66
context.libm_log = log;
67
context.libm_log2 = log2;
68
context.libm_log10 = log10;
69
context.libm_ldexp = ldexp;
70
context.libm_round = round;
71
context.libm_frexp = frexp;
72
context.libm_modf = modf;
73
74
context.libm_asin = asin;
75
context.libm_sin = sin;
76
context.libm_sinh = sinh;
77
context.libm_acos = acos;
78
context.libm_cos = cos;
79
context.libm_cosh = cosh;
80
context.libm_atan = atan;
81
context.libm_atan2 = atan2;
82
context.libm_tan = tan;
83
context.libm_tanh = tanh;
84
85
context.forgLoopTableIter = forgLoopTableIter;
86
context.forgLoopNodeIter = forgLoopNodeIter;
87
context.forgLoopNonTableFallback = forgLoopNonTableFallback;
88
context.forgPrepXnextFallback = forgPrepXnextFallback;
89
context.callProlog = callProlog;
90
context.callEpilogC = callEpilogC;
91
context.newUserdata = newUserdata;
92
context.getImport = getImport;
93
94
context.callFallback = callFallback;
95
96
context.executeGETGLOBAL = executeGETGLOBAL;
97
context.executeSETGLOBAL = executeSETGLOBAL;
98
context.executeGETTABLEKS = executeGETTABLEKS;
99
context.executeSETTABLEKS = executeSETTABLEKS;
100
101
context.executeNAMECALL = executeNAMECALL;
102
context.executeFORGPREP = executeFORGPREP;
103
context.executeGETVARARGSMultRet = executeGETVARARGSMultRet;
104
context.executeGETVARARGSConst = executeGETVARARGSConst;
105
context.executeDUPCLOSURE = executeDUPCLOSURE;
106
context.executePREPVARARGS = executePREPVARARGS;
107
context.executeSETLIST = executeSETLIST;
108
}
109
110
} // namespace CodeGen
111
} // namespace Luau
112
113