use crate::{
    core::compile_passes::{circuit_builder::arcis_gate::ArcisGate, Gate},
    utils::hash_map_vec::HashMapVec,
    AsyncMPCCircuit,
};

mod arcis_gate;

type Label = core_utils::circuit::GateIndex;

#[derive(Debug, Clone, Default)]
pub struct CircuitBuilder {
    contents: HashMapVec<ArcisGate>,
}

impl CircuitBuilder {
    pub fn add_gate(&mut self, gate: Gate) -> Label {
        self.contents.push(ArcisGate::new(gate)) as u32
    }
    pub fn into_circuit(self, outputs: Vec<Label>) -> AsyncMPCCircuit {
        let gates = self.contents.move_vec();
        let mut circuit = AsyncMPCCircuit::default();
        for gate in gates {
            circuit.add_gate(gate.get().clone());
        }
        for output in outputs {
            circuit.output_gate(output);
        }
        circuit
    }
}
