aboutsummaryrefslogtreecommitdiff
path: root/ltm.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltm.c')
-rw-r--r--ltm.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ltm.c b/ltm.c
index cc812e62..92a03e71 100644
--- a/ltm.c
+++ b/ltm.c
@@ -277,6 +277,28 @@ void luaT_adjustvarargs (lua_State *L, CallInfo *ci, const Proto *p) {
277} 277}
278 278
279 279
280void luaT_getvararg (CallInfo *ci, StkId ra, TValue *rc) {
281 int nextra = ci->u.l.nextraargs;
282 lua_Integer n;
283 if (tointegerns(rc, &n)) { /* integral value? */
284 if (l_castS2U(n) - 1 < cast_uint(nextra)) {
285 StkId slot = ci->func.p - nextra + cast_int(n) - 1;
286 setobjs2s(((lua_State*)NULL), ra, slot);
287 return;
288 }
289 }
290 else if (ttisshrstring(rc)) { /* short-string value? */
291 size_t len;
292 const char *s = getlstr(tsvalue(rc), len);
293 if (len == 1 && s[0] == 'n') { /* key is "n"? */
294 setivalue(s2v(ra), nextra);
295 return;
296 }
297 }
298 setnilvalue(s2v(ra)); /* else produce nil */
299}
300
301
280void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted) { 302void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted) {
281 int i; 303 int i;
282 int nextra = ci->u.l.nextraargs; 304 int nextra = ci->u.l.nextraargs;