openvm_instructions/
exe.rsuse std::collections::BTreeMap;
use openvm_stark_backend::p3_field::Field;
use serde::{Deserialize, Serialize};
use crate::program::Program;
pub type MemoryImage<F> = BTreeMap<(u32, u32), F>;
pub type FnBounds = BTreeMap<u32, FnBound>;
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(bound(
serialize = "F: Serialize",
deserialize = "F: std::cmp::Ord + Deserialize<'de>"
))]
pub struct VmExe<F> {
pub program: Program<F>,
pub pc_start: u32,
pub init_memory: MemoryImage<F>,
pub fn_bounds: FnBounds,
}
impl<F> VmExe<F> {
pub fn new(program: Program<F>) -> Self {
Self {
program,
pc_start: 0,
init_memory: BTreeMap::new(),
fn_bounds: Default::default(),
}
}
pub fn with_pc_start(mut self, pc_start: u32) -> Self {
self.pc_start = pc_start;
self
}
pub fn with_init_memory(mut self, init_memory: MemoryImage<F>) -> Self {
self.init_memory = init_memory;
self
}
}
impl<F: Field> From<Program<F>> for VmExe<F> {
fn from(program: Program<F>) -> Self {
Self::new(program)
}
}
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct FnBound {
pub start: u32,
pub end: u32,
pub name: String,
}