MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / singlevaraux

Function singlevaraux

Source/Misc/lua/src/lua.c:7800–7821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7798
7799
7800static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {
7801if (fs == NULL) { /* no more levels? */
7802init_exp(var, VGLOBAL, NO_REG); /* default is global variable */
7803return VGLOBAL;
7804}
7805else {
7806int v = searchvar(fs, n); /* look up at current level */
7807if (v >= 0) {
7808init_exp(var, VLOCAL, v);
7809if (!base)
7810markupval(fs, v); /* local will be used as an upval */
7811return VLOCAL;
7812}
7813else { /* not found at current level; try upper one */
7814if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL)
7815return VGLOBAL;
7816var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */
7817var->k = VUPVAL; /* upvalue in this level */
7818return VUPVAL;
7819}
7820}
7821}
7822
7823
7824static 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