Skip to content

Commit

Permalink
refactor: add Library, Program with advice map constructors,
Browse files Browse the repository at this point in the history
`AdviceMap` from iterator constructor.
  • Loading branch information
greenhat committed Dec 18, 2024
1 parent ba40fe5 commit fedea27
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
11 changes: 10 additions & 1 deletion assembly/src/library/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use vm_core::{
debuginfo::Span,
mast::{MastForest, MastNodeId},
utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable},
Kernel,
AdviceMap, Kernel,
};

use crate::ast::{Ident, ProcedureName, QualifiedProcedureName};
Expand Down Expand Up @@ -92,6 +92,15 @@ impl Library {

Ok(Self { digest, exports, mast_forest })
}

pub fn with_advice_map(self, advice_map: AdviceMap) -> Self {
let mut mast_forest = (*self.mast_forest).clone();
mast_forest.advice_map_mut().extend(advice_map);
Self {
mast_forest: Arc::new(mast_forest),
..self
}
}
}

// ------------------------------------------------------------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions core/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use super::Kernel;
use crate::{
mast::{MastForest, MastNode, MastNodeId},
utils::ToElements,
AdviceMap,
};

// PROGRAM
Expand Down Expand Up @@ -53,6 +54,15 @@ impl Program {

Self { mast_forest, entrypoint, kernel }
}

pub fn with_advice_map(self, advice_map: AdviceMap) -> Self {
let mut mast_forest = (*self.mast_forest).clone();
mast_forest.advice_map_mut().extend(advice_map);
Self {
mast_forest: Arc::new(mast_forest),
..self
}
}
}

// ------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit fedea27

Please sign in to comment.