** Find a variable with the given name 'n', handling global variables ** too. */
| 461 | ** too. |
| 462 | */ |
| 463 | static void singlevar (LexState *ls, expdesc *var) { |
| 464 | TString *varname = str_checkname(ls); |
| 465 | FuncState *fs = ls->fs; |
| 466 | singlevaraux(fs, varname, var, 1); |
| 467 | if (var->k == VVOID) { /* global name? */ |
| 468 | expdesc key; |
| 469 | singlevaraux(fs, ls->envn, var, 1); /* get environment variable */ |
| 470 | lua_assert(var->k != VVOID); /* this one must exist */ |
| 471 | luaK_exp2anyregup(fs, var); /* but could be a constant */ |
| 472 | codestring(&key, varname); /* key is variable name */ |
| 473 | luaK_indexed(fs, var, &key); /* env[varname] */ |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | |
| 478 | /* |
no test coverage detected