Integrate new types into the rest of the project

This commit is contained in:
2020-04-13 17:12:43 -07:00
parent 379a64f379
commit 2a936927a1
5 changed files with 58 additions and 26 deletions

View File

@@ -4,6 +4,7 @@
#include <set>
#include "instruction.hpp"
#include "llvm_context.hpp"
#include "parsed_type.hpp"
#include "type_env.hpp"
struct ast;
@@ -11,10 +12,10 @@ using ast_ptr = std::unique_ptr<ast>;
struct constructor {
std::string name;
std::vector<std::string> types;
std::vector<parsed_type_ptr> types;
int8_t tag;
constructor(std::string n, std::vector<std::string> ts)
constructor(std::string n, std::vector<parsed_type_ptr> ts)
: name(std::move(n)), types(std::move(ts)) {}
};
@@ -52,14 +53,18 @@ using definition_defn_ptr = std::unique_ptr<definition_defn>;
struct definition_data {
std::string name;
std::vector<std::string> vars;
std::vector<constructor_ptr> constructors;
type_env_ptr env;
definition_data(std::string n, std::vector<constructor_ptr> cs)
: name(std::move(n)), constructors(std::move(cs)) {}
definition_data(
std::string n,
std::vector<std::string> vs,
std::vector<constructor_ptr> cs)
: name(std::move(n)), vars(std::move(vs)), constructors(std::move(cs)) {}
void insert_types(type_mgr& mgr, type_env_ptr& env);
void insert_types(type_env_ptr& env);
void insert_constructors() const;
void generate_llvm(llvm_context& ctx);
};