** Find a variable with the given name 'n'. If it is an upvalue, add ** this upvalue into all intermediate functions. If it is a global, set ** 'var' as 'void' as a flag. */
| 422 | ** 'var' as 'void' as a flag. |
| 423 | */ |
| 424 | static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { |
| 425 | if (fs == NULL) /* no more levels? */ |
| 426 | init_exp(var, VVOID, 0); /* default is global */ |
| 427 | else { |
| 428 | int v = searchvar(fs, n, var); /* look up locals at current level */ |
| 429 | if (v >= 0) { /* found? */ |
| 430 | if (v == VLOCAL && !base) |
| 431 | markupval(fs, var->u.var.vidx); /* local will be used as an upval */ |
| 432 | } |
| 433 | else { /* not found as local at current level; try upvalues */ |
| 434 | int idx = searchupvalue(fs, n); /* try existing upvalues */ |
| 435 | if (idx < 0) { /* not found? */ |
| 436 | singlevaraux(fs->prev, n, var, 0); /* try upper levels */ |
| 437 | if (var->k == VLOCAL || var->k == VUPVAL) /* local or upvalue? */ |
| 438 | idx = newupvalue(fs, n, var); /* will be a new upvalue */ |
| 439 | else /* it is a global or a constant */ |
| 440 | return; /* don't need to do anything at this level */ |
| 441 | } |
| 442 | init_exp(var, VUPVAL, idx); /* new or old upvalue */ |
| 443 | } |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | |
| 448 | /* |
no test coverage detected