** Check whether table being indexed by instruction 'i' is the ** environment '_ENV'. If the table is an upvalue, get its name; ** otherwise, find some "name" for the table and check whether ** that name is the name of a local variable (and not, for instance, ** a string). Then check that, if there is a name, it is '_ENV'. */
| 556 | ** a string). Then check that, if there is a name, it is '_ENV'. |
| 557 | */ |
| 558 | static const char *isEnv (const Proto *p, int pc, Instruction i, int isup) { |
| 559 | int t = GETARG_B(i); /* table index */ |
| 560 | const char *name; /* name of indexed variable */ |
| 561 | if (isup) /* is 't' an upvalue? */ |
| 562 | name = upvalname(p, t); |
| 563 | else { /* 't' is a register */ |
| 564 | const char *what = basicgetobjname(p, &pc, t, &name); |
| 565 | if (what != strlocal && what != strupval) |
| 566 | name = NULL; /* cannot be the variable _ENV */ |
| 567 | } |
| 568 | return (name && strcmp(name, LUA_ENV) == 0) ? "global" : "field"; |
| 569 | } |
| 570 | |
| 571 | |
| 572 | /* |
no test coverage detected