citadel_frontend/util/
mod.rs

1use std::fmt::Debug;
2
3use crate::ir::{IRExpr, IRTypedIdent};
4
5pub mod errors;
6
7#[derive(Debug)]
8pub enum CompositeDataType {
9    Struct,
10    Union,
11}
12
13pub(crate) trait VecDisplay: Debug {
14    fn to_string(&self) -> String;
15}
16
17impl VecDisplay for Vec<IRExpr<'_>> {
18    fn to_string(&self) -> String {
19        let mut exprs = Vec::new();
20        for expr in self {
21            exprs.push(expr.to_string());
22            exprs.push(",".into());
23        }
24        exprs.pop();
25        exprs.join("")
26    }
27}
28
29impl VecDisplay for Vec<IRTypedIdent<'_>> {
30    fn to_string(&self) -> String {
31        let mut idents = Vec::new();
32        for ident in self {
33            idents.push(format!("${} {},", ident.ident, ident._type));
34        }
35        let mut idents = idents.join("");
36        idents.pop();
37        idents
38    }
39}