MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / indexupvalue

Function indexupvalue

Source/Misc/lua/src/lua.c:7759–7780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7757
7758
7759static int indexupvalue (FuncState *fs, TString *name, expdesc *v) {
7760int i;
7761Proto *f = fs->f;
7762int oldsize = f->sizeupvalues;
7763for (i=0; i<f->nups; i++) {
7764if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) {
7765lua_assert(f->upvalues[i] == name);
7766return i;
7767}
7768}
7769/* new one */
7770luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues");
7771luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues,
7772TString *, MAX_INT, "");
7773while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL;
7774f->upvalues[f->nups] = name;
7775luaC_objbarrier(fs->L, f, name);
7776lua_assert(v->k == VLOCAL || v->k == VUPVAL);
7777fs->upvalues[f->nups].k = cast_byte(v->k);
7778fs->upvalues[f->nups].info = cast_byte(v->u.s.info);
7779return f->nups++;
7780}
7781
7782
7783static int searchvar (FuncState *fs, TString *n) {

Callers 1

singlevarauxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected