MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / singlevaraux

Function singlevaraux

src/Chain/libraries/glua/lparser.cpp:292–315  ·  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

290 upvalue into all intermediate functions.
291 */
292static int singlevaraux(FuncState *fs, TString *n, expdesc *var, int base) {
293 if (fs == nullptr) /* no more levels? */
294 return VVOID; /* default is global */
295 else {
296 int v = searchvar(fs, n); /* look up locals at current level */
297 if (v >= 0) { /* found? */
298 init_exp(var, VLOCAL, v); /* variable is local */
299 if (!base)
300 markupval(fs, v); /* local will be used as an upval */
301 return VLOCAL;
302 }
303 else { /* not found as local at current level; try upvalues */
304 int idx = searchupvalue(fs, n); /* try existing upvalues */
305 if (idx < 0) { /* not found? */
306 if (singlevaraux(fs->prev, n, var, 0) == VVOID) /* try upper levels */
307 return VVOID; /* not found; is a global */
308 /* else was LOCAL or UPVAL */
309 idx = newupvalue(fs, n, var); /* will be a new upvalue */
310 }
311 init_exp(var, VUPVAL, idx);
312 return VUPVAL;
313 }
314 }
315}
316
317
318static void singlevar(LexState *ls, expdesc *var) {

Callers 1

singlevarFunction · 0.85

Calls 5

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

Tested by

no test coverage detected