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

Function singlevaraux

third-party/lua-5.2.4/src/lparser.c:271–294  ·  view source on GitHub ↗

Find variable with given name 'n'. If it is an upvalue, add this upvalue into all intermediate functions. */

Source from the content-addressed store, hash-verified

269 upvalue into all intermediate functions.
270*/
271static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
272 if (fs == NULL) /* no more levels? */
273 return VVOID; /* default is global */
274 else {
275 int v = searchvar(fs, n); /* look up locals at current level */
276 if (v >= 0) { /* found? */
277 init_exp(var, VLOCAL, v); /* variable is local */
278 if (!base)
279 markupval(fs, v); /* local will be used as an upval */
280 return VLOCAL;
281 }
282 else { /* not found as local at current level; try upvalues */
283 int idx = searchupvalue(fs, n); /* try existing upvalues */
284 if (idx < 0) { /* not found? */
285 if (singlevaraux(fs->prev, n, var, 0) == VVOID) /* try upper levels */
286 return VVOID; /* not found; is a global */
287 /* else was LOCAL or UPVAL */
288 idx = newupvalue(fs, n, var); /* will be a new upvalue */
289 }
290 init_exp(var, VUPVAL, idx);
291 return VUPVAL;
292 }
293 }
294}
295
296
297static void singlevar (LexState *ls, expdesc *var) {

Callers 1

singlevarFunction · 0.70

Calls 5

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

Tested by

no test coverage detected