| 14965 | |
| 14966 | |
| 14967 | void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { |
| 14968 | int loop; |
| 14969 | for (loop = 0; loop < MAXTAGLOOP; loop++) { |
| 14970 | const TValue *tm; |
| 14971 | if (ttistable(t)) { /* `t' is a table? */ |
| 14972 | Table *h = hvalue(t); |
| 14973 | TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ |
| 14974 | if (!ttisnil(oldval) || /* result is no nil? */ |
| 14975 | (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ |
| 14976 | setobj2t(L, oldval, val); |
| 14977 | luaC_barriert(L, h, val); |
| 14978 | return; |
| 14979 | } |
| 14980 | /* else will try the tag method */ |
| 14981 | } |
| 14982 | else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) |
| 14983 | luaG_typeerror(L, t, "index"); |
| 14984 | if (ttisfunction(tm)) { |
| 14985 | callTM(L, tm, t, key, val); |
| 14986 | return; |
| 14987 | } |
| 14988 | t = tm; /* else repeat with `tm' */ |
| 14989 | } |
| 14990 | luaG_runerror(L, "loop in settable"); |
| 14991 | } |
| 14992 | |
| 14993 | |
| 14994 | static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, |
no test coverage detected