Rewrite types to not use IDs unless needed.
This commit is contained in:
28
src/type.hpp
28
src/type.hpp
@@ -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) {}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user