@@ -39,23 +39,6 @@ impl WrappedOpcode {
39
39
/// The depth is calculated as the maximum depth of any input plus 1.
40
40
/// A depth of 1 means the opcode has only raw inputs (or no inputs).
41
41
/// Greater depths indicate a chain of operations.
42
- ///
43
- /// ```
44
- /// use heimdall_vm::core::opcodes::wrapped::{WrappedOpcode, WrappedInput};
45
- /// use alloy::primitives::U256;
46
- /// use heimdall_vm::ext::lexers::solidity::WrappedOpcode;
47
- ///
48
- /// // Create a PUSH1 0x01 operation
49
- /// let push1 = WrappedOpcode::new(0x60, vec![WrappedInput::Raw(U256::from(1))]);
50
- /// assert_eq!(push1.depth(), 1); // Depth is 1 because it has only raw inputs
51
- ///
52
- /// // Create an ADD operation that takes the result of two PUSH operations
53
- /// let add = WrappedOpcode::new(0x01, vec![
54
- /// WrappedInput::Opcode(push1.clone()),
55
- /// WrappedInput::Opcode(push1.clone())
56
- /// ]);
57
- /// assert_eq!(add.depth(), 2); // Depth is 2 because it contains operations with depth 1
58
- /// ```
59
42
pub fn depth ( & self ) -> u32 {
60
43
self . inputs . iter ( ) . map ( |x| x. depth ( ) ) . max ( ) . unwrap_or ( 0 ) + 1
61
44
}
@@ -66,21 +49,6 @@ impl std::fmt::Display for WrappedOpcode {
66
49
///
67
50
/// The format is: `OPCODENAME(input1, input2, ...)` where each input is
68
51
/// formatted according to its own [`Display`] implementation.
69
- ///
70
- /// ```
71
- /// use heimdall_vm::core::opcodes::wrapped::{WrappedOpcode, WrappedInput};
72
- /// use heimdall_vm::ext::lexers::solidity::WrappedOpcode;
73
- /// use alloy::primitives::U256;
74
- ///
75
- /// let push1 = WrappedOpcode::new(0x60, vec![WrappedInput::Raw(U256::from(1))]);
76
- /// assert_eq!(push1.to_string(), "PUSH1(1)");
77
- ///
78
- /// let add = WrappedOpcode::new(0x01, vec![
79
- /// WrappedInput::Opcode(push1.clone()),
80
- /// WrappedInput::Opcode(push1.clone())
81
- /// ]);
82
- /// assert_eq!(add.to_string(), "ADD(PUSH1(1), PUSH1(1))");
83
- /// ```
84
52
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
85
53
write ! (
86
54
f,
@@ -99,21 +67,6 @@ impl WrappedInput {
99
67
///
100
68
/// This method is used to calculate the recursive depth of operations
101
69
/// for analysis and optimization purposes.
102
- ///
103
- /// ```
104
- /// use heimdall_vm::core::opcodes::wrapped::WrappedInput;
105
- /// use heimdall_vm::ext::lexers::solidity::WrappedOpcode;
106
- /// use alloy::primitives::U256;
107
- ///
108
- /// // Raw inputs have depth 0
109
- /// let raw = WrappedInput::Raw(U256::from(42));
110
- /// assert_eq!(raw.depth(), 0);
111
- ///
112
- /// // Opcode inputs have the depth of the operation they contain
113
- /// let push1 = WrappedOpcode::new(0x60, vec![WrappedInput::Raw(U256::from(1))]);
114
- /// let op_input = WrappedInput::Opcode(push1);
115
- /// assert_eq!(op_input.depth(), 1);
116
- /// ```
117
70
pub fn depth ( & self ) -> u32 {
118
71
match self {
119
72
WrappedInput :: Raw ( _) => 0 ,
@@ -127,19 +80,6 @@ impl std::fmt::Display for WrappedInput {
127
80
///
128
81
/// - For [`Raw`] inputs, displays the contained [`U256`] value.
129
82
/// - For [`Opcode`] inputs, recursively formats the contained [`WrappedOpcode`].
130
- ///
131
- /// ```
132
- /// use heimdall_vm::core::opcodes::wrapped::WrappedInput;
133
- /// use heimdall_vm::ext::lexers::solidity::WrappedOpcode;
134
- /// use alloy::primitives::U256;
135
- ///
136
- /// let raw = WrappedInput::Raw(U256::from(42));
137
- /// assert_eq!(raw.to_string(), "42");
138
- ///
139
- /// let push1 = WrappedOpcode::new(0x60, vec![WrappedInput::Raw(U256::from(1))]);
140
- /// let op_input = WrappedInput::Opcode(push1);
141
- /// assert_eq!(op_input.to_string(), "PUSH1(1)");
142
- /// ```
143
83
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
144
84
match self {
145
85
WrappedInput :: Raw ( u256) => write ! ( f, "{u256}" ) ,
@@ -153,19 +93,6 @@ impl From<U256> for WrappedInput {
153
93
///
154
94
/// This implementation allows for more ergonomic code when creating
155
95
/// [`WrappedInput`]s from raw values.
156
- ///
157
- /// ```
158
- /// use heimdall_vm::core::opcodes::wrapped::WrappedInput;
159
- /// use alloy::primitives::U256;
160
- ///
161
- /// let u256_val = U256::from(42);
162
- /// let input: WrappedInput = u256_val.into();
163
- ///
164
- /// match input {
165
- /// WrappedInput::Raw(val) => assert_eq!(val, U256::from(42)),
166
- /// _ => panic!("Expected Raw variant"),
167
- /// }
168
- /// ```
169
96
fn from ( val : U256 ) -> Self {
170
97
WrappedInput :: Raw ( val)
171
98
}
@@ -176,20 +103,6 @@ impl From<WrappedOpcode> for WrappedInput {
176
103
///
177
104
/// This implementation allows for more ergonomic code when creating
178
105
/// [`WrappedInput`]s from operations.
179
- ///
180
- /// ```
181
- /// use heimdall_vm::core::opcodes::wrapped::WrappedInput;
182
- /// use heimdall_vm::ext::lexers::solidity::WrappedOpcode;
183
- /// use alloy::primitives::U256;
184
- ///
185
- /// let push1 = WrappedOpcode::new(0x60, vec![WrappedInput::Raw(U256::from(1))]);
186
- /// let input: WrappedInput = push1.clone().into();
187
- ///
188
- /// match input {
189
- /// WrappedInput::Opcode(op) => assert_eq!(op, push1),
190
- /// _ => panic!("Expected Opcode variant"),
191
- /// }
192
- /// ```
193
106
fn from ( val : WrappedOpcode ) -> Self {
194
107
WrappedInput :: Opcode ( val)
195
108
}
0 commit comments