changing {} style to match majority of previous style

This commit is contained in:
Philippe Teuwen 2019-03-10 11:20:22 +01:00
commit 961d929f4d
320 changed files with 5502 additions and 10485 deletions

View file

@ -57,8 +57,7 @@ static void statement(LexState *ls);
static void expr(LexState *ls, expdesc *v);
static void anchor_token(LexState *ls)
{
static void anchor_token(LexState *ls) {
/* last token from outer function must be EOS */
lua_assert(ls->fs != NULL || ls->t.token == TK_EOS);
if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) {
@ -69,22 +68,19 @@ static void anchor_token(LexState *ls)
/* semantic error */
static l_noret semerror(LexState *ls, const char *msg)
{
static l_noret semerror(LexState *ls, const char *msg) {
ls->t.token = 0; /* remove 'near to' from final message */
luaX_syntaxerror(ls, msg);
}
static l_noret error_expected(LexState *ls, int token)
{
static l_noret error_expected(LexState *ls, int token) {
luaX_syntaxerror(ls,
luaO_pushfstring(ls->L, "%s expected", luaX_token2str(ls, token)));
}
static l_noret errorlimit(FuncState *fs, int limit, const char *what)
{
static l_noret errorlimit(FuncState *fs, int limit, const char *what) {
lua_State *L = fs->ls->L;
const char *msg;
int line = fs->f->linedefined;
@ -97,14 +93,12 @@ static l_noret errorlimit(FuncState *fs, int limit, const char *what)
}
static void checklimit(FuncState *fs, int v, int l, const char *what)
{
static void checklimit(FuncState *fs, int v, int l, const char *what) {
if (v > l) errorlimit(fs, l, what);
}
static int testnext(LexState *ls, int c)
{
static int testnext(LexState *ls, int c) {
if (ls->t.token == c) {
luaX_next(ls);
return 1;
@ -112,15 +106,13 @@ static int testnext(LexState *ls, int c)
}
static void check(LexState *ls, int c)
{
static void check(LexState *ls, int c) {
if (ls->t.token != c)
error_expected(ls, c);
}
static void checknext(LexState *ls, int c)
{
static void checknext(LexState *ls, int c) {
check(ls, c);
luaX_next(ls);
}
@ -130,8 +122,7 @@ static void checknext(LexState *ls, int c)
static void check_match(LexState *ls, int what, int who, int where)
{
static void check_match(LexState *ls, int what, int who, int where) {
if (!testnext(ls, what)) {
if (where == ls->linenumber)
error_expected(ls, what);
@ -144,8 +135,7 @@ static void check_match(LexState *ls, int what, int who, int where)
}
static TString *str_checkname(LexState *ls)
{
static TString *str_checkname(LexState *ls) {
TString *ts;
check(ls, TK_NAME);
ts = ls->t.seminfo.ts;
@ -154,28 +144,24 @@ static TString *str_checkname(LexState *ls)
}
static void init_exp(expdesc *e, expkind k, int i)
{
static void init_exp(expdesc *e, expkind k, int i) {
e->f = e->t = NO_JUMP;
e->k = k;
e->u.info = i;
}
static void codestring(LexState *ls, expdesc *e, TString *s)
{
static void codestring(LexState *ls, expdesc *e, TString *s) {
init_exp(e, VK, luaK_stringK(ls->fs, s));
}
static void checkname(LexState *ls, expdesc *e)
{
static void checkname(LexState *ls, expdesc *e) {
codestring(ls, e, str_checkname(ls));
}
static int registerlocalvar(LexState *ls, TString *varname)
{
static int registerlocalvar(LexState *ls, TString *varname) {
FuncState *fs = ls->fs;
Proto *f = fs->f;
int oldsize = f->sizelocvars;
@ -188,8 +174,7 @@ static int registerlocalvar(LexState *ls, TString *varname)
}
static void new_localvar(LexState *ls, TString *name)
{
static void new_localvar(LexState *ls, TString *name) {
FuncState *fs = ls->fs;
Dyndata *dyd = ls->dyd;
int reg = registerlocalvar(ls, name);
@ -201,8 +186,7 @@ static void new_localvar(LexState *ls, TString *name)
}
static void new_localvarliteral_(LexState *ls, const char *name, size_t sz)
{
static void new_localvarliteral_(LexState *ls, const char *name, size_t sz) {
new_localvar(ls, luaX_newstring(ls, name, sz));
}
@ -210,16 +194,14 @@ static void new_localvarliteral_(LexState *ls, const char *name, size_t sz)
new_localvarliteral_(ls, "" v, (sizeof(v)/sizeof(char))-1)
static LocVar *getlocvar(FuncState *fs, int i)
{
static LocVar *getlocvar(FuncState *fs, int i) {
int idx = fs->ls->dyd->actvar.arr[fs->firstlocal + i].idx;
lua_assert(idx < fs->nlocvars);
return &fs->f->locvars[idx];
}
static void adjustlocalvars(LexState *ls, int nvars)
{
static void adjustlocalvars(LexState *ls, int nvars) {
FuncState *fs = ls->fs;
fs->nactvar = cast_byte(fs->nactvar + nvars);
for (; nvars; nvars--) {
@ -228,16 +210,14 @@ static void adjustlocalvars(LexState *ls, int nvars)
}
static void removevars(FuncState *fs, int tolevel)
{
static void removevars(FuncState *fs, int tolevel) {
fs->ls->dyd->actvar.n -= (fs->nactvar - tolevel);
while (fs->nactvar > tolevel)
getlocvar(fs, --fs->nactvar)->endpc = fs->pc;
}
static int searchupvalue(FuncState *fs, TString *name)
{
static int searchupvalue(FuncState *fs, TString *name) {
int i;
Upvaldesc *up = fs->f->upvalues;
for (i = 0; i < fs->nups; i++) {
@ -247,8 +227,7 @@ static int searchupvalue(FuncState *fs, TString *name)
}
static int newupvalue(FuncState *fs, TString *name, expdesc *v)
{
static int newupvalue(FuncState *fs, TString *name, expdesc *v) {
Proto *f = fs->f;
int oldsize = f->sizeupvalues;
checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues");
@ -263,8 +242,7 @@ static int newupvalue(FuncState *fs, TString *name, expdesc *v)
}
static int searchvar(FuncState *fs, TString *n)
{
static int searchvar(FuncState *fs, TString *n) {
int i;
for (i = cast_int(fs->nactvar) - 1; i >= 0; i--) {
if (luaS_eqstr(n, getlocvar(fs, i)->varname))
@ -278,8 +256,7 @@ static int searchvar(FuncState *fs, TString *n)
Mark block where variable at given level was defined
(to emit close instructions later).
*/
static void markupval(FuncState *fs, int level)
{
static void markupval(FuncState *fs, int level) {
BlockCnt *bl = fs->bl;
while (bl->nactvar > level) bl = bl->previous;
bl->upval = 1;
@ -290,8 +267,7 @@ static void markupval(FuncState *fs, int level)
Find variable with given name 'n'. If it is an upvalue, add this
upvalue into all intermediate functions.
*/
static int singlevaraux(FuncState *fs, TString *n, expdesc *var, int base)
{
static int singlevaraux(FuncState *fs, TString *n, expdesc *var, int base) {
if (fs == NULL) /* no more levels? */
return VVOID; /* default is global */
else {
@ -316,8 +292,7 @@ static int singlevaraux(FuncState *fs, TString *n, expdesc *var, int base)
}
static void singlevar(LexState *ls, expdesc *var)
{
static void singlevar(LexState *ls, expdesc *var) {
TString *varname = str_checkname(ls);
FuncState *fs = ls->fs;
if (singlevaraux(fs, varname, var, 1) == VVOID) { /* global name? */
@ -330,8 +305,7 @@ static void singlevar(LexState *ls, expdesc *var)
}
static void adjust_assign(LexState *ls, int nvars, int nexps, expdesc *e)
{
static void adjust_assign(LexState *ls, int nvars, int nexps, expdesc *e) {
FuncState *fs = ls->fs;
int extra = nvars - nexps;
if (hasmultret(e->k)) {
@ -350,8 +324,7 @@ static void adjust_assign(LexState *ls, int nvars, int nexps, expdesc *e)
}
static void enterlevel(LexState *ls)
{
static void enterlevel(LexState *ls) {
lua_State *L = ls->L;
++L->nCcalls;
checklimit(ls->fs, L->nCcalls, LUAI_MAXCCALLS, "C levels");
@ -361,8 +334,7 @@ static void enterlevel(LexState *ls)
#define leavelevel(ls) ((ls)->L->nCcalls--)
static void closegoto(LexState *ls, int g, Labeldesc *label)
{
static void closegoto(LexState *ls, int g, Labeldesc *label) {
int i;
FuncState *fs = ls->fs;
Labellist *gl = &ls->dyd->gt;
@ -386,8 +358,7 @@ static void closegoto(LexState *ls, int g, Labeldesc *label)
/*
** try to close a goto with existing labels; this solves backward jumps
*/
static int findlabel(LexState *ls, int g)
{
static int findlabel(LexState *ls, int g) {
int i;
BlockCnt *bl = ls->fs->bl;
Dyndata *dyd = ls->dyd;
@ -397,7 +368,7 @@ static int findlabel(LexState *ls, int g)
Labeldesc *lb = &dyd->label.arr[i];
if (luaS_eqstr(lb->name, gt->name)) { /* correct label? */
if (gt->nactvar > lb->nactvar &&
(bl->upval || dyd->label.n > bl->firstlabel))
(bl->upval || dyd->label.n > bl->firstlabel))
luaK_patchclose(ls->fs, gt->pc, lb->nactvar);
closegoto(ls, g, lb); /* close it */
return 1;
@ -408,8 +379,7 @@ static int findlabel(LexState *ls, int g)
static int newlabelentry(LexState *ls, Labellist *l, TString *name,
int line, int pc)
{
int line, int pc) {
int n = l->n;
luaM_growvector(ls->L, l->arr, n, l->size,
Labeldesc, SHRT_MAX, "labels/gotos");
@ -426,8 +396,7 @@ static int newlabelentry(LexState *ls, Labellist *l, TString *name,
** check whether new label 'lb' matches any pending gotos in current
** block; solves forward jumps
*/
static void findgotos(LexState *ls, Labeldesc *lb)
{
static void findgotos(LexState *ls, Labeldesc *lb) {
Labellist *gl = &ls->dyd->gt;
int i = ls->fs->bl->firstgoto;
while (i < gl->n) {
@ -445,8 +414,7 @@ static void findgotos(LexState *ls, Labeldesc *lb)
** the goto exits the scope of any variable (which can be the
** upvalue), close those variables being exited.
*/
static void movegotosout(FuncState *fs, BlockCnt *bl)
{
static void movegotosout(FuncState *fs, BlockCnt *bl) {
int i = bl->firstgoto;
Labellist *gl = &fs->ls->dyd->gt;
/* correct pending gotos to current block and try to close it
@ -464,8 +432,7 @@ static void movegotosout(FuncState *fs, BlockCnt *bl)
}
static void enterblock(FuncState *fs, BlockCnt *bl, lu_byte isloop)
{
static void enterblock(FuncState *fs, BlockCnt *bl, lu_byte isloop) {
bl->isloop = isloop;
bl->nactvar = fs->nactvar;
bl->firstlabel = fs->ls->dyd->label.n;
@ -480,8 +447,7 @@ static void enterblock(FuncState *fs, BlockCnt *bl, lu_byte isloop)
/*
** create a label named "break" to resolve break statements
*/
static void breaklabel(LexState *ls)
{
static void breaklabel(LexState *ls) {
TString *n = luaS_new(ls->L, "break");
int l = newlabelentry(ls, &ls->dyd->label, n, 0, ls->fs->pc);
findgotos(ls, &ls->dyd->label.arr[l]);
@ -491,8 +457,7 @@ static void breaklabel(LexState *ls)
** generates an error for an undefined 'goto'; choose appropriate
** message when label name is a reserved word (which can only be 'break')
*/
static l_noret undefgoto(LexState *ls, Labeldesc *gt)
{
static l_noret undefgoto(LexState *ls, Labeldesc *gt) {
const char *msg = isreserved(gt->name)
? "<%s> at line %d not inside a loop"
: "no visible label " LUA_QS " for <goto> at line %d";
@ -501,8 +466,7 @@ static l_noret undefgoto(LexState *ls, Labeldesc *gt)
}
static void leaveblock(FuncState *fs)
{
static void leaveblock(FuncState *fs) {
BlockCnt *bl = fs->bl;
LexState *ls = fs->ls;
if (bl->previous && bl->upval) {
@ -528,8 +492,7 @@ static void leaveblock(FuncState *fs)
/*
** adds a new prototype into list of prototypes
*/
static Proto *addprototype(LexState *ls)
{
static Proto *addprototype(LexState *ls) {
Proto *clp;
lua_State *L = ls->L;
FuncState *fs = ls->fs;
@ -551,16 +514,14 @@ static Proto *addprototype(LexState *ls)
** so that, if it invokes the GC, the GC knows which registers
** are in use at that time.
*/
static void codeclosure(LexState *ls, expdesc *v)
{
static void codeclosure(LexState *ls, expdesc *v) {
FuncState *fs = ls->fs->prev;
init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1));
luaK_exp2nextreg(fs, v); /* fix it at the last register */
}
static void open_func(LexState *ls, FuncState *fs, BlockCnt *bl)
{
static void open_func(LexState *ls, FuncState *fs, BlockCnt *bl) {
lua_State *L = ls->L;
Proto *f;
fs->prev = ls->fs; /* linked list of funcstates */
@ -588,8 +549,7 @@ static void open_func(LexState *ls, FuncState *fs, BlockCnt *bl)
}
static void close_func(LexState *ls)
{
static void close_func(LexState *ls) {
lua_State *L = ls->L;
FuncState *fs = ls->fs;
Proto *f = fs->f;
@ -627,8 +587,7 @@ static void close_func(LexState *ls)
** 'until' closes syntactical blocks, but do not close scope,
** so it handled in separate.
*/
static int block_follow(LexState *ls, int withuntil)
{
static int block_follow(LexState *ls, int withuntil) {
switch (ls->t.token) {
case TK_ELSE:
case TK_ELSEIF:
@ -643,8 +602,7 @@ static int block_follow(LexState *ls, int withuntil)
}
static void statlist(LexState *ls)
{
static void statlist(LexState *ls) {
/* statlist -> { stat [`;'] } */
while (!block_follow(ls, 1)) {
if (ls->t.token == TK_RETURN) {
@ -656,8 +614,7 @@ static void statlist(LexState *ls)
}
static void fieldsel(LexState *ls, expdesc *v)
{
static void fieldsel(LexState *ls, expdesc *v) {
/* fieldsel -> ['.' | ':'] NAME */
FuncState *fs = ls->fs;
expdesc key;
@ -668,8 +625,7 @@ static void fieldsel(LexState *ls, expdesc *v)
}
static void yindex(LexState *ls, expdesc *v)
{
static void yindex(LexState *ls, expdesc *v) {
/* index -> '[' expr ']' */
luaX_next(ls); /* skip the '[' */
expr(ls, v);
@ -694,8 +650,7 @@ struct ConsControl {
};
static void recfield(LexState *ls, struct ConsControl *cc)
{
static void recfield(LexState *ls, struct ConsControl *cc) {
/* recfield -> (NAME | `['exp1`]') = exp1 */
FuncState *fs = ls->fs;
int reg = ls->fs->freereg;
@ -715,8 +670,7 @@ static void recfield(LexState *ls, struct ConsControl *cc)
}
static void closelistfield(FuncState *fs, struct ConsControl *cc)
{
static void closelistfield(FuncState *fs, struct ConsControl *cc) {
if (cc->v.k == VVOID) return; /* there is no list item */
luaK_exp2nextreg(fs, &cc->v);
cc->v.k = VVOID;
@ -727,8 +681,7 @@ static void closelistfield(FuncState *fs, struct ConsControl *cc)
}
static void lastlistfield(FuncState *fs, struct ConsControl *cc)
{
static void lastlistfield(FuncState *fs, struct ConsControl *cc) {
if (cc->tostore == 0) return;
if (hasmultret(cc->v.k)) {
luaK_setmultret(fs, &cc->v);
@ -742,8 +695,7 @@ static void lastlistfield(FuncState *fs, struct ConsControl *cc)
}
static void listfield(LexState *ls, struct ConsControl *cc)
{
static void listfield(LexState *ls, struct ConsControl *cc) {
/* listfield -> exp */
expr(ls, &cc->v);
checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
@ -752,8 +704,7 @@ static void listfield(LexState *ls, struct ConsControl *cc)
}
static void field(LexState *ls, struct ConsControl *cc)
{
static void field(LexState *ls, struct ConsControl *cc) {
/* field -> listfield | recfield */
switch (ls->t.token) {
case TK_NAME: { /* may be 'listfield' or 'recfield' */
@ -775,8 +726,7 @@ static void field(LexState *ls, struct ConsControl *cc)
}
static void constructor(LexState *ls, expdesc *t)
{
static void constructor(LexState *ls, expdesc *t) {
/* constructor -> '{' [ field { sep field } [sep] ] '}'
sep -> ',' | ';' */
FuncState *fs = ls->fs;
@ -805,8 +755,7 @@ static void constructor(LexState *ls, expdesc *t)
static void parlist(LexState *ls)
{
static void parlist(LexState *ls) {
/* parlist -> [ param { `,' param } ] */
FuncState *fs = ls->fs;
Proto *f = fs->f;
@ -836,8 +785,7 @@ static void parlist(LexState *ls)
}
static void body(LexState *ls, expdesc *e, int ismethod, int line)
{
static void body(LexState *ls, expdesc *e, int ismethod, int line) {
/* body -> `(' parlist `)' block END */
FuncState new_fs;
BlockCnt bl;
@ -859,8 +807,7 @@ static void body(LexState *ls, expdesc *e, int ismethod, int line)
}
static int explist(LexState *ls, expdesc *v)
{
static int explist(LexState *ls, expdesc *v) {
/* explist -> expr { `,' expr } */
int n = 1; /* at least one expression */
expr(ls, v);
@ -873,8 +820,7 @@ static int explist(LexState *ls, expdesc *v)
}
static void funcargs(LexState *ls, expdesc *f, int line)
{
static void funcargs(LexState *ls, expdesc *f, int line) {
FuncState *fs = ls->fs;
expdesc args;
int base, nparams;
@ -928,8 +874,7 @@ static void funcargs(LexState *ls, expdesc *f, int line)
*/
static void primaryexp(LexState *ls, expdesc *v)
{
static void primaryexp(LexState *ls, expdesc *v) {
/* primaryexp -> NAME | '(' expr ')' */
switch (ls->t.token) {
case '(': {
@ -951,8 +896,7 @@ static void primaryexp(LexState *ls, expdesc *v)
}
static void suffixedexp(LexState *ls, expdesc *v)
{
static void suffixedexp(LexState *ls, expdesc *v) {
/* suffixedexp ->
primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */
FuncState *fs = ls->fs;
@ -993,8 +937,7 @@ static void suffixedexp(LexState *ls, expdesc *v)
}
static void simpleexp(LexState *ls, expdesc *v)
{
static void simpleexp(LexState *ls, expdesc *v) {
/* simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | ... |
constructor | FUNCTION body | suffixedexp */
switch (ls->t.token) {
@ -1044,8 +987,7 @@ static void simpleexp(LexState *ls, expdesc *v)
}
static UnOpr getunopr(int op)
{
static UnOpr getunopr(int op) {
switch (op) {
case TK_NOT:
return OPR_NOT;
@ -1059,8 +1001,7 @@ static UnOpr getunopr(int op)
}
static BinOpr getbinopr(int op)
{
static BinOpr getbinopr(int op) {
switch (op) {
case '+':
return OPR_ADD;
@ -1116,8 +1057,7 @@ static const struct {
** subexpr -> (simpleexp | unop subexpr) { binop subexpr }
** where `binop' is any binary operator with a priority higher than `limit'
*/
static BinOpr subexpr(LexState *ls, expdesc *v, int limit)
{
static BinOpr subexpr(LexState *ls, expdesc *v, int limit) {
BinOpr op;
UnOpr uop;
enterlevel(ls);
@ -1146,8 +1086,7 @@ static BinOpr subexpr(LexState *ls, expdesc *v, int limit)
}
static void expr(LexState *ls, expdesc *v)
{
static void expr(LexState *ls, expdesc *v) {
subexpr(ls, v, 0);
}
@ -1162,8 +1101,7 @@ static void expr(LexState *ls, expdesc *v)
*/
static void block(LexState *ls)
{
static void block(LexState *ls) {
/* block -> statlist */
FuncState *fs = ls->fs;
BlockCnt bl;
@ -1189,8 +1127,7 @@ struct LHS_assign {
** table. If so, save original upvalue/local value in a safe place and
** use this safe copy in the previous assignment.
*/
static void check_conflict(LexState *ls, struct LHS_assign *lh, expdesc *v)
{
static void check_conflict(LexState *ls, struct LHS_assign *lh, expdesc *v) {
FuncState *fs = ls->fs;
int extra = fs->freereg; /* eventual position to save local variable */
int conflict = 0;
@ -1218,8 +1155,7 @@ static void check_conflict(LexState *ls, struct LHS_assign *lh, expdesc *v)
}
static void assignment(LexState *ls, struct LHS_assign *lh, int nvars)
{
static void assignment(LexState *ls, struct LHS_assign *lh, int nvars) {
expdesc e;
check_condition(ls, vkisvar(lh->v.k), "syntax error");
if (testnext(ls, ',')) { /* assignment -> ',' suffixedexp assignment */
@ -1250,8 +1186,7 @@ static void assignment(LexState *ls, struct LHS_assign *lh, int nvars)
}
static int cond(LexState *ls)
{
static int cond(LexState *ls) {
/* cond -> exp */
expdesc v;
expr(ls, &v); /* read condition */
@ -1261,8 +1196,7 @@ static int cond(LexState *ls)
}
static void gotostat(LexState *ls, int pc)
{
static void gotostat(LexState *ls, int pc) {
int line = ls->linenumber;
TString *label;
int g;
@ -1278,8 +1212,7 @@ static void gotostat(LexState *ls, int pc)
/* check for repeated labels on the same block */
static void checkrepeated(FuncState *fs, Labellist *ll, TString *label)
{
static void checkrepeated(FuncState *fs, Labellist *ll, TString *label) {
int i;
for (i = fs->bl->firstlabel; i < ll->n; i++) {
if (luaS_eqstr(label, ll->arr[i].name)) {
@ -1293,15 +1226,13 @@ static void checkrepeated(FuncState *fs, Labellist *ll, TString *label)
/* skip no-op statements */
static void skipnoopstat(LexState *ls)
{
static void skipnoopstat(LexState *ls) {
while (ls->t.token == ';' || ls->t.token == TK_DBCOLON)
statement(ls);
}
static void labelstat(LexState *ls, TString *label, int line)
{
static void labelstat(LexState *ls, TString *label, int line) {
/* label -> '::' NAME '::' */
FuncState *fs = ls->fs;
Labellist *ll = &ls->dyd->label;
@ -1319,8 +1250,7 @@ static void labelstat(LexState *ls, TString *label, int line)
}
static void whilestat(LexState *ls, int line)
{
static void whilestat(LexState *ls, int line) {
/* whilestat -> WHILE cond DO block END */
FuncState *fs = ls->fs;
int whileinit;
@ -1339,8 +1269,7 @@ static void whilestat(LexState *ls, int line)
}
static void repeatstat(LexState *ls, int line)
{
static void repeatstat(LexState *ls, int line) {
/* repeatstat -> REPEAT block UNTIL cond */
int condexit;
FuncState *fs = ls->fs;
@ -1360,8 +1289,7 @@ static void repeatstat(LexState *ls, int line)
}
static int exp1(LexState *ls)
{
static int exp1(LexState *ls) {
expdesc e;
int reg;
expr(ls, &e);
@ -1372,8 +1300,7 @@ static int exp1(LexState *ls)
}
static void forbody(LexState *ls, int base, int line, int nvars, int isnum)
{
static void forbody(LexState *ls, int base, int line, int nvars, int isnum) {
/* forbody -> DO block */
BlockCnt bl;
FuncState *fs = ls->fs;
@ -1399,8 +1326,7 @@ static void forbody(LexState *ls, int base, int line, int nvars, int isnum)
}
static void fornum(LexState *ls, TString *varname, int line)
{
static void fornum(LexState *ls, TString *varname, int line) {
/* fornum -> NAME = exp1,exp1[,exp1] forbody */
FuncState *fs = ls->fs;
int base = fs->freereg;
@ -1422,8 +1348,7 @@ static void fornum(LexState *ls, TString *varname, int line)
}
static void forlist(LexState *ls, TString *indexname)
{
static void forlist(LexState *ls, TString *indexname) {
/* forlist -> NAME {,NAME} IN explist forbody */
FuncState *fs = ls->fs;
expdesc e;
@ -1448,8 +1373,7 @@ static void forlist(LexState *ls, TString *indexname)
}
static void forstat(LexState *ls, int line)
{
static void forstat(LexState *ls, int line) {
/* forstat -> FOR (fornum | forlist) END */
FuncState *fs = ls->fs;
TString *varname;
@ -1473,8 +1397,7 @@ static void forstat(LexState *ls, int line)
}
static void test_then_block(LexState *ls, int *escapelist)
{
static void test_then_block(LexState *ls, int *escapelist) {
/* test_then_block -> [IF | ELSEIF] cond THEN block */
BlockCnt bl;
FuncState *fs = ls->fs;
@ -1501,14 +1424,13 @@ static void test_then_block(LexState *ls, int *escapelist)
statlist(ls); /* `then' part */
leaveblock(fs);
if (ls->t.token == TK_ELSE ||
ls->t.token == TK_ELSEIF) /* followed by 'else'/'elseif'? */
ls->t.token == TK_ELSEIF) /* followed by 'else'/'elseif'? */
luaK_concat(fs, escapelist, luaK_jump(fs)); /* must jump over it */
luaK_patchtohere(fs, jf);
}
static void ifstat(LexState *ls, int line)
{
static void ifstat(LexState *ls, int line) {
/* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
FuncState *fs = ls->fs;
int escapelist = NO_JUMP; /* exit list for finished parts */
@ -1522,8 +1444,7 @@ static void ifstat(LexState *ls, int line)
}
static void localfunc(LexState *ls)
{
static void localfunc(LexState *ls) {
expdesc b;
FuncState *fs = ls->fs;
new_localvar(ls, str_checkname(ls)); /* new local variable */
@ -1534,8 +1455,7 @@ static void localfunc(LexState *ls)
}
static void localstat(LexState *ls)
{
static void localstat(LexState *ls) {
/* stat -> LOCAL NAME {`,' NAME} [`=' explist] */
int nvars = 0;
int nexps;
@ -1555,8 +1475,7 @@ static void localstat(LexState *ls)
}
static int funcname(LexState *ls, expdesc *v)
{
static int funcname(LexState *ls, expdesc *v) {
/* funcname -> NAME {fieldsel} [`:' NAME] */
int ismethod = 0;
singlevar(ls, v);
@ -1570,8 +1489,7 @@ static int funcname(LexState *ls, expdesc *v)
}
static void funcstat(LexState *ls, int line)
{
static void funcstat(LexState *ls, int line) {
/* funcstat -> FUNCTION funcname body */
int ismethod;
expdesc v, b;
@ -1583,8 +1501,7 @@ static void funcstat(LexState *ls, int line)
}
static void exprstat(LexState *ls)
{
static void exprstat(LexState *ls) {
/* stat -> func | assignment */
FuncState *fs = ls->fs;
struct LHS_assign v;
@ -1599,8 +1516,7 @@ static void exprstat(LexState *ls)
}
static void retstat(LexState *ls)
{
static void retstat(LexState *ls) {
/* stat -> RETURN [explist] [';'] */
FuncState *fs = ls->fs;
expdesc e;
@ -1632,8 +1548,7 @@ static void retstat(LexState *ls)
}
static void statement(LexState *ls)
{
static void statement(LexState *ls) {
int line = ls->linenumber; /* may be needed for error messages */
enterlevel(ls);
switch (ls->t.token) {
@ -1708,8 +1623,7 @@ static void statement(LexState *ls)
** compiles the main function, which is a regular vararg function with an
** upvalue named LUA_ENV
*/
static void mainfunc(LexState *ls, FuncState *fs)
{
static void mainfunc(LexState *ls, FuncState *fs) {
BlockCnt bl;
expdesc v;
open_func(ls, fs, &bl);
@ -1724,8 +1638,7 @@ static void mainfunc(LexState *ls, FuncState *fs)
Closure *luaY_parser(lua_State *L, ZIO *z, Mbuffer *buff,
Dyndata *dyd, const char *name, int firstchar)
{
Dyndata *dyd, const char *name, int firstchar) {
LexState lexstate;
FuncState funcstate;
Closure *cl = luaF_newLclosure(L, 1); /* create main closure */