sbpf_common/
instruction.rs

1use crate::opcode::Opcode;
2
3use std::ops::Range;
4
5#[derive(Debug, Clone)]
6pub struct Register {
7    pub n: u8,
8}
9
10impl Register {
11    pub fn to_string(&self) -> String {
12        format!("r{}", self.n)
13    }
14}
15
16#[derive(Debug, Clone)]
17pub enum Number {
18    Int(i64),
19    Addr(i64),
20}
21
22#[derive(Debug, Clone)]
23pub struct Instruction {
24    pub opcode: Opcode,
25    pub dst: Option<Register>,
26    pub src: Option<Register>,
27    pub off: Option<i16>,
28    pub imm: Option<Number>,
29    pub span: Range<usize>,
30}