Switch type environment to using pointers
This commit is contained in:
parent
5d53678e83
commit
6714e18e7c
|
@ -11,6 +11,6 @@ void type_env::bind(const std::string& name, type_ptr t) {
|
||||||
names[name] = t;
|
names[name] = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
type_env type_env::scope() const {
|
type_env_ptr type_scope(type_env_ptr parent) {
|
||||||
return type_env(this);
|
return type_env_ptr(new type_env(std::move(parent)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,19 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "type.hpp"
|
#include "type.hpp"
|
||||||
|
|
||||||
struct type_env {
|
struct type_env;
|
||||||
std::map<std::string, type_ptr> names;
|
using type_env_ptr = std::shared_ptr<type_env>;
|
||||||
type_env const* parent = nullptr;
|
|
||||||
|
|
||||||
type_env(type_env const* p)
|
struct type_env {
|
||||||
: parent(p) {}
|
type_env_ptr parent;
|
||||||
|
std::map<std::string, type_ptr> names;
|
||||||
|
|
||||||
|
type_env(type_env_ptr p) : parent(std::move(p)) {}
|
||||||
type_env() : type_env(nullptr) {}
|
type_env() : type_env(nullptr) {}
|
||||||
|
|
||||||
type_ptr lookup(const std::string& name) const;
|
type_ptr lookup(const std::string& name) const;
|
||||||
void bind(const std::string& name, type_ptr t);
|
void bind(const std::string& name, type_ptr t);
|
||||||
type_env scope() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
type_env_ptr type_scope(type_env_ptr parent);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user