Rewrite types to not use IDs unless needed.

This commit is contained in:
2019-06-09 16:13:13 -07:00
parent f3be325644
commit 1e77622589
8 changed files with 110 additions and 76 deletions

View File

@@ -13,20 +13,32 @@ namespace lily {
virtual ~type() = default;
};
typedef std::shared_ptr<type> type_ptr;
struct type_int : type {
struct type_internal : type {
int type_id;
type_int(int id) : type_id(id) {}
type_internal(int id) : type_id(id) {}
};
struct type_data : type {
struct constructor {
type_data* parent;
int id;
std::vector<type*> params;
};
int type_id;
std::vector<std::unique_ptr<constructor>> constructors;
type_data(int id) : type_id(id) {}
constructor* create_constructor(const std::string& name, std::vector<type*>&& params);
};
struct type_func : type {
type_ptr left;
type_ptr right;
type* left;
type* right;
type_func(type_ptr l, type_ptr r) :
left(std::move(l)), right(std::move(r)) {}
type_func(type* l, type* r) :
left(l), right(r) {}
};
}