aboutsummaryrefslogtreecommitdiff
path: root/src/lua/lapi.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/lapi.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/lapi.h')
-rw-r--r--src/lua/lapi.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/lua/lapi.h b/src/lua/lapi.h
new file mode 100644
index 0000000..41216b2
--- /dev/null
+++ b/src/lua/lapi.h
@@ -0,0 +1,47 @@
1/*
2** $Id: lapi.h $
3** Auxiliary functions from Lua API
4** See Copyright Notice in lua.h
5*/
6
7#ifndef lapi_h
8#define lapi_h
9
10
11#include "llimits.h"
12#include "lstate.h"
13
14
15/* Increments 'L->top', checking for stack overflows */
16#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \
17 "stack overflow");}
18
19
20/*
21** If a call returns too many multiple returns, the callee may not have
22** stack space to accommodate all results. In this case, this macro
23** increases its stack space ('L->ci->top').
24*/
25#define adjustresults(L,nres) \
26 { if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
27
28
29/* Ensure the stack has at least 'n' elements */
30#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \
31 "not enough elements in the stack")
32
33
34/*
35** To reduce the overhead of returning from C functions, the presence of
36** to-be-closed variables in these functions is coded in the CallInfo's
37** field 'nresults', in a way that functions with no to-be-closed variables
38** with zero, one, or "all" wanted results have no overhead. Functions
39** with other number of wanted results, as well as functions with
40** variables to be closed, have an extra check.
41*/
42
43#define hastocloseCfunc(n) ((n) < LUA_MULTRET)
44
45#define codeNresults(n) (-(n) - 3)
46
47#endif