44use crate :: compiler:: format_source;
55use crate :: lib_registry:: LibraryModule ;
66use crate :: lua_value:: { LuaProto , LuaValue } ;
7+ use crate :: lua_vm:: call_info:: call_status;
78use crate :: lua_vm:: opcode:: OpCode ;
8- use crate :: lua_vm:: { LuaError , LuaResult , LuaState , get_metatable} ;
9- use crate :: { Instruction , LUA_MASKCALL , LUA_MASKLINE , LUA_MASKRET } ;
9+ use crate :: lua_vm:: { LuaError , LuaResult , LuaState , TmKind , get_metatable} ;
10+ use crate :: { Instruction , LUA_MASKCALL , LUA_MASKCOUNT , LUA_MASKLINE , LUA_MASKRET , lib_module } ;
1011
1112/// Get the type name of an object, checking __name in metatable first.
1213/// Mirrors C Lua's luaT_objtypename.
@@ -315,7 +316,6 @@ fn funcnamefromcode(chunk: &LuaProto, pc: usize) -> Option<(&'static str, String
315316 Some ( ( "metamethod" , "newindex" . to_string ( ) ) )
316317 }
317318 OpCode :: MmBin | OpCode :: MmBinI | OpCode :: MmBinK => {
318- use crate :: lua_vm:: TmKind ;
319319 let tm = TmKind :: from_u8 ( i. get_c ( ) as u8 ) ;
320320 let name: & str = tm. name ( ) ;
321321 Some ( ( "metamethod" , name[ 2 ..] . to_string ( ) ) )
@@ -347,7 +347,7 @@ fn getfuncname(l: &LuaState, ci_frame_idx: usize) -> Option<(&'static str, Strin
347347 // Look at the immediately previous frame (the caller)
348348 let prev_idx = ci_frame_idx - 1 ;
349349 let prev = l. get_frame ( prev_idx) ?;
350- if prev. call_status & crate :: lua_vm :: call_info :: call_status:: CIST_HOOKED != 0 {
350+ if prev. call_status & call_status:: CIST_HOOKED != 0 {
351351 return Some ( ( "hook" , "?" . to_string ( ) ) ) ;
352352 }
353353 if prev. is_lua ( ) {
@@ -672,7 +672,7 @@ pub fn opinterror(
672672}
673673
674674/// Generate a comparison error (mirrors luaG_ordererror).
675- pub fn ordererror ( l : & mut LuaState , p1 : & crate :: LuaValue , p2 : & crate :: LuaValue ) -> LuaError {
675+ pub fn ordererror ( l : & mut LuaState , p1 : & LuaValue , p2 : & LuaValue ) -> LuaError {
676676 let t1 = objtypename ( l, p1) ;
677677 let t2 = objtypename ( l, p2) ;
678678 if t1 == t2 {
@@ -684,7 +684,7 @@ pub fn ordererror(l: &mut LuaState, p1: &crate::LuaValue, p2: &crate::LuaValue)
684684
685685/// Generate a call error with function name info (mirrors luaG_callerror).
686686/// Used when attempting to call a non-callable value.
687- pub fn callerror ( l : & mut LuaState , val : & crate :: LuaValue ) -> LuaError {
687+ pub fn callerror ( l : & mut LuaState , val : & LuaValue ) -> LuaError {
688688 // Look at the current frame's instruction to determine what was being called
689689 let ci_idx = l. call_depth ( ) . wrapping_sub ( 1 ) ;
690690 if let Some ( ci) = l. get_frame ( ci_idx)
@@ -714,7 +714,7 @@ pub fn pub_getfuncname(l: &LuaState, ci_frame_idx: usize) -> Option<(&'static st
714714}
715715
716716pub fn create_debug_lib ( ) -> LibraryModule {
717- let mut module = crate :: lib_module!( "debug" , {
717+ let mut module = lib_module ! ( "debug" , {
718718 "traceback" => debug_traceback,
719719 "getinfo" => debug_getinfo,
720720 "getmetatable" => debug_getmetatable,
@@ -1203,9 +1203,9 @@ fn debug_sethook(l: &mut LuaState) -> LuaResult<usize> {
12031203 {
12041204 for ch in s. chars ( ) {
12051205 match ch {
1206- 'c' => mask |= crate :: lua_vm :: LUA_MASKCALL ,
1207- 'r' => mask |= crate :: lua_vm :: LUA_MASKRET ,
1208- 'l' => mask |= crate :: lua_vm :: LUA_MASKLINE ,
1206+ 'c' => mask |= LUA_MASKCALL ,
1207+ 'r' => mask |= LUA_MASKRET ,
1208+ 'l' => mask |= LUA_MASKLINE ,
12091209 _ => { } // ignore unknown characters
12101210 }
12111211 }
@@ -1214,7 +1214,7 @@ fn debug_sethook(l: &mut LuaState) -> LuaResult<usize> {
12141214 // Parse count
12151215 let count = count_val. and_then ( |v| v. as_integer ( ) ) . unwrap_or ( 0 ) as i32 ;
12161216 if count > 0 {
1217- mask |= crate :: lua_vm :: LUA_MASKCOUNT ;
1217+ mask |= LUA_MASKCOUNT ;
12181218 }
12191219
12201220 // If hook is nil, clear everything
0 commit comments