|
|
@ -1,6 +1,7 @@ |
|
|
|
#include "type_env.hpp" |
|
|
|
#include "type.hpp" |
|
|
|
#include "error.hpp" |
|
|
|
#include <cassert> |
|
|
|
|
|
|
|
void type_env::find_free(const type_mgr& mgr, std::set<std::string>& into) const { |
|
|
|
if(parent != nullptr) parent->find_free(mgr, into); |
|
|
@ -45,7 +46,10 @@ void type_env::set_mangled_name(const std::string& name, const std::string& mang |
|
|
|
|
|
|
|
const std::string& type_env::get_mangled_name(const std::string& name) const { |
|
|
|
auto it = names.find(name); |
|
|
|
if(it != names.end()) return it->second.mangled_name; |
|
|
|
if(it != names.end()) { |
|
|
|
assert(it->second.mangled_name); |
|
|
|
return *it->second.mangled_name; |
|
|
|
} |
|
|
|
assert(parent != nullptr); |
|
|
|
return parent->get_mangled_name(name); |
|
|
|
} |
|
|
@ -59,7 +63,7 @@ type_ptr type_env::lookup_type(const std::string& name) const { |
|
|
|
|
|
|
|
void type_env::bind(const std::string& name, type_ptr t, visibility v) { |
|
|
|
type_scheme_ptr new_scheme(new type_scheme(std::move(t))); |
|
|
|
names[name] = variable_data(std::move(new_scheme), v, ""); |
|
|
|
names[name] = variable_data(std::move(new_scheme), v, std::nullopt); |
|
|
|
} |
|
|
|
|
|
|
|
void type_env::bind(const std::string& name, type_scheme_ptr t, visibility v) { |
|
|
|