miden_assembly_syntax/ast/
advice_map_entry.rs

1use alloc::{string::String, vec::Vec};
2
3use miden_debug_types::{SourceSpan, Span};
4
5use super::DocString;
6use crate::{Felt, ast::Ident, parser::WordValue};
7
8// Advice Map data that the host populates before the VM starts.
9// ============================================================
10
11#[derive(Debug, PartialEq, Eq)]
12pub struct AdviceMapEntry {
13    /// The source span of the definition.
14    pub span: SourceSpan,
15    /// The documentation string attached to this definition.
16    pub docs: Option<DocString>,
17    /// The name of the constant.
18    pub name: Ident,
19    /// The key to insert in the Advice Map.
20    pub key: Option<Span<WordValue>>,
21    /// The value to insert in the Advice Map.
22    pub value: Vec<Felt>,
23}
24
25impl AdviceMapEntry {
26    pub fn new(
27        span: SourceSpan,
28        name: Ident,
29        key: Option<Span<WordValue>>,
30        value: Vec<Felt>,
31    ) -> Self {
32        Self { span, docs: None, name, key, value }
33    }
34
35    /// Adds documentation to this constant declaration.
36    pub fn with_docs(mut self, docs: Option<Span<String>>) -> Self {
37        self.docs = docs.map(DocString::new);
38        self
39    }
40}