revm_bytecode/legacy/
analyzed.rs1use super::JumpTable;
2use bitvec::{bitvec, order::Lsb0};
3use primitives::Bytes;
4use std::sync::Arc;
5
6#[derive(Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub struct LegacyAnalyzedBytecode {
10 bytecode: Bytes,
12 original_len: usize,
14 jump_table: JumpTable,
16}
17
18impl Default for LegacyAnalyzedBytecode {
19 #[inline]
20 fn default() -> Self {
21 Self {
22 bytecode: Bytes::from_static(&[0]),
23 original_len: 0,
24 jump_table: JumpTable(Arc::new(bitvec![u8, Lsb0; 0])),
25 }
26 }
27}
28
29impl LegacyAnalyzedBytecode {
30 pub fn new(bytecode: Bytes, original_len: usize, jump_table: JumpTable) -> Self {
32 Self {
33 bytecode,
34 original_len,
35 jump_table,
36 }
37 }
38
39 pub fn bytecode(&self) -> &Bytes {
43 &self.bytecode
44 }
45
46 pub fn original_len(&self) -> usize {
48 self.original_len
49 }
50
51 pub fn original_bytes(&self) -> Bytes {
53 self.bytecode.slice(..self.original_len)
54 }
55
56 pub fn original_byte_slice(&self) -> &[u8] {
58 &self.bytecode[..self.original_len]
59 }
60
61 pub fn jump_table(&self) -> &JumpTable {
63 &self.jump_table
64 }
65}