24 lines
638 B
C++
24 lines
638 B
C++
#pragma once
|
|
#include <map>
|
|
#include <memory>
|
|
#include "type.hpp"
|
|
#include "ast.hpp"
|
|
|
|
namespace lily {
|
|
class type_env {
|
|
private:
|
|
type_env* parent = nullptr;
|
|
std::map<std::string, type*> identifier_types;
|
|
|
|
public:
|
|
bool identifier_exists(const std::string& name);
|
|
type* get_identifier_type(const std::string& name);
|
|
void unify(type* l, type* r);
|
|
|
|
std::shared_ptr<type_env> with_type(const std::string& name, type* ntype);
|
|
void set_type(const std::string& name, type* ntype);
|
|
|
|
void set_parent(type_env* new_parent);
|
|
};
|
|
}
|