** Find a variable with the given name 'n', handling global variables ** too. */
| 518 | ** too. |
| 519 | */ |
| 520 | static void buildvar (LexState *ls, TString *varname, expdesc *var) { |
| 521 | FuncState *fs = ls->fs; |
| 522 | init_exp(var, VGLOBAL, -1); /* global by default */ |
| 523 | singlevaraux(fs, varname, var, 1); |
| 524 | if (var->k == VGLOBAL) { /* global name? */ |
| 525 | int info = var->u.info; |
| 526 | /* global by default in the scope of a global declaration? */ |
| 527 | if (info == -2) |
| 528 | luaK_semerror(ls, "variable '%s' not declared", getstr(varname)); |
| 529 | buildglobal(ls, varname, var); |
| 530 | if (info != -1 && ls->dyd->actvar.arr[info].vd.kind == GDKCONST) |
| 531 | var->u.ind.ro = 1; /* mark variable as read-only */ |
| 532 | else /* anyway must be a global */ |
| 533 | lua_assert(info == -1 || ls->dyd->actvar.arr[info].vd.kind == GDKREG); |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | |
| 538 | static void singlevar (LexState *ls, expdesc *var) { |
no test coverage detected