diff --git a/ldo.c b/ldo.c index d0c65a4b..0b4e9569 100644 --- a/ldo.c +++ b/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 2.151 2015/12/16 16:40:07 roberto Exp roberto $ +** $Id: ldo.c,v 2.152 2016/07/29 17:12:44 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -374,13 +374,13 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { int n = cast_int(L->top - func) - 1; /* number of real arguments */ int fsize = p->maxstacksize; /* frame size */ checkstackp(L, fsize, func); - if (p->is_vararg != 1) { /* do not use vararg? */ + if (p->is_vararg) + base = adjust_varargs(L, p, n); + else { /* non vararg function */ for (; n < p->numparams; n++) setnilvalue(L->top++); /* complete missing arguments */ base = func + 1; } - else - base = adjust_varargs(L, p, n); ci = next_ci(L); /* now 'enter' new function */ ci->nresults = nresults; ci->func = func; diff --git a/lobject.h b/lobject.h index 79b467e8..eeddfdef 100644 --- a/lobject.h +++ b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 2.115 2015/10/28 17:28:40 roberto Exp roberto $ +** $Id: lobject.h,v 2.116 2015/11/03 18:33:10 roberto Exp roberto $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -407,7 +407,7 @@ typedef struct LocVar { typedef struct Proto { CommonHeader; lu_byte numparams; /* number of fixed parameters */ - lu_byte is_vararg; /* 2: declared vararg; 1: uses vararg */ + lu_byte is_vararg; lu_byte maxstacksize; /* number of registers needed by this function */ int sizeupvalues; /* size of 'upvalues' */ int sizek; /* size of 'k' */ diff --git a/lparser.c b/lparser.c index 2a818388..5894d8ff 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.153 2016/05/13 19:10:16 roberto Exp roberto $ +** $Id: lparser.c,v 2.154 2016/06/22 15:48:25 roberto Exp roberto $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -766,7 +766,7 @@ static void parlist (LexState *ls) { } case TK_DOTS: { /* param -> '...' */ luaX_next(ls); - f->is_vararg = 2; /* declared vararg */ + f->is_vararg = 1; /* declared vararg */ break; } default: luaX_syntaxerror(ls, " or '...' expected"); @@ -962,7 +962,6 @@ static void simpleexp (LexState *ls, expdesc *v) { FuncState *fs = ls->fs; check_condition(ls, fs->f->is_vararg, "cannot use '...' outside a vararg function"); - fs->f->is_vararg = 1; /* function actually uses vararg */ init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); break; } @@ -1614,7 +1613,7 @@ static void mainfunc (LexState *ls, FuncState *fs) { BlockCnt bl; expdesc v; open_func(ls, fs, &bl); - fs->f->is_vararg = 2; /* main function is always declared vararg */ + fs->f->is_vararg = 1; /* main function is always declared vararg */ init_exp(&v, VLOCAL, 0); /* create and... */ newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */ luaX_next(ls); /* read first token */