use std::{cell::RefCell, collections::HashMap};
use super::{
block::Block,
dialect::Dialect,
mnemonic::MnemonicSegment,
op::OpObj,
region::Region,
symbol::NameManager,
ty::TyObj,
value::Value,
};
use crate::support::{
cast::CasterStorage,
storage::{Arena, UniqueArena},
};
#[derive(Default)]
pub struct Context {
pub values: Arena<Value>,
pub blocks: Arena<Block>,
pub regions: Arena<Region>,
pub ops: Arena<OpObj>,
pub tys: UniqueArena<TyObj>,
pub dialects: HashMap<MnemonicSegment, Dialect>,
pub casters: CasterStorage,
pub(crate) value_names: RefCell<NameManager<Value>>,
}
impl Context {
pub fn register_dialect(&mut self, dialect: Dialect) {
self.dialects.insert(dialect.mnemonic(), dialect);
}
}