Make type_mgr a class.

This commit is contained in:
2020-09-15 19:19:58 -07:00
parent f4b5069125
commit 127f51041b
2 changed files with 27 additions and 18 deletions

View File

@@ -26,9 +26,9 @@ type_ptr type_scheme::instantiate(type_mgr& mgr) const {
}
void type_var::print(const type_mgr& mgr, std::ostream& to) const {
auto it = mgr.types.find(name);
if(it != mgr.types.end()) {
it->second->print(mgr, to);
auto type = mgr.lookup(name);
if(type) {
type->print(mgr, to);
} else {
to << name;
}
@@ -82,6 +82,12 @@ type_ptr type_mgr::new_arrow_type() {
return type_ptr(new type_arr(new_type(), new_type()));
}
type_ptr type_mgr::lookup(const std::string& var) const {
auto types_it = types.find(var);
if(types_it != types.end()) return types_it->second;
return nullptr;
}
type_ptr type_mgr::resolve(type_ptr t, type_var*& var) const {
type_var* cast;