revm_bytecode/legacy/
raw.rs1use super::{analyze_legacy, LegacyAnalyzedBytecode};
2use core::ops::Deref;
3use primitives::Bytes;
4
5#[derive(Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub struct LegacyRawBytecode(pub Bytes);
10
11impl LegacyRawBytecode {
12 pub fn into_analyzed(self) -> LegacyAnalyzedBytecode {
16 let bytecode = self.0;
17 let len = bytecode.len();
18 let (jump_table, padded_bytecode) = analyze_legacy(bytecode);
19 LegacyAnalyzedBytecode::new(padded_bytecode, len, jump_table)
20 }
21}
22
23impl From<Bytes> for LegacyRawBytecode {
24 fn from(bytes: Bytes) -> Self {
25 Self(bytes)
26 }
27}
28
29impl<const N: usize> From<[u8; N]> for LegacyRawBytecode {
30 fn from(bytes: [u8; N]) -> Self {
31 Self(bytes.into())
32 }
33}
34
35impl Deref for LegacyRawBytecode {
36 type Target = Bytes;
37
38 fn deref(&self) -> &Self::Target {
39 &self.0
40 }
41}