MCPcopy Create free account
hub / github.com/F-Stack/f-stack / singlevaraux

Function singlevaraux

freebsd/contrib/openzfs/module/lua/lparser.c:269–292  ·  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

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

Callers 1

singlevarFunction · 0.70

Calls 5

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

Tested by

no test coverage detected