1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::asm_lang::allocated_ops::AllocatedOp;
use std::fmt;

/// An [InstructionSet] is produced by allocating registers on an [AbstractInstructionSet].
#[derive(Clone)]
pub enum InstructionSet {
    Fuel {
        ops: Vec<AllocatedOp>,
    },
    Evm {
        ops: Vec<etk_asm::ops::AbstractOp>,
    },
    MidenVM {
        ops: Vec<crate::asm_generation::DirectOp>,
    },
}

impl fmt::Display for InstructionSet {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(
            f,
            ".program:\n{}",
            match self {
                InstructionSet::Fuel { ops } => ops
                    .iter()
                    .map(|x| format!("{x}"))
                    .collect::<Vec<_>>()
                    .join("\n"),
                InstructionSet::Evm { ops } => ops
                    .iter()
                    .map(|x| format!("{x}"))
                    .collect::<Vec<_>>()
                    .join("\n"),
                InstructionSet::MidenVM { ops } => {
                    ops.iter()
                        .map(|x| format!("{x}"))
                        .collect::<Vec<_>>()
                        .join("\n")
                }
            }
        )
    }
}