use fuel_tx::Transaction;
use super::Interpreter;
use crate::consts::*;
use crate::context::Context;
use crate::prelude::*;
use crate::state::Debugger;
#[cfg(feature = "profile-any")]
use crate::profiler::{ProfileReceiver, Profiler};
impl<S> Interpreter<S> {
pub fn with_storage(storage: S) -> Self {
Self {
registers: [0; VM_REGISTER_COUNT],
memory: vec![0; VM_MAX_RAM as usize],
frames: vec![],
receipts: vec![],
tx: Transaction::default(),
storage,
debugger: Debugger::default(),
context: Context::default(),
block_height: 0,
#[cfg(feature = "profile-any")]
profiler: Profiler::default(),
}
}
#[cfg(feature = "profile-any")]
pub fn with_profiling(mut self, receiver: Box<dyn ProfileReceiver>) -> Self {
self.profiler.set_receiver(receiver);
self
}
}
impl<S> Default for Interpreter<S>
where
S: Default,
{
fn default() -> Self {
Self::with_storage(Default::default())
}
}
impl Interpreter<()> {
pub fn without_storage() -> Self {
Self::default()
}
}
impl Interpreter<MemoryStorage> {
pub fn with_memory_storage() -> Self {
Self::default()
}
}