MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / singlevaraux

Function singlevaraux

lua/lparser.c:255–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253
254
255static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
256 if (fs == NULL) { /* no more levels? */
257 init_exp(var, VGLOBAL, NO_REG); /* default is global variable */
258 return VGLOBAL;
259 }
260 else {
261 int v = searchvar(fs, n); /* look up at current level */
262 if (v >= 0) {
263 init_exp(var, VLOCAL, v);
264 if (!base)
265 markupval(fs, v); /* local will be used as an upval */
266 return VLOCAL;
267 }
268 else { /* not found at current level; try upper one */
269 if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL)
270 return VGLOBAL;
271 var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */
272 var->k = VUPVAL; /* upvalue in this level */
273 return VUPVAL;
274 }
275 }
276}
277
278
279static void singlevar (LexState *ls, expdesc *var) {

Callers 1

singlevarFunction · 0.85

Calls 4

init_expFunction · 0.85
searchvarFunction · 0.85
markupvalFunction · 0.85
indexupvalueFunction · 0.85

Tested by

no test coverage detected