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

Function newupvalue

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

Source from the content-addressed store, hash-verified

362
363
364static int newupvalue (FuncState *fs, TString *name, expdesc *v) {
365 Upvaldesc *up = allocupvalue(fs);
366 FuncState *prev = fs->prev;
367 if (v->k == VLOCAL) {
368 up->instack = 1;
369 up->idx = v->u.var.ridx;
370 up->kind = getlocalvardesc(prev, v->u.var.vidx)->vd.kind;
371 lua_assert(eqstr(name, getlocalvardesc(prev, v->u.var.vidx)->vd.name));
372 }
373 else {
374 up->instack = 0;
375 up->idx = cast_byte(v->u.info);
376 up->kind = prev->f->upvalues[v->u.info].kind;
377 lua_assert(eqstr(name, prev->f->upvalues[v->u.info].name));
378 }
379 up->name = name;
380 luaC_objbarrier(fs->ls->L, fs->f, name);
381 return fs->nups - 1;
382}
383
384
385/*

Callers 1

singlevarauxFunction · 0.85

Calls 2

allocupvalueFunction · 0.85
getlocalvardescFunction · 0.85

Tested by

no test coverage detected