lily/src/type.hpp

45 lines
886 B
C++

#pragma once
#include <string>
#include <vector>
namespace lily {
enum reserved_types {
type_id_int = 0,
type_id_str,
type_id_last
};
struct type {
virtual ~type() = default;
};
struct type_internal : type {
int type_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* left;
type* right;
type_func(type* l, type* r) :
left(l), right(r) {}
};
}