diff --git a/src/protocol/eval/value.rs b/src/protocol/eval/value.rs index 6d6a618e386fa47a56189146f6ebd208a4608d7f..00d546ed6bc96ec19ea274d58225d0ea273773cf 100644 --- a/src/protocol/eval/value.rs +++ b/src/protocol/eval/value.rs @@ -1,3 +1,4 @@ +use std::collections::VecDeque; use super::store::*; use crate::PortId; @@ -160,7 +161,7 @@ impl Value { /// /// Again: this is a temporary thing, hopefully removed once we move to a /// bytecode interpreter. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct ValueGroup { pub(crate) values: Vec, pub(crate) regions: Vec> @@ -230,6 +231,17 @@ impl ValueGroup { } } + /// Transfers the heap values into the store, but will put the stack values + /// into the provided `VecDeque`. This is mainly used to merge `ValueGroup` + /// instances retrieved by the code by `get` calls into the expression + /// stack. + pub(crate) fn into_stack(self, stack: &mut VecDeque, store: &mut Store) { + for value in &self.values { + let transferred = self.provide_value(value, store); + stack.push_back(transferred); + } + } + fn provide_value(&self, value: &Value, to_store: &mut Store) -> Value { if let Some(from_heap_pos) = value.get_heap_pos() { let from_heap_pos = from_heap_pos as usize;