MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / parlist

Function parlist

3rd/lua-5.4.3/src/lparser.c:947–975  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

945
946
947static void parlist (LexState *ls) {
948 /* parlist -> [ {NAME ','} (NAME | '...') ] */
949 FuncState *fs = ls->fs;
950 Proto *f = fs->f;
951 int nparams = 0;
952 int isvararg = 0;
953 if (ls->t.token != ')') { /* is 'parlist' not empty? */
954 do {
955 switch (ls->t.token) {
956 case TK_NAME: {
957 new_localvar(ls, str_checkname(ls));
958 nparams++;
959 break;
960 }
961 case TK_DOTS: {
962 luaX_next(ls);
963 isvararg = 1;
964 break;
965 }
966 default: luaX_syntaxerror(ls, "<name> or '...' expected");
967 }
968 } while (!isvararg && testnext(ls, ','));
969 }
970 adjustlocalvars(ls, nparams);
971 f->numparams = cast_byte(fs->nactvar);
972 if (isvararg)
973 setvararg(fs, f->numparams); /* declared vararg */
974 luaK_reserveregs(fs, fs->nactvar); /* reserve registers for parameters */
975}
976
977
978static void body (LexState *ls, expdesc *e, int ismethod, int line) {

Callers 1

bodyFunction · 0.85

Calls 8

new_localvarFunction · 0.85
str_checknameFunction · 0.85
luaX_nextFunction · 0.85
luaX_syntaxerrorFunction · 0.85
testnextFunction · 0.85
adjustlocalvarsFunction · 0.85
setvarargFunction · 0.85
luaK_reserveregsFunction · 0.85

Tested by

no test coverage detected