MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / singlevaraux

Function singlevaraux

deps/lua/src/lparser.c:224–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222
223
224static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
225 if (fs == NULL) { /* no more levels? */
226 init_exp(var, VGLOBAL, NO_REG); /* default is global variable */
227 return VGLOBAL;
228 }
229 else {
230 int v = searchvar(fs, n); /* look up at current level */
231 if (v >= 0) {
232 init_exp(var, VLOCAL, v);
233 if (!base)
234 markupval(fs, v); /* local will be used as an upval */
235 return VLOCAL;
236 }
237 else { /* not found at current level; try upper one */
238 if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL)
239 return VGLOBAL;
240 var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */
241 var->k = VUPVAL; /* upvalue in this level */
242 return VUPVAL;
243 }
244 }
245}
246
247
248static 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