use crate::{Composite, ConstDeclaration, Function, Indent, Interface};
use leo_span::Symbol;
use std::fmt;
use itertools::Itertools;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct Module {
pub program_name: Symbol,
pub path: Vec<Symbol>,
pub consts: Vec<(Symbol, ConstDeclaration)>,
pub composites: Vec<(Symbol, Composite)>,
pub functions: Vec<(Symbol, Function)>,
pub interfaces: Vec<(Symbol, Interface)>,
}
impl fmt::Display for Module {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "module {} {{", self.path.iter().format("::"))?;
for (_, const_decl) in self.consts.iter() {
writeln!(f, "{};", Indent(const_decl))?;
}
for (_, composite) in self.composites.iter() {
writeln!(f, "{}", Indent(composite))?;
}
for (_, function) in self.functions.iter() {
writeln!(f, "{}", Indent(function))?;
}
writeln!(f, "}}")
}
}