2020-03-10 20:58:26 -07:00
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
|
|
#include "type.hpp"
|
|
|
|
|
2020-03-24 18:04:01 -07:00
|
|
|
struct type_env;
|
|
|
|
using type_env_ptr = std::shared_ptr<type_env>;
|
|
|
|
|
2020-03-10 20:58:26 -07:00
|
|
|
struct type_env {
|
2020-03-24 18:04:01 -07:00
|
|
|
type_env_ptr parent;
|
2020-03-10 20:58:26 -07:00
|
|
|
std::map<std::string, type_ptr> names;
|
|
|
|
|
2020-03-24 18:04:01 -07:00
|
|
|
type_env(type_env_ptr p) : parent(std::move(p)) {}
|
2020-03-10 20:58:26 -07:00
|
|
|
type_env() : type_env(nullptr) {}
|
|
|
|
|
|
|
|
type_ptr lookup(const std::string& name) const;
|
|
|
|
void bind(const std::string& name, type_ptr t);
|
|
|
|
};
|
2020-03-24 18:04:01 -07:00
|
|
|
|
|
|
|
|
|
|
|
type_env_ptr type_scope(type_env_ptr parent);
|