static void code_params (LexState *ls, int nparams, int dots) { FuncState *fs = ls->fs; adjustlocalvars(ls, nparams); luaX_checklimit(ls, fs->nactvar, MAXPARAMS, "parameters"); fs->f->numparams = cast(lu_byte, fs->nactvar); fs->f->is_vararg = cast(lu_byte, dots); if (dots) create_local(ls, "arg"); luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ }
static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { int i; Proto *f = fs->f; for (i=0; i<f->nups; i++) { if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->info) { lua_assert(fs->f->upvalues[i] == name); return i; } } /* new one */ luaX_checklimit(fs->ls, f->nups + 1, MAXUPVALUES, "upvalues"); luaM_growvector(fs->L, fs->f->upvalues, f->nups, fs->f->sizeupvalues, TString *, MAX_INT, ""); fs->f->upvalues[f->nups] = name; fs->upvalues[f->nups] = *v; return f->nups++; }
static void recfield (LexState *ls, struct ConsControl *cc) { /* recfield -> (NAME | `['exp1`]') = exp1 */ FuncState *fs = ls->fs; int reg = ls->fs->freereg; expdesc key, val; if (ls->t.token == TK_NAME) { luaX_checklimit(ls, cc->nh, MAX_INT, "items in a constructor"); cc->nh++; checkname(ls, &key); } else /* ls->t.token == '[' */ luaY_index(ls, &key); check(ls, '='); luaK_exp2RK(fs, &key); expr(ls, &val); luaK_codeABC(fs, OP_SETTABLE, cc->t->info, luaK_exp2RK(fs, &key), luaK_exp2RK(fs, &val)); fs->freereg = reg; /* free registers */ }
static void listfield (LexState *ls, struct ConsControl *cc) { expr(ls, &cc->v); luaX_checklimit(ls, cc->na, MAXARG_Bx, "items in a constructor"); cc->na++; cc->tostore++; }
static void new_localvar (LexState *ls, TString *name, int n) { FuncState *fs = ls->fs; luaX_checklimit(ls, fs->nactvar+n+1, MAXVARS, "local variables"); fs->actvar[fs->nactvar+n] = luaI_registerlocalvar(ls, name); }
static void inclinenumber (LexState *LS) { next(LS); /* skip `\n' */ ++LS->linenumber; luaX_checklimit(LS, LS->linenumber, MAX_INT, "lines in a chunk"); }