2020-03-10 20:58:26 -07:00
|
|
|
#include "type_env.hpp"
|
|
|
|
|
|
|
|
type_ptr type_env::lookup(const std::string& name) const {
|
|
|
|
auto it = names.find(name);
|
|
|
|
if(it != names.end()) return it->second;
|
|
|
|
if(parent) return parent->lookup(name);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void type_env::bind(const std::string& name, type_ptr t) {
|
|
|
|
names[name] = t;
|
|
|
|
}
|
|
|
|
|
2020-03-24 18:04:01 -07:00
|
|
|
type_env_ptr type_scope(type_env_ptr parent) {
|
|
|
|
return type_env_ptr(new type_env(std::move(parent)));
|
2020-03-10 20:58:26 -07:00
|
|
|
}
|