diff options
Diffstat (limited to 'lapi.h')
-rw-r--r-- | lapi.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -11,12 +11,22 @@ | |||
11 | #include "llimits.h" | 11 | #include "llimits.h" |
12 | #include "lstate.h" | 12 | #include "lstate.h" |
13 | 13 | ||
14 | |||
15 | /* Increments 'L->top', checking for stack overflows */ | ||
14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ | 16 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ |
15 | "stack overflow");} | 17 | "stack overflow");} |
16 | 18 | ||
19 | |||
20 | /* | ||
21 | ** If a call returns too many multiple returns, the callee may not have | ||
22 | ** stack space to accomodate all results. In this case, this macro | ||
23 | ** increases its stack space ('L->ci->top'). | ||
24 | */ | ||
17 | #define adjustresults(L,nres) \ | 25 | #define adjustresults(L,nres) \ |
18 | { if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } | 26 | { if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } |
19 | 27 | ||
28 | |||
29 | /* Ensure the stack has at least 'n' elements */ | ||
20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ | 30 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ |
21 | "not enough elements in the stack") | 31 | "not enough elements in the stack") |
22 | 32 | ||