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}
30
31impl crate::prettier::PrettyPrint for DebugOptions {
32    fn render(&self) -> crate::prettier::Document {
33        crate::prettier::display(self)
34    }
35}
36
37impl fmt::Display for DebugOptions {
38    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
39        match self {
40            Self::StackAll => write!(f, "stack"),
41            Self::StackTop(n) => write!(f, "stack.{n}"),
42            Self::MemAll => write!(f, "mem"),
43            Self::MemInterval(n, m) => write!(f, "mem.{n}.{m}"),
44            Self::LocalInterval(start, end, _) => {
45                write!(f, "local.{start}.{end}")
46            },
47        }
48    }
49}