use crate::parts::{Symbol, Text, Data, Bss};

/// Contains all the needed references to construct a final
/// mushed and relocated executable from an object file
pub struct Relocatable<'a> {
    pub origin: &'a str,
    pub symbols: Vec<Symbol<'a>>,
    pub texts: Vec<Text<'a>>,
    pub data: Vec<Data<'a>>,
    pub bss: Vec<Bss<'a>>,
}

impl<'a> Relocatable<'a> {
    pub fn new(origin: &'a str) -> Self {
        Self {
            origin,
            symbols: Vec::new(),
            texts: Vec::new(),
            data: Vec::new(),
            bss: Vec::new(),
        }
    }
}

impl std::fmt::Display for Relocatable<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "==={}===\nSymbols:\n{:?}\nTexts:\n??",
            self.origin, self.symbols //, self.texts
        )
    }
}
