| 3825 | } |
| 3826 | |
| 3827 | static int compat53_countlevels(lua_State* L) { |
| 3828 | lua_Debug ar; |
| 3829 | int li = 1, le = 1; |
| 3830 | /* find an upper bound */ |
| 3831 | while (lua_getstack(L, le, &ar)) { |
| 3832 | li = le; |
| 3833 | le *= 2; |
| 3834 | } |
| 3835 | /* do a binary search */ |
| 3836 | while (li < le) { |
| 3837 | int m = (li + le) / 2; |
| 3838 | if (lua_getstack(L, m, &ar)) |
| 3839 | li = m + 1; |
| 3840 | else |
| 3841 | le = m; |
| 3842 | } |
| 3843 | return le - 1; |
| 3844 | } |
| 3845 | |
| 3846 | static int compat53_findfield(lua_State* L, int objidx, int level) { |
| 3847 | if (level == 0 || !lua_istable(L, -1)) |
no test coverage detected