Skip to content

Commit 1ce5a52

Browse files
authored
feat(interpreter): expose mutable access methods on stack and memory (#1219)
* feat(interpreter): allow mutable stack access * feat(interpreter): allow mutable memory access * chore: inline
1 parent 09df19c commit 1ce5a52

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

crates/interpreter/src/interpreter/shared_memory.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl SharedMemory {
296296

297297
/// Returns a mutable reference to the memory of the current context.
298298
#[inline]
299-
fn context_memory_mut(&mut self) -> &mut [u8] {
299+
pub fn context_memory_mut(&mut self) -> &mut [u8] {
300300
let buf_len = self.buffer.len();
301301
// SAFETY: access bounded by buffer length
302302
unsafe { self.buffer.get_unchecked_mut(self.last_checkpoint..buf_len) }

crates/interpreter/src/interpreter/stack.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,19 @@ impl Stack {
5858
self.data.is_empty()
5959
}
6060

61-
/// Returns the underlying data of the stack.
61+
/// Returns a reference to the underlying data buffer.
6262
#[inline]
6363
pub fn data(&self) -> &Vec<U256> {
6464
&self.data
6565
}
6666

67-
/// Consumes the stack and returns the underlying data.
67+
/// Returns a mutable reference to the underlying data buffer.
68+
#[inline]
69+
pub fn data_mut(&mut self) -> &mut Vec<U256> {
70+
&mut self.data
71+
}
72+
73+
/// Consumes the stack and returns the underlying data buffer.
6874
#[inline]
6975
pub fn into_data(self) -> Vec<U256> {
7076
self.data

0 commit comments

Comments
 (0)