@@ -64,7 +64,7 @@ impl<PERM16, PERM24> VirtualMachine<PERM16, PERM24> {
6464
6565 if is_zero {
6666 // **Condition is zero**: The jump is not taken. Advance the `pc` by one.
67- self . run_context . pc ( ) . add_usize ( 1 ) ?
67+ ( * self . run_context . pc ( ) + 1 ) ?
6868 } else {
6969 // **Condition is non-zero**: Execute the jump.
7070 //
@@ -80,7 +80,7 @@ impl<PERM16, PERM24> VirtualMachine<PERM16, PERM24> {
8080 }
8181 } else {
8282 // For any instruction other than `JumpIfNotZero`, advance the `pc` by one.
83- self . run_context . pc ( ) . add_usize ( 1 ) ?
83+ ( * self . run_context . pc ( ) + 1 ) ?
8484 } ;
8585
8686 // Update the virtual machine's program counter with the calculated next address.
@@ -99,7 +99,7 @@ impl<PERM16, PERM24> VirtualMachine<PERM16, PERM24> {
9999 MemOrFp :: Fp => self . run_context . fp ,
100100 // The instruction specifies updating `fp` to a value from memory.
101101 MemOrFp :: MemoryAfterFp { shift } => {
102- let addr = self . run_context . fp ( ) . add_usize ( * shift) ?;
102+ let addr = ( * self . run_context . fp ( ) + * shift) ?;
103103 let value = self
104104 . memory_manager
105105 . get ( addr)
@@ -272,7 +272,7 @@ impl<PERM16, PERM24> VirtualMachine<PERM16, PERM24> {
272272 . value_from_mem_or_fp_or_constant ( res, & self . memory_manager ) ?;
273273
274274 // Calculate the address of the first-level pointer, `fp + shift_0`.
275- let ptr_shift_0_addr = self . run_context . fp . add_usize ( shift_0) ?;
275+ let ptr_shift_0_addr = ( self . run_context . fp + shift_0) ?;
276276
277277 // Read the pointer from memory. It must be a `MemoryAddress` type.
278278 let ptr: MemoryAddress = self
@@ -282,7 +282,7 @@ impl<PERM16, PERM24> VirtualMachine<PERM16, PERM24> {
282282 . try_into ( ) ?;
283283
284284 // Calculate the final, second-level address: `ptr + shift_1`.
285- let ptr_shift_1_addr = ptr . add_usize ( shift_1) ?;
285+ let ptr_shift_1_addr = ( ptr + shift_1) ?;
286286
287287 // Branch execution based on whether `res` was a known value or an unwritten address.
288288 match res_lookup_result {
@@ -326,7 +326,7 @@ impl<PERM16, PERM24> VirtualMachine<PERM16, PERM24> {
326326 // Read Pointers from Memory
327327 //
328328 // The instruction specifies 4 consecutive pointers starting at `fp + shift`.
329- let base_ptr_addr = self . run_context . fp . add_usize ( shift) ?;
329+ let base_ptr_addr = ( self . run_context . fp + shift) ?;
330330 let ptrs: [ MemoryValue ; 4 ] = self . memory_manager . get_array ( base_ptr_addr) ?;
331331
332332 // Convert the `MemoryValue` pointers to `MemoryAddress`.
@@ -452,11 +452,7 @@ mod tests {
452452 let pc = MemoryAddress :: new ( 0 , 10 ) ;
453453 let fp = MemoryAddress :: new ( 1 , 5 ) ;
454454 // Pre-load memory with a zero value at the address `fp + 1`, which will be our condition.
455- let mut vm = setup_vm (
456- pc,
457- fp,
458- & [ ( fp. add_usize ( 1 ) . unwrap ( ) , MemoryValue :: Int ( F :: ZERO ) ) ] ,
459- ) ;
455+ let mut vm = setup_vm ( pc, fp, & [ ( ( fp + 1 ) . unwrap ( ) , MemoryValue :: Int ( F :: ZERO ) ) ] ) ;
460456 // Define a JNZ instruction where the condition points to the zero value.
461457 let instruction = Instruction :: JumpIfNotZero {
462458 condition : MemOrConstant :: MemoryAfterFp { shift : 1 } ,
@@ -482,9 +478,9 @@ mod tests {
482478 fp,
483479 & [
484480 // The condition value (non-zero).
485- ( fp . add_usize ( 1 ) . unwrap ( ) , MemoryValue :: Int ( F :: from_u64 ( 42 ) ) ) ,
481+ ( ( fp + 1 ) . unwrap ( ) , MemoryValue :: Int ( F :: from_u64 ( 42 ) ) ) ,
486482 // The destination address for the jump.
487- ( fp . add_usize ( 2 ) . unwrap ( ) , MemoryValue :: Address ( jump_target) ) ,
483+ ( ( fp + 2 ) . unwrap ( ) , MemoryValue :: Address ( jump_target) ) ,
488484 ] ,
489485 ) ;
490486 // Define a JNZ instruction pointing to the condition and destination.
@@ -509,7 +505,7 @@ mod tests {
509505 pc,
510506 fp,
511507 & [ (
512- fp . add_usize ( 1 ) . unwrap ( ) ,
508+ ( fp + 1 ) . unwrap ( ) ,
513509 MemoryValue :: Address ( MemoryAddress :: new ( 8 , 8 ) ) ,
514510 ) ] ,
515511 ) ;
@@ -554,7 +550,7 @@ mod tests {
554550 let mut vm = setup_vm (
555551 MemoryAddress :: new ( 0 , 0 ) ,
556552 fp,
557- & [ ( fp . add_usize ( 3 ) . unwrap ( ) , MemoryValue :: Address ( new_fp) ) ] ,
553+ & [ ( ( fp + 3 ) . unwrap ( ) , MemoryValue :: Address ( new_fp) ) ] ,
558554 ) ;
559555 // Define a JNZ instruction where `updated_fp` points to the new address in memory.
560556 let instruction = Instruction :: JumpIfNotZero {
@@ -576,7 +572,7 @@ mod tests {
576572 let mut vm = setup_vm (
577573 MemoryAddress :: new ( 0 , 0 ) ,
578574 fp,
579- & [ ( fp . add_usize ( 3 ) . unwrap ( ) , MemoryValue :: Int ( F :: from_u64 ( 99 ) ) ) ] ,
575+ & [ ( ( fp + 3 ) . unwrap ( ) , MemoryValue :: Int ( F :: from_u64 ( 99 ) ) ) ] ,
580576 ) ;
581577 // Define a JNZ instruction where `updated_fp` points to this integer value.
582578 let instruction = Instruction :: JumpIfNotZero {
0 commit comments