use crate::*;
pub struct ProcessingStep2();
impl ProcessingStep2 {
pub fn exec(&self, host: &mut SModelHost, m: &Rc<SmType>) -> bool {
let slot = host.factory.create_smtype_slot(m.name.to_string());
if let Some(inherits) = &m.inherits {
if let Some(inherited_smtype) = host.smtype_slots.get(&inherits.to_string()) {
slot.set_inherits(Some(inherited_smtype));
inherited_smtype.subtypes().push(slot.clone());
} else {
inherits.span().unwrap().error(format!("Data type '{}' not found.", inherits.to_string())).emit();
return false;
}
}
if host.smtype_slots.contains_key(&slot.name()) {
m.name.span().unwrap().error(format!("Redefining '{}'", slot.name())).emit();
return false;
} else {
host.smtype_slots.insert(slot.name(), slot.clone());
}
host.semantics.set(m, Some(slot));
true
}
}