| 14939 | |
| 14940 | |
| 14941 | void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { |
| 14942 | int loop; |
| 14943 | for (loop = 0; loop < MAXTAGLOOP; loop++) { |
| 14944 | const TValue *tm; |
| 14945 | if (ttistable(t)) { /* `t' is a table? */ |
| 14946 | Table *h = hvalue(t); |
| 14947 | const TValue *res = luaH_get(h, key); /* do a primitive get */ |
| 14948 | if (!ttisnil(res) || /* result is no nil? */ |
| 14949 | (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ |
| 14950 | setobj2s(L, val, res); |
| 14951 | return; |
| 14952 | } |
| 14953 | /* else will try the tag method */ |
| 14954 | } |
| 14955 | else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) |
| 14956 | luaG_typeerror(L, t, "index"); |
| 14957 | if (ttisfunction(tm)) { |
| 14958 | callTMres(L, val, tm, t, key); |
| 14959 | return; |
| 14960 | } |
| 14961 | t = tm; /* else repeat with `tm' */ |
| 14962 | } |
| 14963 | luaG_runerror(L, "loop in gettable"); |
| 14964 | } |
| 14965 | |
| 14966 | |
| 14967 | void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { |
no test coverage detected