MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / newupvalue

Function newupvalue

third-party/lua-5.5.0/src/lparser.c:382–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380
381
382static int newupvalue (FuncState *fs, TString *name, expdesc *v) {
383 Upvaldesc *up = allocupvalue(fs);
384 FuncState *prev = fs->prev;
385 if (v->k == VLOCAL) {
386 up->instack = 1;
387 up->idx = v->u.var.ridx;
388 up->kind = getlocalvardesc(prev, v->u.var.vidx)->vd.kind;
389 lua_assert(eqstr(name, getlocalvardesc(prev, v->u.var.vidx)->vd.name));
390 }
391 else {
392 up->instack = 0;
393 up->idx = cast_byte(v->u.info);
394 up->kind = prev->f->upvalues[v->u.info].kind;
395 lua_assert(eqstr(name, prev->f->upvalues[v->u.info].name));
396 }
397 up->name = name;
398 luaC_objbarrier(fs->ls->L, fs->f, name);
399 return fs->nups - 1;
400}
401
402
403/*

Callers 1

singlevarauxFunction · 0.70

Calls 2

allocupvalueFunction · 0.70
getlocalvardescFunction · 0.70

Tested by

no test coverage detected