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

Function singlevaraux

third-party/lua-5.4.6/src/lparser.c:435–456  ·  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

433** 'var' as 'void' as a flag.
434*/
435static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
436 if (fs == NULL) /* no more levels? */
437 init_exp(var, VVOID, 0); /* default is global */
438 else {
439 int v = searchvar(fs, n, var); /* look up locals at current level */
440 if (v >= 0) { /* found? */
441 if (v == VLOCAL && !base)
442 markupval(fs, var->u.var.vidx); /* local will be used as an upval */
443 }
444 else { /* not found as local at current level; try upvalues */
445 int idx = searchupvalue(fs, n); /* try existing upvalues */
446 if (idx < 0) { /* not found? */
447 singlevaraux(fs->prev, n, var, 0); /* try upper levels */
448 if (var->k == VLOCAL || var->k == VUPVAL) /* local or upvalue? */
449 idx = newupvalue(fs, n, var); /* will be a new upvalue */
450 else /* it is a global or a constant */
451 return; /* don't need to do anything at this level */
452 }
453 init_exp(var, VUPVAL, idx); /* new or old upvalue */
454 }
455 }
456}
457
458
459/*

Callers 1

singlevarFunction · 0.70

Calls 5

init_expFunction · 0.70
searchvarFunction · 0.70
markupvalFunction · 0.70
searchupvalueFunction · 0.70
newupvalueFunction · 0.70

Tested by

no test coverage detected