miden_core/operations/decorators/
debug.rs

1use core::fmt;
2
3// DEBUG OPTIONS
4// ================================================================================================
5
6/// Options of the `Debug` decorator.
7///
8/// These options define the debug info which gets printed out when the Debug decorator is
9/// executed.
10#[derive(Copy, Clone, Debug, Eq, PartialEq)]
11pub enum DebugOptions {
12    /// Print out the entire contents of the stack for the current execution context.
13    StackAll,
14    /// Prints out the top n items of the stack for the current context.
15    StackTop(u8),
16    /// Prints out the entire contents of RAM.
17    MemAll,
18    /// Prints out the contents of memory stored in the provided interval. Interval boundaries are
19    /// both inclusive.
20    ///
21    /// First parameter specifies the interval starting address, second -- the ending address.
22    MemInterval(u32, u32),
23    /// Prints out locals stored in the provided interval of the currently executing procedure.
24    /// Interval boundaries are both inclusive.
25    ///
26    /// First parameter specifies the starting address, second -- the ending address, and the third
27    /// specifies the overall number of locals.
28    LocalInterval(u16, u16, u16),
29    /// Prints out the top n items of the advice stack for the current context.
30    AdvStackTop(u16),
31}
32
33impl crate::prettier::PrettyPrint for DebugOptions {
34    fn render(&self) -> crate::prettier::Document {
35        crate::prettier::display(self)
36    }
37}
38
39impl fmt::Display for DebugOptions {
40    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41        match self {
42            Self::StackAll => write!(f, "stack"),
43            Self::StackTop(n) => write!(f, "stack.{n}"),
44            Self::MemAll => write!(f, "mem"),
45            Self::MemInterval(n, m) => write!(f, "mem.{n}.{m}"),
46            Self::LocalInterval(start, end, _) => {
47                write!(f, "local.{start}.{end}")
48            },
49            Self::AdvStackTop(n) => write!(f, "adv_stack.{n}"),
50        }
51    }
52}