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

Function singlevaraux

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

** Find a variable with the given name 'n'. If it is an upvalue, add ** this upvalue into all intermediate functions. If it is a global, set ** 'var' as 'void' as a flag. */

Source from the content-addressed store, hash-verified

474** 'var' as 'void' as a flag.
475*/
476static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
477 int v = searchvar(fs, n, var); /* look up variables at current level */
478 if (v >= 0) { /* found? */
479 if (!base) {
480 if (var->k == VVARGVAR) /* vararg parameter? */
481 luaK_vapar2local(fs, var); /* change it to a regular local */
482 if (var->k == VLOCAL)
483 markupval(fs, var->u.var.vidx); /* will be used as an upvalue */
484 }
485 /* else nothing else to be done */
486 }
487 else { /* not found at current level; try upvalues */
488 int idx = searchupvalue(fs, n); /* try existing upvalues */
489 if (idx < 0) { /* not found? */
490 if (fs->prev != NULL) /* more levels? */
491 singlevaraux(fs->prev, n, var, 0); /* try upper levels */
492 if (var->k == VLOCAL || var->k == VUPVAL) /* local or upvalue? */
493 idx = newupvalue(fs, n, var); /* will be a new upvalue */
494 else /* it is a global or a constant */
495 return; /* don't need to do anything at this level */
496 }
497 init_exp(var, VUPVAL, idx); /* new or old upvalue */
498 }
499}
500
501
502static void buildglobal (LexState *ls, TString *varname, expdesc *var) {

Callers 2

buildglobalFunction · 0.70
buildvarFunction · 0.70

Calls 6

luaK_vapar2localFunction · 0.85
searchvarFunction · 0.70
markupvalFunction · 0.70
searchupvalueFunction · 0.70
newupvalueFunction · 0.70
init_expFunction · 0.70

Tested by

no test coverage detected