2020-09-15 18:51:28 -07:00
|
|
|
#pragma once
|
|
|
|
#include "binop.hpp"
|
|
|
|
#include "parse_driver.hpp"
|
|
|
|
#include "definition.hpp"
|
|
|
|
#include "type_env.hpp"
|
|
|
|
#include "type.hpp"
|
|
|
|
#include "global_scope.hpp"
|
|
|
|
#include "mangler.hpp"
|
|
|
|
#include "llvm_context.hpp"
|
|
|
|
|
|
|
|
class compiler {
|
|
|
|
private:
|
|
|
|
file_mgr file_m;
|
|
|
|
definition_group global_defs;
|
|
|
|
parse_driver driver;
|
|
|
|
type_env_ptr global_env;
|
|
|
|
type_mgr type_m;
|
2020-09-17 18:30:41 -07:00
|
|
|
mangler mng;
|
|
|
|
global_scope global_scp;
|
2020-09-15 18:51:28 -07:00
|
|
|
llvm_context ctx;
|
|
|
|
|
|
|
|
void add_default_types();
|
|
|
|
void add_binop_type(binop op, type_ptr type);
|
|
|
|
void add_default_function_types();
|
|
|
|
void parse();
|
|
|
|
void typecheck();
|
|
|
|
void translate();
|
|
|
|
void compile();
|
|
|
|
void create_llvm_binop(binop op);
|
|
|
|
void create_llvm_bool(bool b);
|
|
|
|
void generate_llvm();
|
|
|
|
void output_llvm(const std::string& into);
|
|
|
|
public:
|
|
|
|
compiler(const std::string& filename);
|
|
|
|
void operator()(const std::string& into);
|
|
|
|
file_mgr& get_file_manager();
|
|
|
|
type_mgr& get_type_manager();
|
|
|
|
};
|