summaryrefslogtreecommitdiff
path: root/src/ffi/luau/compat.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2022-03-19 21:18:56 +0000
committerAlex Orlenko <zxteam@protonmail.com>2022-03-21 01:08:48 +0000
commit37cddc6b1c733547316b6767d67ac4239e91fe1e (patch)
tree8fc3e10d578831accc91c6cd6bebd7f176fbec61 /src/ffi/luau/compat.rs
parent2c069f703366f9479a3563827c77f9c4b2ccf546 (diff)
downloadmlua-37cddc6b1c733547316b6767d67ac4239e91fe1e.zip
Replace compat53_countlevels with lua_stackdepth for Luau
Diffstat (limited to 'src/ffi/luau/compat.rs')
-rw-r--r--src/ffi/luau/compat.rs22
1 files changed, 1 insertions, 21 deletions
diff --git a/src/ffi/luau/compat.rs b/src/ffi/luau/compat.rs
index db9c55c..26d3fd8 100644
--- a/src/ffi/luau/compat.rs
+++ b/src/ffi/luau/compat.rs
@@ -26,26 +26,6 @@ unsafe fn compat53_reverse(L: *mut lua_State, mut a: c_int, mut b: c_int) {
const COMPAT53_LEVELS1: c_int = 12; // size of the first part of the stack
const COMPAT53_LEVELS2: c_int = 10; // size of the second part of the stack
-unsafe fn compat53_countlevels(L: *mut lua_State) -> c_int {
- let mut ar: lua_Debug = mem::zeroed();
- let (mut li, mut le) = (1, 1);
- // find an upper bound
- while lua_getinfo(L, le, cstr!(""), &mut ar) != 0 {
- li = le;
- le *= 2;
- }
- // do a binary search
- while li < le {
- let m = (li + le) / 2;
- if lua_getinfo(L, m, cstr!(""), &mut ar) != 0 {
- li = m + 1;
- } else {
- le = m;
- }
- }
- le - 1
-}
-
unsafe fn compat53_findfield(L: *mut lua_State, objidx: c_int, level: c_int) -> c_int {
if level == 0 || lua_istable(L, -1) == 0 {
return 0; // not found
@@ -425,7 +405,7 @@ pub unsafe fn luaL_traceback(
) {
let mut ar: lua_Debug = mem::zeroed();
let top = lua_gettop(L);
- let numlevels = compat53_countlevels(L1);
+ let numlevels = lua_stackdepth(L);
let mark = if numlevels > COMPAT53_LEVELS1 + COMPAT53_LEVELS2 {
COMPAT53_LEVELS1
} else {