Write up type code

This commit is contained in:
2019-08-25 16:42:23 -07:00
parent ac589a8b0a
commit 1820a05fcc
3 changed files with 187 additions and 12 deletions

View File

@@ -15,11 +15,11 @@ struct type_var : public type {
: name(std::move(n)) {}
};
struct type_id : public type {
int id;
struct type_base : public type {
std::string name;
type_id(int i)
: id(i) {}
type_base(std::string n)
: name(std::move(n)) {}
};
struct type_arr : public type {
@@ -32,8 +32,13 @@ struct type_arr : public type {
struct type_mgr {
int last_id = 0;
std::map<std::string, type_ptr> types;
std::string new_type_name();
type_ptr new_type();
type_ptr new_arrow_type();
void unify(type_ptr l, type_ptr r);
type_ptr resolve(type_ptr t, type_var*& var);
void bind(std::string s, type_ptr t);
};