Lines Matching full:ls
62 static void statement (LexState *ls);
63 static void expr (LexState *ls, expdesc *v);
67 static l_noret semerror (LexState *ls, const char *msg) { in semerror() argument
68 ls->t.token = 0; /* remove "near <token>" from final message */ in semerror()
69 luaX_syntaxerror(ls, msg); in semerror()
73 static l_noret error_expected (LexState *ls, int token) { in error_expected() argument
74 luaX_syntaxerror(ls, in error_expected()
75 luaO_pushfstring(ls->L, "%s expected", luaX_token2str(ls, token))); in error_expected()
80 lua_State *L = fs->ls->L; in errorlimit()
88 luaX_syntaxerror(fs->ls, msg); in errorlimit()
97 static int testnext (LexState *ls, int c) { in testnext() argument
98 if (ls->t.token == c) { in testnext()
99 luaX_next(ls); in testnext()
106 static void check (LexState *ls, int c) { in check() argument
107 if (ls->t.token != c) in check()
108 error_expected(ls, c); in check()
112 static void checknext (LexState *ls, int c) { in checknext() argument
113 check(ls, c); in checknext()
114 luaX_next(ls); in checknext()
118 #define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } argument
122 static void check_match (LexState *ls, int what, int who, int where) { in check_match() argument
123 if (!testnext(ls, what)) { in check_match()
124 if (where == ls->linenumber) in check_match()
125 error_expected(ls, what); in check_match()
127 luaX_syntaxerror(ls, luaO_pushfstring(ls->L, in check_match()
129 luaX_token2str(ls, what), luaX_token2str(ls, who), where)); in check_match()
135 static TString *str_checkname (LexState *ls) { in str_checkname() argument
137 check(ls, TK_NAME); in str_checkname()
138 ts = ls->t.seminfo.ts; in str_checkname()
139 luaX_next(ls); in str_checkname()
151 static void codestring (LexState *ls, expdesc *e, TString *s) { in codestring() argument
152 init_exp(e, VK, luaK_stringK(ls->fs, s)); in codestring()
156 static void checkname (LexState *ls, expdesc *e) { in checkname() argument
157 codestring(ls, e, str_checkname(ls)); in checkname()
161 static int registerlocalvar (LexState *ls, TString *varname) { in registerlocalvar() argument
162 FuncState *fs = ls->fs; in registerlocalvar()
165 luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, in registerlocalvar()
170 luaC_objbarrier(ls->L, f, varname); in registerlocalvar()
175 static void new_localvar (LexState *ls, TString *name) { in new_localvar() argument
176 FuncState *fs = ls->fs; in new_localvar()
177 Dyndata *dyd = ls->dyd; in new_localvar()
178 int reg = registerlocalvar(ls, name); in new_localvar()
181 luaM_growvector(ls->L, dyd->actvar.arr, dyd->actvar.n + 1, in new_localvar()
187 static void new_localvarliteral_ (LexState *ls, const char *name, size_t sz) { in new_localvarliteral_() argument
188 new_localvar(ls, luaX_newstring(ls, name, sz)); in new_localvarliteral_()
191 #define new_localvarliteral(ls,v) \ argument
192 new_localvarliteral_(ls, "" v, (sizeof(v)/sizeof(char))-1)
196 int idx = fs->ls->dyd->actvar.arr[fs->firstlocal + i].idx; in getlocvar()
202 static void adjustlocalvars (LexState *ls, int nvars) { in adjustlocalvars() argument
203 FuncState *fs = ls->fs; in adjustlocalvars()
212 fs->ls->dyd->actvar.n -= (fs->nactvar - tolevel); in removevars()
232 luaM_growvector(fs->ls->L, f->upvalues, fs->nups, f->sizeupvalues, in newupvalue()
239 luaC_objbarrier(fs->ls->L, f, name); in newupvalue()
295 static void singlevar (LexState *ls, expdesc *var) { in singlevar() argument
296 TString *varname = str_checkname(ls); in singlevar()
297 FuncState *fs = ls->fs; in singlevar()
301 singlevaraux(fs, ls->envn, var, 1); /* get environment variable */ in singlevar()
303 codestring(ls, &key, varname); /* key is variable name */ in singlevar()
309 static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { in adjust_assign() argument
310 FuncState *fs = ls->fs; in adjust_assign()
327 ls->fs->freereg -= nexps - nvars; /* remove extra values */ in adjust_assign()
331 static void enterlevel (LexState *ls) { in enterlevel() argument
332 lua_State *L = ls->L; in enterlevel()
334 checklimit(ls->fs, L->nCcalls, LUAI_MAXCCALLS, "C levels"); in enterlevel()
338 #define leavelevel(ls) ((ls)->L->nCcalls--) argument
341 static void closegoto (LexState *ls, int g, Labeldesc *label) { in closegoto() argument
343 FuncState *fs = ls->fs; in closegoto()
344 Labellist *gl = &ls->dyd->gt; in closegoto()
349 const char *msg = luaO_pushfstring(ls->L, in closegoto()
352 semerror(ls, msg); in closegoto()
365 static int findlabel (LexState *ls, int g) { in findlabel() argument
367 BlockCnt *bl = ls->fs->bl; in findlabel()
368 Dyndata *dyd = ls->dyd; in findlabel()
376 luaK_patchclose(ls->fs, gt->pc, lb->nactvar); in findlabel()
377 closegoto(ls, g, lb); /* close it */ in findlabel()
385 static int newlabelentry (LexState *ls, Labellist *l, TString *name, in newlabelentry() argument
388 luaM_growvector(ls->L, l->arr, n, l->size, in newlabelentry()
392 l->arr[n].nactvar = ls->fs->nactvar; in newlabelentry()
403 static void findgotos (LexState *ls, Labeldesc *lb) { in findgotos() argument
404 Labellist *gl = &ls->dyd->gt; in findgotos()
405 int i = ls->fs->bl->firstgoto; in findgotos()
408 closegoto(ls, i, lb); in findgotos()
423 Labellist *gl = &fs->ls->dyd->gt; in movegotosout()
433 if (!findlabel(fs->ls, i)) in movegotosout()
442 bl->firstlabel = fs->ls->dyd->label.n; in enterblock()
443 bl->firstgoto = fs->ls->dyd->gt.n; in enterblock()
454 static void breaklabel (LexState *ls) { in breaklabel() argument
455 TString *n = luaS_new(ls->L, "break"); in breaklabel()
456 int l = newlabelentry(ls, &ls->dyd->label, n, 0, ls->fs->pc); in breaklabel()
457 findgotos(ls, &ls->dyd->label.arr[l]); in breaklabel()
464 static l_noret undefgoto (LexState *ls, Labeldesc *gt) { in undefgoto() argument
468 msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line); in undefgoto()
469 semerror(ls, msg); in undefgoto()
475 LexState *ls = fs->ls; in leaveblock() local
483 breaklabel(ls); /* close pending breaks */ in leaveblock()
488 ls->dyd->label.n = bl->firstlabel; /* remove local labels */ in leaveblock()
491 else if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */ in leaveblock()
492 undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */ in leaveblock()
499 static Proto *addprototype (LexState *ls) { in addprototype() argument
501 lua_State *L = ls->L; in addprototype()
502 FuncState *fs = ls->fs; in addprototype()
522 static void codeclosure (LexState *ls, expdesc *v) { in codeclosure() argument
523 FuncState *fs = ls->fs->prev; in codeclosure()
529 static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) { in open_func() argument
531 fs->prev = ls->fs; /* linked list of funcstates */ in open_func()
532 fs->ls = ls; in open_func()
533 ls->fs = fs; in open_func()
543 fs->firstlocal = ls->dyd->actvar.n; in open_func()
546 f->source = ls->source; in open_func()
552 static void close_func (LexState *ls) { in close_func() argument
553 lua_State *L = ls->L; in close_func()
554 FuncState *fs = ls->fs; in close_func()
571 ls->fs = fs->prev; in close_func()
587 static int block_follow (LexState *ls, int withuntil) { in block_follow() argument
588 switch (ls->t.token) { in block_follow()
598 static void statlist (LexState *ls) { in statlist() argument
600 while (!block_follow(ls, 1)) { in statlist()
601 if (ls->t.token == TK_RETURN) { in statlist()
602 statement(ls); in statlist()
605 statement(ls); in statlist()
610 static void fieldsel (LexState *ls, expdesc *v) { in fieldsel() argument
612 FuncState *fs = ls->fs; in fieldsel()
615 luaX_next(ls); /* skip the dot or colon */ in fieldsel()
616 checkname(ls, &key); in fieldsel()
621 static void yindex (LexState *ls, expdesc *v) { in yindex() argument
623 luaX_next(ls); /* skip the '[' */ in yindex()
624 expr(ls, v); in yindex()
625 luaK_exp2val(ls->fs, v); in yindex()
626 checknext(ls, ']'); in yindex()
646 static void recfield (LexState *ls, struct ConsControl *cc) { in recfield() argument
648 FuncState *fs = ls->fs; in recfield()
649 int reg = ls->fs->freereg; in recfield()
652 if (ls->t.token == TK_NAME) { in recfield()
654 checkname(ls, &key); in recfield()
656 else /* ls->t.token == '[' */ in recfield()
657 yindex(ls, &key); in recfield()
659 checknext(ls, '='); in recfield()
661 expr(ls, &val); in recfield()
693 static void listfield (LexState *ls, struct ConsControl *cc) { in listfield() argument
695 expr(ls, &cc->v); in listfield()
696 checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); in listfield()
702 static void field (LexState *ls, struct ConsControl *cc) { in field() argument
704 switch(ls->t.token) { in field()
706 if (luaX_lookahead(ls) != '=') /* expression? */ in field()
707 listfield(ls, cc); in field()
709 recfield(ls, cc); in field()
713 recfield(ls, cc); in field()
717 listfield(ls, cc); in field()
724 static void constructor (LexState *ls, expdesc *t) { in constructor() argument
727 FuncState *fs = ls->fs; in constructor()
728 int line = ls->linenumber; in constructor()
735 luaK_exp2nextreg(ls->fs, t); /* fix it at stack top */ in constructor()
736 checknext(ls, '{'); in constructor()
739 if (ls->t.token == '}') break; in constructor()
741 field(ls, &cc); in constructor()
742 } while (testnext(ls, ',') || testnext(ls, ';')); in constructor()
743 check_match(ls, '}', '{', line); in constructor()
753 static void parlist (LexState *ls) { in parlist() argument
755 FuncState *fs = ls->fs; in parlist()
759 if (ls->t.token != ')') { /* is 'parlist' not empty? */ in parlist()
761 switch (ls->t.token) { in parlist()
763 new_localvar(ls, str_checkname(ls)); in parlist()
768 luaX_next(ls); in parlist()
772 default: luaX_syntaxerror(ls, "<name> or '...' expected"); in parlist()
774 } while (!f->is_vararg && testnext(ls, ',')); in parlist()
776 adjustlocalvars(ls, nparams); in parlist()
782 static void body (LexState *ls, expdesc *e, int ismethod, int line) { in body() argument
786 new_fs.f = addprototype(ls); in body()
788 open_func(ls, &new_fs, &bl); in body()
789 checknext(ls, '('); in body()
791 new_localvarliteral(ls, "self"); /* create 'self' parameter */ in body()
792 adjustlocalvars(ls, 1); in body()
794 parlist(ls); in body()
795 checknext(ls, ')'); in body()
796 statlist(ls); in body()
797 new_fs.f->lastlinedefined = ls->linenumber; in body()
798 check_match(ls, TK_END, TK_FUNCTION, line); in body()
799 codeclosure(ls, e); in body()
800 close_func(ls); in body()
804 static int explist (LexState *ls, expdesc *v) { in explist() argument
807 expr(ls, v); in explist()
808 while (testnext(ls, ',')) { in explist()
809 luaK_exp2nextreg(ls->fs, v); in explist()
810 expr(ls, v); in explist()
817 static void funcargs (LexState *ls, expdesc *f, int line) { in funcargs() argument
818 FuncState *fs = ls->fs; in funcargs()
821 switch (ls->t.token) { in funcargs()
823 luaX_next(ls); in funcargs()
824 if (ls->t.token == ')') /* arg list is empty? */ in funcargs()
827 explist(ls, &args); in funcargs()
830 check_match(ls, ')', '(', line); in funcargs()
834 constructor(ls, &args); in funcargs()
838 codestring(ls, &args, ls->t.seminfo.ts); in funcargs()
839 luaX_next(ls); /* must use 'seminfo' before 'next' */ in funcargs()
843 luaX_syntaxerror(ls, "function arguments expected"); in funcargs()
871 static void primaryexp (LexState *ls, expdesc *v) { in primaryexp() argument
873 switch (ls->t.token) { in primaryexp()
875 int line = ls->linenumber; in primaryexp()
876 luaX_next(ls); in primaryexp()
877 expr(ls, v); in primaryexp()
878 check_match(ls, ')', '(', line); in primaryexp()
879 luaK_dischargevars(ls->fs, v); in primaryexp()
883 singlevar(ls, v); in primaryexp()
887 luaX_syntaxerror(ls, "unexpected symbol"); in primaryexp()
893 static void suffixedexp (LexState *ls, expdesc *v) { in suffixedexp() argument
896 FuncState *fs = ls->fs; in suffixedexp()
897 int line = ls->linenumber; in suffixedexp()
898 primaryexp(ls, v); in suffixedexp()
900 switch (ls->t.token) { in suffixedexp()
902 fieldsel(ls, v); in suffixedexp()
908 yindex(ls, &key); in suffixedexp()
914 luaX_next(ls); in suffixedexp()
915 checkname(ls, &key); in suffixedexp()
917 funcargs(ls, v, line); in suffixedexp()
922 funcargs(ls, v, line); in suffixedexp()
931 static void simpleexp (LexState *ls, expdesc *v) { in simpleexp() argument
934 switch (ls->t.token) { in simpleexp()
937 v->u.nval = ls->t.seminfo.r; in simpleexp()
942 v->u.ival = ls->t.seminfo.i; in simpleexp()
946 codestring(ls, v, ls->t.seminfo.ts); in simpleexp()
962 FuncState *fs = ls->fs; in simpleexp()
963 check_condition(ls, fs->f->is_vararg, in simpleexp()
969 constructor(ls, v); in simpleexp()
973 luaX_next(ls); in simpleexp()
974 body(ls, v, 0, ls->linenumber); in simpleexp()
978 suffixedexp(ls, v); in simpleexp()
982 luaX_next(ls); in simpleexp()
1048 static BinOpr subexpr (LexState *ls, expdesc *v, int limit) { in subexpr() argument
1051 enterlevel(ls); in subexpr()
1052 uop = getunopr(ls->t.token); in subexpr()
1054 int line = ls->linenumber; in subexpr()
1055 luaX_next(ls); in subexpr()
1056 subexpr(ls, v, UNARY_PRIORITY); in subexpr()
1057 luaK_prefix(ls->fs, uop, v, line); in subexpr()
1059 else simpleexp(ls, v); in subexpr()
1061 op = getbinopr(ls->t.token); in subexpr()
1065 int line = ls->linenumber; in subexpr()
1066 luaX_next(ls); in subexpr()
1067 luaK_infix(ls->fs, op, v); in subexpr()
1069 nextop = subexpr(ls, &v2, priority[op].right); in subexpr()
1070 luaK_posfix(ls->fs, op, v, &v2, line); in subexpr()
1073 leavelevel(ls); in subexpr()
1078 static void expr (LexState *ls, expdesc *v) { in expr() argument
1079 subexpr(ls, v, 0); in expr()
1093 static void block (LexState *ls) { in block() argument
1095 FuncState *fs = ls->fs; in block()
1098 statlist(ls); in block()
1119 static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { in check_conflict() argument
1120 FuncState *fs = ls->fs; in check_conflict()
1147 static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { in assignment() argument
1149 check_condition(ls, vkisvar(lh->v.k), "syntax error"); in assignment()
1150 if (testnext(ls, ',')) { /* assignment -> ',' suffixedexp assignment */ in assignment()
1153 suffixedexp(ls, &nv.v); in assignment()
1155 check_conflict(ls, lh, &nv.v); in assignment()
1156 checklimit(ls->fs, nvars + ls->L->nCcalls, LUAI_MAXCCALLS, in assignment()
1158 assignment(ls, &nv, nvars+1); in assignment()
1162 checknext(ls, '='); in assignment()
1163 nexps = explist(ls, &e); in assignment()
1165 adjust_assign(ls, nvars, nexps, &e); in assignment()
1167 luaK_setoneret(ls->fs, &e); /* close last expression */ in assignment()
1168 luaK_storevar(ls->fs, &lh->v, &e); in assignment()
1172 init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ in assignment()
1173 luaK_storevar(ls->fs, &lh->v, &e); in assignment()
1177 static int cond (LexState *ls) { in cond() argument
1180 expr(ls, &v); /* read condition */ in cond()
1182 luaK_goiftrue(ls->fs, &v); in cond()
1187 static void gotostat (LexState *ls, int pc) { in gotostat() argument
1188 int line = ls->linenumber; in gotostat()
1191 if (testnext(ls, TK_GOTO)) in gotostat()
1192 label = str_checkname(ls); in gotostat()
1194 luaX_next(ls); /* skip break */ in gotostat()
1195 label = luaS_new(ls->L, "break"); in gotostat()
1197 g = newlabelentry(ls, &ls->dyd->gt, label, line, pc); in gotostat()
1198 findlabel(ls, g); /* close it if label already defined */ in gotostat()
1207 const char *msg = luaO_pushfstring(fs->ls->L, in checkrepeated()
1210 semerror(fs->ls, msg); in checkrepeated()
1217 static void skipnoopstat (LexState *ls) { in skipnoopstat() argument
1218 while (ls->t.token == ';' || ls->t.token == TK_DBCOLON) in skipnoopstat()
1219 statement(ls); in skipnoopstat()
1223 static void labelstat (LexState *ls, TString *label, int line) { in labelstat() argument
1225 FuncState *fs = ls->fs; in labelstat()
1226 Labellist *ll = &ls->dyd->label; in labelstat()
1229 checknext(ls, TK_DBCOLON); /* skip double colon */ in labelstat()
1231 l = newlabelentry(ls, ll, label, line, luaK_getlabel(fs)); in labelstat()
1232 skipnoopstat(ls); /* skip other no-op statements */ in labelstat()
1233 if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */ in labelstat()
1237 findgotos(ls, &ll->arr[l]); in labelstat()
1241 static void whilestat (LexState *ls, int line) { in whilestat() argument
1243 FuncState *fs = ls->fs; in whilestat()
1247 luaX_next(ls); /* skip WHILE */ in whilestat()
1249 condexit = cond(ls); in whilestat()
1251 checknext(ls, TK_DO); in whilestat()
1252 block(ls); in whilestat()
1254 check_match(ls, TK_END, TK_WHILE, line); in whilestat()
1260 static void repeatstat (LexState *ls, int line) { in repeatstat() argument
1263 FuncState *fs = ls->fs; in repeatstat()
1268 luaX_next(ls); /* skip REPEAT */ in repeatstat()
1269 statlist(ls); in repeatstat()
1270 check_match(ls, TK_UNTIL, TK_REPEAT, line); in repeatstat()
1271 condexit = cond(ls); /* read condition (inside scope block) */ in repeatstat()
1280 static int exp1 (LexState *ls) { in exp1() argument
1283 expr(ls, &e); in exp1()
1284 luaK_exp2nextreg(ls->fs, &e); in exp1()
1291 static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { in forbody() argument
1294 FuncState *fs = ls->fs; in forbody()
1296 adjustlocalvars(ls, 3); /* control variables */ in forbody()
1297 checknext(ls, TK_DO); in forbody()
1300 adjustlocalvars(ls, nvars); in forbody()
1302 block(ls); in forbody()
1317 static void fornum (LexState *ls, TString *varname, int line) { in fornum() argument
1319 FuncState *fs = ls->fs; in fornum()
1321 new_localvarliteral(ls, "(for index)"); in fornum()
1322 new_localvarliteral(ls, "(for limit)"); in fornum()
1323 new_localvarliteral(ls, "(for step)"); in fornum()
1324 new_localvar(ls, varname); in fornum()
1325 checknext(ls, '='); in fornum()
1326 exp1(ls); /* initial value */ in fornum()
1327 checknext(ls, ','); in fornum()
1328 exp1(ls); /* limit */ in fornum()
1329 if (testnext(ls, ',')) in fornum()
1330 exp1(ls); /* optional step */ in fornum()
1335 forbody(ls, base, line, 1, 1); in fornum()
1339 static void forlist (LexState *ls, TString *indexname) { in forlist() argument
1341 FuncState *fs = ls->fs; in forlist()
1347 new_localvarliteral(ls, "(for generator)"); in forlist()
1348 new_localvarliteral(ls, "(for state)"); in forlist()
1349 new_localvarliteral(ls, "(for control)"); in forlist()
1351 new_localvar(ls, indexname); in forlist()
1352 while (testnext(ls, ',')) { in forlist()
1353 new_localvar(ls, str_checkname(ls)); in forlist()
1356 checknext(ls, TK_IN); in forlist()
1357 line = ls->linenumber; in forlist()
1358 adjust_assign(ls, 3, explist(ls, &e), &e); in forlist()
1360 forbody(ls, base, line, nvars - 3, 0); in forlist()
1364 static void forstat (LexState *ls, int line) { in forstat() argument
1366 FuncState *fs = ls->fs; in forstat()
1370 luaX_next(ls); /* skip 'for' */ in forstat()
1371 varname = str_checkname(ls); /* first variable name */ in forstat()
1372 switch (ls->t.token) { in forstat()
1373 case '=': fornum(ls, varname, line); break; in forstat()
1374 case ',': case TK_IN: forlist(ls, varname); break; in forstat()
1375 default: luaX_syntaxerror(ls, "'=' or 'in' expected"); in forstat()
1377 check_match(ls, TK_END, TK_FOR, line); in forstat()
1382 static void test_then_block (LexState *ls, int *escapelist) { in test_then_block() argument
1385 FuncState *fs = ls->fs; in test_then_block()
1388 luaX_next(ls); /* skip IF or ELSEIF */ in test_then_block()
1389 expr(ls, &v); /* read condition */ in test_then_block()
1390 checknext(ls, TK_THEN); in test_then_block()
1391 if (ls->t.token == TK_GOTO || ls->t.token == TK_BREAK) { in test_then_block()
1392 luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */ in test_then_block()
1394 gotostat(ls, v.t); /* handle goto/break */ in test_then_block()
1395 while (testnext(ls, ';')) {} /* skip colons */ in test_then_block()
1396 if (block_follow(ls, 0)) { /* 'goto' is the entire block? */ in test_then_block()
1404 luaK_goiftrue(ls->fs, &v); /* skip over block if condition is false */ in test_then_block()
1408 statlist(ls); /* 'then' part */ in test_then_block()
1410 if (ls->t.token == TK_ELSE || in test_then_block()
1411 ls->t.token == TK_ELSEIF) /* followed by 'else'/'elseif'? */ in test_then_block()
1417 static void ifstat (LexState *ls, int line) { in ifstat() argument
1419 FuncState *fs = ls->fs; in ifstat()
1421 test_then_block(ls, &escapelist); /* IF cond THEN block */ in ifstat()
1422 while (ls->t.token == TK_ELSEIF) in ifstat()
1423 test_then_block(ls, &escapelist); /* ELSEIF cond THEN block */ in ifstat()
1424 if (testnext(ls, TK_ELSE)) in ifstat()
1425 block(ls); /* 'else' part */ in ifstat()
1426 check_match(ls, TK_END, TK_IF, line); in ifstat()
1431 static void localfunc (LexState *ls) { in localfunc() argument
1433 FuncState *fs = ls->fs; in localfunc()
1434 new_localvar(ls, str_checkname(ls)); /* new local variable */ in localfunc()
1435 adjustlocalvars(ls, 1); /* enter its scope */ in localfunc()
1436 body(ls, &b, 0, ls->linenumber); /* function created in next register */ in localfunc()
1442 static void localstat (LexState *ls) { in localstat() argument
1448 new_localvar(ls, str_checkname(ls)); in localstat()
1450 } while (testnext(ls, ',')); in localstat()
1451 if (testnext(ls, '=')) in localstat()
1452 nexps = explist(ls, &e); in localstat()
1457 adjust_assign(ls, nvars, nexps, &e); in localstat()
1458 adjustlocalvars(ls, nvars); in localstat()
1462 static int funcname (LexState *ls, expdesc *v) { in funcname() argument
1465 singlevar(ls, v); in funcname()
1466 while (ls->t.token == '.') in funcname()
1467 fieldsel(ls, v); in funcname()
1468 if (ls->t.token == ':') { in funcname()
1470 fieldsel(ls, v); in funcname()
1476 static void funcstat (LexState *ls, int line) { in funcstat() argument
1480 luaX_next(ls); /* skip FUNCTION */ in funcstat()
1481 ismethod = funcname(ls, &v); in funcstat()
1482 body(ls, &b, ismethod, line); in funcstat()
1483 luaK_storevar(ls->fs, &v, &b); in funcstat()
1484 luaK_fixline(ls->fs, line); /* definition "happens" in the first line */ in funcstat()
1488 static void exprstat (LexState *ls) { in exprstat() argument
1490 FuncState *fs = ls->fs; in exprstat()
1492 suffixedexp(ls, &v.v); in exprstat()
1493 if (ls->t.token == '=' || ls->t.token == ',') { /* stat -> assignment ? */ in exprstat()
1495 assignment(ls, &v, 1); in exprstat()
1498 check_condition(ls, v.v.k == VCALL, "syntax error"); in exprstat()
1504 static void retstat (LexState *ls) { in retstat() argument
1506 FuncState *fs = ls->fs; in retstat()
1509 if (block_follow(ls, 1) || ls->t.token == ';') in retstat()
1512 nret = explist(ls, &e); /* optional return values */ in retstat()
1533 testnext(ls, ';'); /* skip optional semicolon */ in retstat()
1537 static void statement (LexState *ls) { in statement() argument
1538 int line = ls->linenumber; /* may be needed for error messages */ in statement()
1539 enterlevel(ls); in statement()
1540 switch (ls->t.token) { in statement()
1542 luaX_next(ls); /* skip ';' */ in statement()
1546 ifstat(ls, line); in statement()
1550 whilestat(ls, line); in statement()
1554 luaX_next(ls); /* skip DO */ in statement()
1555 block(ls); in statement()
1556 check_match(ls, TK_END, TK_DO, line); in statement()
1560 forstat(ls, line); in statement()
1564 repeatstat(ls, line); in statement()
1568 funcstat(ls, line); in statement()
1572 luaX_next(ls); /* skip LOCAL */ in statement()
1573 if (testnext(ls, TK_FUNCTION)) /* local function? */ in statement()
1574 localfunc(ls); in statement()
1576 localstat(ls); in statement()
1580 luaX_next(ls); /* skip double colon */ in statement()
1581 labelstat(ls, str_checkname(ls), line); in statement()
1585 luaX_next(ls); /* skip RETURN */ in statement()
1586 retstat(ls); in statement()
1591 gotostat(ls, luaK_jump(ls->fs)); in statement()
1595 exprstat(ls); in statement()
1599 lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && in statement()
1600 ls->fs->freereg >= ls->fs->nactvar); in statement()
1601 ls->fs->freereg = ls->fs->nactvar; /* free registers */ in statement()
1602 leavelevel(ls); in statement()
1612 static void mainfunc (LexState *ls, FuncState *fs) { in mainfunc() argument
1615 open_func(ls, fs, &bl); in mainfunc()
1618 newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */ in mainfunc()
1619 luaX_next(ls); /* read first token */ in mainfunc()
1620 statlist(ls); /* parse main body */ in mainfunc()
1621 check(ls, TK_EOS); in mainfunc()
1622 close_func(ls); in mainfunc()