Skip to content

Commit 5e8a8c6

Browse files
committed
run context: function naming change
1 parent c7c5b80 commit 5e8a8c6

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

crates/leanVm/src/context/run_context.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl RunContext {
3636
///
3737
/// - If the operand is a constant, it returns the constant.
3838
/// - If it's a memory location, it computes the address relative to `fp` and fetches the value from memory.
39-
pub fn get_value<F>(
39+
pub fn get_value_from_mem_or_constant<F>(
4040
&self,
4141
operand: &MemOrConstant<F>,
4242
memory: &MemoryManager,
@@ -131,11 +131,13 @@ mod tests {
131131
// A constant operand with field element 42.
132132
let operand = MemOrConstant::Constant(F::from_u64(42));
133133

134-
// Run `get_value` with an unused memory manager (memory is not needed for constants).
134+
// Run `get_value_from_mem_or_constant` with an unused memory manager (memory is not needed for constants).
135135
let memory = MemoryManager::default();
136136

137137
// It should return the wrapped constant as a MemoryValue::Int.
138-
let result = ctx.get_value(&operand, &memory).unwrap();
138+
let result = ctx
139+
.get_value_from_mem_or_constant(&operand, &memory)
140+
.unwrap();
139141
assert_eq!(result, MemoryValue::Int(F::from_u64(42)));
140142
}
141143

@@ -171,8 +173,10 @@ mod tests {
171173
// The operand asks to read memory at fp + 2.
172174
let operand = MemOrConstant::MemoryAfterFp { shift: 2 };
173175

174-
// Call get_value, which should fetch the value we inserted.
175-
let result = ctx.get_value(&operand, &memory).unwrap();
176+
// Call get_value_from_mem_or_constant, which should fetch the value we inserted.
177+
let result = ctx
178+
.get_value_from_mem_or_constant(&operand, &memory)
179+
.unwrap();
176180
assert_eq!(result, expected_val);
177181
}
178182

@@ -197,8 +201,10 @@ mod tests {
197201
fp,
198202
);
199203

200-
// Calling get_value should return a VirtualMachineError::MemoryError::UninitializedMemory.
201-
let err = ctx.get_value(&operand, &memory).unwrap_err();
204+
// Calling get_value_from_mem_or_constant should return a VirtualMachineError::MemoryError::UninitializedMemory.
205+
let err = ctx
206+
.get_value_from_mem_or_constant(&operand, &memory)
207+
.unwrap_err();
202208

203209
match err {
204210
VirtualMachineError::Memory(MemoryError::UninitializedMemory(addr)) => {

crates/leanVm/src/core.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl VirtualMachine {
4343
// This will return an error if the memory location is uninitialized.
4444
let condition_val = self
4545
.run_context
46-
.get_value(condition, &self.memory_manager)?;
46+
.get_value_from_mem_or_constant(condition, &self.memory_manager)?;
4747

4848
// A jump condition must be a field element.
4949
let is_zero = condition_val.to_f()?.is_zero();
@@ -55,7 +55,9 @@ impl VirtualMachine {
5555
// **Condition is non-zero**: Execute the jump.
5656
//
5757
// First, resolve the `dest` operand to get the target address value.
58-
let dest_val = self.run_context.get_value(dest, &self.memory_manager)?;
58+
let dest_val = self
59+
.run_context
60+
.get_value_from_mem_or_constant(dest, &self.memory_manager)?;
5961

6062
// The resolved destination value must be a valid address.
6163
//

0 commit comments

Comments
 (0)