miden_core/operations/debug_metadata/
assembly_op.rs1use alloc::sync::Arc;
2use core::fmt;
3
4use miden_debug_types::Location;
5
6#[derive(Clone, Debug, Eq, PartialEq)]
11pub struct AssemblyOp {
12 location: Option<Location>,
13 context_name: Arc<str>,
14 op: Arc<str>,
15 num_cycles: u8,
16}
17
18impl AssemblyOp {
19 pub fn new(
22 location: Option<Location>,
23 context_name: impl Into<Arc<str>>,
24 num_cycles: u8,
25 op: impl Into<Arc<str>>,
26 ) -> Self {
27 Self {
28 location,
29 context_name: context_name.into(),
30 op: op.into(),
31 num_cycles,
32 }
33 }
34
35 pub fn location(&self) -> Option<&Location> {
37 self.location.as_ref()
38 }
39
40 pub fn context_name(&self) -> &Arc<str> {
42 &self.context_name
43 }
44
45 pub const fn num_cycles(&self) -> u8 {
47 self.num_cycles
48 }
49
50 pub fn op(&self) -> &Arc<str> {
52 &self.op
53 }
54
55 pub fn set_num_cycles(&mut self, num_cycles: u8) {
60 self.num_cycles = num_cycles;
61 }
62
63 pub fn set_location(&mut self, location: Location) {
65 self.location = Some(location);
66 }
67}
68
69impl fmt::Display for AssemblyOp {
70 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
71 write!(
72 f,
73 "context={}, operation={}, cost={}",
74 self.context_name, self.op, self.num_cycles,
75 )
76 }
77}