Add a struct to contain groups of mutually recursive definitions.
This commit is contained in:
11
12/main.cpp
11
12/main.cpp
@@ -21,8 +21,7 @@ void yy::parser::error(const std::string& msg) {
|
||||
std::cout << "An error occured: " << msg << std::endl;
|
||||
}
|
||||
|
||||
extern std::map<std::string, definition_data_ptr> defs_data;
|
||||
extern std::map<std::string, definition_defn_ptr> defs_defn;
|
||||
extern definition_group global_defs;
|
||||
|
||||
void typecheck_program(
|
||||
const std::map<std::string, definition_data_ptr>& defs_data,
|
||||
@@ -180,7 +179,7 @@ int main() {
|
||||
type_env_ptr env(new type_env);
|
||||
|
||||
parser.parse();
|
||||
for(auto& def_defn : defs_defn) {
|
||||
for(auto& def_defn : global_defs.defs_defn) {
|
||||
std::cout << def_defn.second->name;
|
||||
for(auto& param : def_defn.second->params) std::cout << " " << param;
|
||||
std::cout << ":" << std::endl;
|
||||
@@ -188,9 +187,9 @@ int main() {
|
||||
def_defn.second->body->print(1, std::cout);
|
||||
}
|
||||
try {
|
||||
typecheck_program(defs_data, defs_defn, mgr, env);
|
||||
compile_program(defs_defn);
|
||||
gen_llvm(defs_data, defs_defn);
|
||||
typecheck_program(global_defs.defs_data, global_defs.defs_defn, mgr, env);
|
||||
compile_program(global_defs.defs_defn);
|
||||
gen_llvm(global_defs.defs_data, global_defs.defs_defn);
|
||||
} catch(unification_error& err) {
|
||||
std::cout << "failed to unify types: " << std::endl;
|
||||
std::cout << " (1) \033[34m";
|
||||
|
||||
Reference in New Issue
Block a user