i8051_disassembler/render/
mod.rs1use serde::{Deserialize, Serialize};
2
3use crate::{address::AddressValue, db::DataType};
4
5pub mod data;
6pub mod sdas;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub enum Line {
10 Org {
11 addr: AddressValue,
12 },
13 Blank,
14 Comment {
15 addr: AddressValue,
16 text: String,
17 },
18 Label {
19 addr: AddressValue,
20 name: String,
21 },
22 Instruction {
23 addr: AddressValue,
24 direct: Option<u8>, text: String,
26 bytes: Vec<u8>,
27 #[serde(skip_serializing_if = "Option::is_none", default)]
28 target: Option<AddressValue>,
29 },
30 Data {
31 addr: AddressValue,
32 data_type: DataType,
33 bytes: Vec<u8>,
34 },
35 Raw {
36 addr: AddressValue,
37 bytes: Vec<u8>,
38 },
39 Function {
40 addr: AddressValue,
41 name: String,
42 signature: Option<String>,
43 length: AddressValue,
44 noreturn: bool,
45 },
46}
47
48impl Line {
49 pub fn addr(&self) -> AddressValue {
50 match self {
51 Self::Org { addr, .. }
52 | Self::Comment { addr, .. }
53 | Self::Label { addr, .. }
54 | Self::Function { addr, .. }
55 | Self::Instruction { addr, .. }
56 | Self::Data { addr, .. }
57 | Self::Raw { addr, .. } => *addr,
58 Self::Blank => 0,
59 }
60 }
61}