aboutsummaryrefslogtreecommitdiff
path: root/src/lua/ldo.h
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2020-06-22 16:50:40 +0800
committerLi Jin <dragon-fly@qq.com>2020-06-22 16:50:40 +0800
commitcd2b60b101a398cb9356d746364e70eaed1860f1 (patch)
treea1fe71b76faabc4883f16905a94164ce5c23e692 /src/lua/ldo.h
parent88c1052e700f38cf3d8ad82d469da4c487760b7e (diff)
downloadyuescript-cd2b60b101a398cb9356d746364e70eaed1860f1.tar.gz
yuescript-cd2b60b101a398cb9356d746364e70eaed1860f1.tar.bz2
yuescript-cd2b60b101a398cb9356d746364e70eaed1860f1.zip
add support for local variable declared with attribute 'close' and 'const' for Lua 5.4.
Diffstat (limited to 'src/lua/ldo.h')
-rw-r--r--src/lua/ldo.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/lua/ldo.h b/src/lua/ldo.h
new file mode 100644
index 0000000..7760f85
--- /dev/null
+++ b/src/lua/ldo.h
@@ -0,0 +1,75 @@
1/*
2** $Id: ldo.h $
3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h
5*/
6
7#ifndef ldo_h
8#define ldo_h
9
10
11#include "lobject.h"
12#include "lstate.h"
13#include "lzio.h"
14
15
16/*
17** Macro to check stack size and grow stack if needed. Parameters
18** 'pre'/'pos' allow the macro to preserve a pointer into the
19** stack across reallocations, doing the work only when needed.
20** 'condmovestack' is used in heavy tests to force a stack reallocation
21** at every check.
22*/
23#define luaD_checkstackaux(L,n,pre,pos) \
24 if (L->stack_last - L->top <= (n)) \
25 { pre; luaD_growstack(L, n, 1); pos; } \
26 else { condmovestack(L,pre,pos); }
27
28/* In general, 'pre'/'pos' are empty (nothing to save) */
29#define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0)
30
31
32
33#define savestack(L,p) ((char *)(p) - (char *)L->stack)
34#define restorestack(L,n) ((StkId)((char *)L->stack + (n)))
35
36
37/* macro to check stack size, preserving 'p' */
38#define checkstackp(L,n,p) \
39 luaD_checkstackaux(L, n, \
40 ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \
41 luaC_checkGC(L), /* stack grow uses memory */ \
42 p = restorestack(L, t__)) /* 'pos' part: restore 'p' */
43
44
45/* macro to check stack size and GC */
46#define checkstackGC(L,fsize) \
47 luaD_checkstackaux(L, (fsize), (void)0, luaC_checkGC(L))
48
49
50/* type of protected functions, to be ran by 'runprotected' */
51typedef void (*Pfunc) (lua_State *L, void *ud);
52
53LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
54LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
55 const char *mode);
56LUAI_FUNC void luaD_hook (lua_State *L, int event, int line,
57 int fTransfer, int nTransfer);
58LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci);
59LUAI_FUNC void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int n);
60LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
61LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults);
62LUAI_FUNC void luaD_tryfuncTM (lua_State *L, StkId func);
63LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
64 ptrdiff_t oldtop, ptrdiff_t ef);
65LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres);
66LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror);
67LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror);
68LUAI_FUNC void luaD_shrinkstack (lua_State *L);
69LUAI_FUNC void luaD_inctop (lua_State *L);
70
71LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
72LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
73
74#endif
75