@@ -5,7 +5,7 @@ use crate::{
55 BorrowedConstant , Constant , InstrDisplayContext ,
66 oparg:: {
77 BinaryOperator , BuildSliceArgCount , CommonConstant , ComparisonOperator ,
8- ConvertValueOparg , IntrinsicFunction1 , IntrinsicFunction2 , Invert , Label ,
8+ ConvertValueOparg , IntrinsicFunction1 , IntrinsicFunction2 , Invert , Label , LoadAttr ,
99 LoadSuperAttr , MakeFunctionFlags , NameIdx , OpArg , OpArgByte , OpArgType , RaiseKind ,
1010 SpecialMethod , UnpackExArgs ,
1111 } ,
@@ -168,7 +168,7 @@ pub enum Instruction {
168168 i : Arg < u32 > ,
169169 } = 79 ,
170170 LoadAttr {
171- idx : Arg < NameIdx > ,
171+ idx : Arg < LoadAttr > ,
172172 } = 80 ,
173173 LoadCommonConstant {
174174 idx : Arg < CommonConstant > ,
@@ -815,17 +815,17 @@ impl InstructionMetadata for Instruction {
815815 Self :: ListAppend { i } => w ! ( LIST_APPEND , i) ,
816816 Self :: ListExtend { i } => w ! ( LIST_EXTEND , i) ,
817817 Self :: LoadAttr { idx } => {
818- let encoded = idx. get ( arg) ;
819- let ( name_idx , is_method ) = decode_load_attr_arg ( encoded ) ;
820- let attr_name = name ( name_idx) ;
821- if is_method {
818+ let oparg = idx. get ( arg) ;
819+ let oparg_u32 = u32 :: from ( oparg ) ;
820+ let attr_name = name ( oparg . name_idx ( ) ) ;
821+ if oparg . is_method ( ) {
822822 write ! (
823823 f,
824824 "{:pad$}({}, {}, method=true)" ,
825- "LOAD_ATTR" , encoded , attr_name
825+ "LOAD_ATTR" , oparg_u32 , attr_name
826826 )
827827 } else {
828- write ! ( f, "{:pad$}({}, {})" , "LOAD_ATTR" , encoded , attr_name)
828+ write ! ( f, "{:pad$}({}, {})" , "LOAD_ATTR" , oparg_u32 , attr_name)
829829 }
830830 }
831831 Self :: LoadBuildClass => w ! ( LOAD_BUILD_CLASS ) ,
@@ -1292,17 +1292,3 @@ impl<T: OpArgType> fmt::Debug for Arg<T> {
12921292 write ! ( f, "Arg<{}>" , core:: any:: type_name:: <T >( ) )
12931293 }
12941294}
1295-
1296- /// Encode LOAD_ATTR oparg: bit 0 = method flag, bits 1+ = name index.
1297- #[ inline]
1298- pub const fn encode_load_attr_arg ( name_idx : u32 , is_method : bool ) -> u32 {
1299- ( name_idx << 1 ) | ( is_method as u32 )
1300- }
1301-
1302- /// Decode LOAD_ATTR oparg: returns (name_idx, is_method).
1303- #[ inline]
1304- pub const fn decode_load_attr_arg ( oparg : u32 ) -> ( u32 , bool ) {
1305- let is_method = ( oparg & 1 ) == 1 ;
1306- let name_idx = oparg >> 1 ;
1307- ( name_idx, is_method)
1308- }
0 commit comments