openvm_instructions/
exe.rs1use std::collections::BTreeMap;
2
3use openvm_stark_backend::p3_field::Field;
4use serde::{Deserialize, Serialize};
5
6use crate::program::Program;
7
8pub type SparseMemoryImage = BTreeMap<(u32, u32), u8>;
11pub type FnBounds = BTreeMap<u32, FnBound>;
13
14#[derive(Clone, Debug, Default, Serialize, Deserialize)]
16#[serde(bound(
17 serialize = "F: Serialize",
18 deserialize = "F: std::cmp::Ord + Deserialize<'de>"
19))]
20pub struct VmExe<F> {
21 pub program: Program<F>,
23 pub pc_start: u32,
25 pub init_memory: SparseMemoryImage,
27 pub fn_bounds: FnBounds,
29}
30
31impl<F> VmExe<F> {
32 pub fn new(program: Program<F>) -> Self {
33 Self {
34 program,
35 pc_start: 0,
36 init_memory: BTreeMap::new(),
37 fn_bounds: Default::default(),
38 }
39 }
40 pub fn with_pc_start(mut self, pc_start: u32) -> Self {
41 self.pc_start = pc_start;
42 self
43 }
44 pub fn with_init_memory(mut self, init_memory: SparseMemoryImage) -> Self {
45 self.init_memory = init_memory;
46 self
47 }
48}
49
50impl<F: Field> From<Program<F>> for VmExe<F> {
51 fn from(program: Program<F>) -> Self {
52 Self::new(program)
53 }
54}
55
56#[derive(Debug, Default, Clone, Serialize, Deserialize)]
57pub struct FnBound {
58 pub start: u32,
59 pub end: u32,
60 pub name: String,
61}