miden_core/operations/decorators/
mod.rs1use alloc::{string::ToString, vec::Vec};
2use core::fmt;
3
4use miden_crypto::hash::blake::Blake3_256;
5use num_traits::ToBytes;
6#[cfg(feature = "serde")]
7use serde::{Deserialize, Serialize};
8
9mod assembly_op;
10pub use assembly_op::AssemblyOp;
11
12mod debug;
13pub use debug::DebugOptions;
14
15mod debug_var;
16pub use debug_var::{DebugVarInfo, DebugVarLocation};
17
18use crate::mast::{DecoratedOpLink, DecoratorFingerprint};
19
20#[derive(Clone, Debug, Eq, PartialEq)]
31#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
32#[cfg_attr(all(feature = "arbitrary", test), miden_test_serde_macros::serde_test)]
33pub enum Decorator {
34 Debug(DebugOptions),
37 Trace(u32),
39}
40
41impl Decorator {
42 pub fn fingerprint(&self) -> DecoratorFingerprint {
43 match self {
44 Self::Debug(debug) => Blake3_256::hash(debug.to_string().as_bytes()),
45 Self::Trace(trace) => Blake3_256::hash(&trace.to_le_bytes()),
46 }
47 }
48}
49
50impl crate::prettier::PrettyPrint for Decorator {
51 fn render(&self) -> crate::prettier::Document {
52 crate::prettier::display(self)
53 }
54}
55
56impl fmt::Display for Decorator {
57 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58 match self {
59 Self::Debug(options) => write!(f, "debug({options})"),
60 Self::Trace(trace_id) => write!(f, "trace({trace_id})"),
61 }
62 }
63}
64
65pub type DecoratorList = Vec<DecoratedOpLink>;