| 2685 | } |
| 2686 | |
| 2687 | static int compat53_countlevels(lua_State *L) { |
| 2688 | lua_Debug ar; |
| 2689 | int li = 1, le = 1; |
| 2690 | /* find an upper bound */ |
| 2691 | while (lua_getstack(L, le, &ar)) { li = le; le *= 2; } |
| 2692 | /* do a binary search */ |
| 2693 | while (li < le) { |
| 2694 | int m = (li + le) / 2; |
| 2695 | if (lua_getstack(L, m, &ar)) li = m + 1; |
| 2696 | else le = m; |
| 2697 | } |
| 2698 | return le - 1; |
| 2699 | } |
| 2700 | |
| 2701 | static int compat53_findfield(lua_State *L, int objidx, int level) { |
| 2702 | if (level == 0 || !lua_istable(L, -1)) |
no test coverage detected