1- use p3_field:: PrimeField64 ;
2-
31use crate :: {
42 bytecode:: operand:: { MemOrConstant , MemOrFp , MemOrFpOrConstant } ,
53 errors:: { memory:: MemoryError , vm:: VirtualMachineError } ,
@@ -36,14 +34,11 @@ impl RunContext {
3634 ///
3735 /// - If the operand is a constant, it returns the constant.
3836 /// - If it's a memory location, it computes the address relative to `fp` and fetches the value from memory.
39- pub fn value_from_mem_or_constant < F > (
37+ pub fn value_from_mem_or_constant (
4038 & self ,
41- operand : & MemOrConstant < F > ,
39+ operand : & MemOrConstant ,
4240 memory : & MemoryManager ,
43- ) -> Result < MemoryValue < F > , MemoryError < F > >
44- where
45- F : PrimeField64 ,
46- {
41+ ) -> Result < MemoryValue , MemoryError > {
4742 match operand {
4843 MemOrConstant :: Constant ( val) => Ok ( MemoryValue :: Int ( * val) ) ,
4944 MemOrConstant :: MemoryAfterFp { shift } => {
@@ -59,14 +54,11 @@ impl RunContext {
5954 ///
6055 /// - If the operand is the frame pointer `Fp`, it returns the `fp` address itself.
6156 /// - If it's a memory location, it computes the address relative to `fp` and fetches the value.
62- pub fn value_from_mem_or_fp < F > (
57+ pub fn value_from_mem_or_fp (
6358 & self ,
6459 operand : & MemOrFp ,
6560 memory : & MemoryManager ,
66- ) -> Result < MemoryValue < F > , MemoryError < F > >
67- where
68- F : PrimeField64 ,
69- {
61+ ) -> Result < MemoryValue , MemoryError > {
7062 match operand {
7163 MemOrFp :: Fp => Ok ( MemoryValue :: Address ( self . fp ) ) ,
7264 MemOrFp :: MemoryAfterFp { shift } => {
@@ -84,14 +76,11 @@ impl RunContext {
8476 /// - a constant value,
8577 /// - a memory location relative to `fp`,
8678 /// - the `fp` register itself.
87- pub fn value_from_mem_or_fp_or_constant < F > (
79+ pub fn value_from_mem_or_fp_or_constant (
8880 & self ,
89- operand : & MemOrFpOrConstant < F > ,
81+ operand : & MemOrFpOrConstant ,
9082 memory : & MemoryManager ,
91- ) -> Result < MemoryValue < F > , VirtualMachineError < F > >
92- where
93- F : PrimeField64 ,
94- {
83+ ) -> Result < MemoryValue , VirtualMachineError > {
9584 match operand {
9685 MemOrFpOrConstant :: Constant ( val) => Ok ( MemoryValue :: Int ( * val) ) ,
9786 MemOrFpOrConstant :: Fp => Ok ( MemoryValue :: Address ( self . fp ) ) ,
@@ -107,12 +96,10 @@ impl RunContext {
10796
10897#[ cfg( test) ]
10998mod tests {
110- use p3_baby_bear:: BabyBear ;
11199 use p3_field:: PrimeCharacteristicRing ;
112100
113101 use super :: * ;
114-
115- type F = BabyBear ;
102+ use crate :: constant:: F ;
116103
117104 #[ test]
118105 fn test_get_value_constant ( ) {
@@ -183,7 +170,7 @@ mod tests {
183170 // We won't insert anything, so all memory is uninitialized.
184171
185172 // Shift = 1 → fp + 1 points to offset 1 (which is uninitialized).
186- let operand: MemOrConstant < F > = MemOrConstant :: MemoryAfterFp { shift : 1 } ;
173+ let operand: MemOrConstant = MemOrConstant :: MemoryAfterFp { shift : 1 } ;
187174
188175 // Set up context.
189176 let ctx = RunContext :: new (
@@ -223,7 +210,7 @@ mod tests {
223210 fn test_get_value_from_mem_or_fp_or_constant_is_fp ( ) {
224211 let fp_addr = MemoryAddress :: new ( 1 , 10 ) ;
225212 let ctx = RunContext :: new ( MemoryAddress :: new ( 0 , 0 ) , fp_addr) ;
226- let operand = MemOrFpOrConstant :: < F > :: Fp ;
213+ let operand = MemOrFpOrConstant :: Fp ;
227214 let memory = MemoryManager :: default ( ) ;
228215 let result = ctx
229216 . value_from_mem_or_fp_or_constant ( & operand, & memory)
@@ -235,8 +222,8 @@ mod tests {
235222 fn test_get_value_from_mem_or_fp_or_constant_is_mem_success ( ) {
236223 let mut memory = MemoryManager :: default ( ) ;
237224 let fp = memory. add ( ) ;
238- let addr_to_read = fp. add_usize :: < F > ( 7 ) . unwrap ( ) ;
239- let expected_val = MemoryValue :: < F > :: Address ( MemoryAddress :: new ( 5 , 5 ) ) ;
225+ let addr_to_read = fp. add_usize ( 7 ) . unwrap ( ) ;
226+ let expected_val = MemoryValue :: Address ( MemoryAddress :: new ( 5 , 5 ) ) ;
240227 memory. memory . insert ( addr_to_read, expected_val) . unwrap ( ) ;
241228
242229 let ctx = RunContext :: new ( MemoryAddress :: new ( 0 , 0 ) , fp) ;
0 commit comments