Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#### Upcoming Changes

* dev: add Memory::get_maybe_relocatable [#2039](https://github.com/lambdaclass/cairo-vm/pull/2039)

* refactor: remove duplicated get_val function [#2065](https://github.com/lambdaclass/cairo-vm/pull/2065)

* fix: Always use a normal segment in first SegmentArena segment [#1845](https://github.com/lambdaclass/cairo-vm/pull/1845)
Expand Down
12 changes: 12 additions & 0 deletions vm/src/vm/vm_memory/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,18 @@ impl Memory {
}
}

/// Gets the value from memory address as a MaybeRelocatable value.
/// Returns an Error if the value at the memory address is missing or not a MaybeRelocatable.
pub fn get_maybe_relocatable(&self, key: Relocatable) -> Result<MaybeRelocatable, MemoryError> {
match self
.get(&key)
.ok_or_else(|| MemoryError::UnknownMemoryCell(Box::new(key)))?
{
Cow::Borrowed(maybe_rel) => Ok(maybe_rel.clone()),
Cow::Owned(maybe_rel) => Ok(maybe_rel),
}
}

/// Inserts a value into memory
/// Returns an error if the memory cell asignment is invalid
pub fn insert_value<T: Into<MaybeRelocatable>>(
Expand Down
Loading