2021-10-29 21:25:12 +01: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"
|
|
|
|
#include "lstate.h"
|
|
|
|
#include "luaconf.h"
|
|
|
|
#include "ldebug.h"
|
|
|
|
|
|
|
|
#define luaD_checkstack(L, n) \
|
|
|
|
if ((char*)L->stack_last - (char*)L->top <= (n) * (int)sizeof(TValue)) \
|
|
|
|
luaD_growstack(L, n); \
|
|
|
|
else \
|
2022-03-24 22:04:14 +00:00
|
|
|
condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK));
|
2021-10-29 21:25:12 +01:00
|
|
|
|
|
|
|
#define incr_top(L) \
|
|
|
|
{ \
|
|
|
|
luaD_checkstack(L, 1); \
|
|
|
|
L->top++; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define savestack(L, p) ((char*)(p) - (char*)L->stack)
|
|
|
|
#define restorestack(L, n) ((TValue*)((char*)L->stack + (n)))
|
|
|
|
|
|
|
|
#define expandstacklimit(L, p) \
|
|
|
|
{ \
|
|
|
|
LUAU_ASSERT((p) <= (L)->stack_last); \
|
|
|
|
if ((L)->ci->top < (p)) \
|
|
|
|
(L)->ci->top = (p); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define incr_ci(L) ((L->ci == L->end_ci) ? luaD_growCI(L) : (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci))
|
|
|
|
|
|
|
|
#define saveci(L, p) ((char*)(p) - (char*)L->base_ci)
|
|
|
|
#define restoreci(L, n) ((CallInfo*)((char*)L->base_ci + (n)))
|
|
|
|
|
2022-08-04 23:35:33 +01:00
|
|
|
// results from luaD_precall
|
|
|
|
#define PCRLUA 0 // initiated a call to a Lua function
|
|
|
|
#define PCRC 1 // did a call to a C function
|
|
|
|
#define PCRYIELD 2 // C function yielded
|
2021-10-29 21:25:12 +01:00
|
|
|
|
2022-08-04 23:35:33 +01:00
|
|
|
// type of protected functions, to be ran by `runprotected'
|
2021-10-29 21:25:12 +01:00
|
|
|
typedef void (*Pfunc)(lua_State* L, void* ud);
|
|
|
|
|
|
|
|
LUAI_FUNC CallInfo* luaD_growCI(lua_State* L);
|
|
|
|
|
|
|
|
LUAI_FUNC void luaD_call(lua_State* L, StkId func, int nResults);
|
|
|
|
LUAI_FUNC int luaD_pcall(lua_State* L, Pfunc func, void* u, ptrdiff_t oldtop, ptrdiff_t ef);
|
|
|
|
LUAI_FUNC void luaD_reallocCI(lua_State* L, int newsize);
|
|
|
|
LUAI_FUNC void luaD_reallocstack(lua_State* L, int newsize);
|
|
|
|
LUAI_FUNC void luaD_growstack(lua_State* L, int n);
|
2022-05-24 19:32:03 +01:00
|
|
|
LUAI_FUNC void luaD_checkCstack(lua_State* L);
|
2021-10-29 21:25:12 +01:00
|
|
|
|
|
|
|
LUAI_FUNC l_noret luaD_throw(lua_State* L, int errcode);
|
|
|
|
LUAI_FUNC int luaD_rawrunprotected(lua_State* L, Pfunc f, void* ud);
|