@@ -284,7 +284,7 @@ impl CodeInfo {
284284 for info in & mut block. instructions {
285285 let target = info. target ;
286286 if target != BlockIdx :: NULL {
287- let new_arg = OpArg ( block_to_offset[ target. idx ( ) ] . 0 ) ;
287+ let new_arg = OpArg :: new ( block_to_offset[ target. idx ( ) ] . 0 ) ;
288288 recompile_extended_arg |= new_arg. instr_size ( ) != info. arg . instr_size ( ) ;
289289 info. arg = new_arg;
290290 }
@@ -443,7 +443,7 @@ impl CodeInfo {
443443 continue ;
444444 } ;
445445
446- let tuple_size = instr. arg . 0 as usize ;
446+ let tuple_size = u32 :: from ( instr. arg ) as usize ;
447447 if tuple_size == 0 || i < tuple_size {
448448 i += 1 ;
449449 continue ;
@@ -458,7 +458,7 @@ impl CodeInfo {
458458 let load_instr = & block. instructions [ j] ;
459459 match load_instr. instr . real ( ) {
460460 Some ( Instruction :: LoadConst { .. } ) => {
461- let const_idx = load_instr. arg . 0 as usize ;
461+ let const_idx = u32 :: from ( load_instr. arg ) as usize ;
462462 if let Some ( constant) =
463463 self . metadata . consts . get_index ( const_idx) . cloned ( )
464464 {
@@ -470,7 +470,7 @@ impl CodeInfo {
470470 }
471471 Some ( Instruction :: LoadSmallInt { .. } ) => {
472472 // arg is the i32 value stored as u32 (two's complement)
473- let value = load_instr. arg . 0 as i32 ;
473+ let value = u32 :: from ( load_instr. arg ) as i32 ;
474474 elements. push ( ConstantData :: Integer {
475475 value : BigInt :: from ( value) ,
476476 } ) ;
@@ -502,7 +502,7 @@ impl CodeInfo {
502502
503503 // Replace BUILD_TUPLE with LOAD_CONST
504504 block. instructions [ i] . instr = Instruction :: LoadConst { idx : Arg :: marker ( ) } . into ( ) ;
505- block. instructions [ i] . arg = OpArg ( const_idx as u32 ) ;
505+ block. instructions [ i] . arg = OpArg :: new ( const_idx as u32 ) ;
506506
507507 i += 1 ;
508508 }
@@ -529,27 +529,27 @@ impl CodeInfo {
529529 match ( curr_instr, next_instr) {
530530 // LoadFast + LoadFast -> LoadFastLoadFast (if both indices < 16)
531531 ( Instruction :: LoadFast ( _) , Instruction :: LoadFast ( _) ) => {
532- let idx1 = curr. arg . 0 ;
533- let idx2 = next. arg . 0 ;
532+ let idx1 = u32 :: from ( curr. arg ) ;
533+ let idx2 = u32 :: from ( next. arg ) ;
534534 if idx1 < 16 && idx2 < 16 {
535535 let packed = ( idx1 << 4 ) | idx2;
536536 Some ( (
537537 Instruction :: LoadFastLoadFast { arg : Arg :: marker ( ) } ,
538- OpArg ( packed) ,
538+ OpArg :: new ( packed) ,
539539 ) )
540540 } else {
541541 None
542542 }
543543 }
544544 // StoreFast + StoreFast -> StoreFastStoreFast (if both indices < 16)
545545 ( Instruction :: StoreFast ( _) , Instruction :: StoreFast ( _) ) => {
546- let idx1 = curr. arg . 0 ;
547- let idx2 = next. arg . 0 ;
546+ let idx1 = u32 :: from ( curr. arg ) ;
547+ let idx2 = u32 :: from ( next. arg ) ;
548548 if idx1 < 16 && idx2 < 16 {
549549 let packed = ( idx1 << 4 ) | idx2;
550550 Some ( (
551551 Instruction :: StoreFastStoreFast { arg : Arg :: marker ( ) } ,
552- OpArg ( packed) ,
552+ OpArg :: new ( packed) ,
553553 ) )
554554 } else {
555555 None
@@ -584,7 +584,7 @@ impl CodeInfo {
584584 } ;
585585
586586 // Get the constant value
587- let const_idx = instr. arg . 0 as usize ;
587+ let const_idx = u32 :: from ( instr. arg ) as usize ;
588588 let Some ( constant) = self . metadata . consts . get_index ( const_idx) else {
589589 continue ;
590590 } ;
@@ -599,7 +599,7 @@ impl CodeInfo {
599599 // Convert LOAD_CONST to LOAD_SMALL_INT
600600 instr. instr = Instruction :: LoadSmallInt { idx : Arg :: marker ( ) } . into ( ) ;
601601 // The arg is the i32 value stored as u32 (two's complement)
602- instr. arg = OpArg ( small as u32 ) ;
602+ instr. arg = OpArg :: new ( small as u32 ) ;
603603 }
604604 }
605605 }
@@ -621,7 +621,7 @@ impl CodeInfo {
621621 for block in & self . blocks {
622622 for instr in & block. instructions {
623623 if let Some ( Instruction :: LoadConst { .. } ) = instr. instr . real ( ) {
624- let idx = instr. arg . 0 as usize ;
624+ let idx = u32 :: from ( instr. arg ) as usize ;
625625 if idx < nconsts {
626626 used[ idx] = true ;
627627 }
@@ -658,9 +658,9 @@ impl CodeInfo {
658658 for block in & mut self . blocks {
659659 for instr in & mut block. instructions {
660660 if let Some ( Instruction :: LoadConst { .. } ) = instr. instr . real ( ) {
661- let old_idx = instr. arg . 0 as usize ;
661+ let old_idx = u32 :: from ( instr. arg ) as usize ;
662662 if old_idx < nconsts {
663- instr. arg = OpArg ( old_to_new[ old_idx] as u32 ) ;
663+ instr. arg = OpArg :: new ( old_to_new[ old_idx] as u32 ) ;
664664 }
665665 }
666666 }
@@ -801,7 +801,7 @@ impl CodeInfo {
801801 let display_arg = if ins. target == BlockIdx :: NULL {
802802 ins. arg
803803 } else {
804- OpArg ( ins. target . 0 )
804+ OpArg :: new ( ins. target . 0 )
805805 } ;
806806 let instr_display = instr. display ( display_arg, self ) ;
807807 eprint ! ( "{instr_display}: {depth} {effect:+} => " ) ;
@@ -1253,10 +1253,10 @@ pub(crate) fn label_exception_targets(blocks: &mut [Block]) {
12531253 const RESUME_OPARG_LOCATION_MASK : u32 = 0x3 ;
12541254 const RESUME_OPARG_DEPTH1_MASK : u32 = 0x4 ;
12551255
1256- if ( arg. 0 & RESUME_OPARG_LOCATION_MASK ) != RESUME_AT_FUNC_START {
1256+ if ( u32 :: from ( arg) & RESUME_OPARG_LOCATION_MASK ) != RESUME_AT_FUNC_START {
12571257 if last_yield_except_depth == 1 {
12581258 blocks[ bi] . instructions [ i] . arg =
1259- OpArg ( arg. 0 | RESUME_OPARG_DEPTH1_MASK ) ;
1259+ OpArg :: new ( u32 :: from ( arg) | RESUME_OPARG_DEPTH1_MASK ) ;
12601260 }
12611261 last_yield_except_depth = -1 ;
12621262 }
@@ -1311,7 +1311,7 @@ pub(crate) fn convert_pseudo_ops(blocks: &mut [Block], varnames_len: u32) {
13111311 // LOAD_CLOSURE → LOAD_FAST (with varnames offset)
13121312 PseudoInstruction :: LoadClosure ( idx) => {
13131313 let new_idx = varnames_len + idx. get ( info. arg ) ;
1314- info. arg = OpArg ( new_idx) ;
1314+ info. arg = OpArg :: new ( new_idx) ;
13151315 info. instr = Instruction :: LoadFast ( Arg :: marker ( ) ) . into ( ) ;
13161316 }
13171317 // Jump pseudo ops are resolved during block linearization
0 commit comments