Finalize draft of polymorphism post

This commit is contained in:
2020-03-25 03:22:21 -07:00
parent de435d6c80
commit 08246f1474
8 changed files with 40 additions and 117 deletions

View File

@@ -29,10 +29,11 @@ void typecheck_program(
const std::map<std::string, definition_defn_ptr>& defs_defn,
type_mgr& mgr, type_env_ptr& env) {
type_ptr int_type = type_ptr(new type_base("Int"));
env->bind_type("Int", int_type);
type_ptr binop_type = type_ptr(new type_arr(
int_type,
type_ptr(new type_arr(int_type, int_type))));
env->bind("+", binop_type);
env->bind("-", binop_type);
env->bind("*", binop_type);
@@ -68,6 +69,8 @@ void typecheck_program(
for(auto& def_defnn_name : group->members) {
auto& def_defn = defs_defn.find(def_defnn_name)->second;
def_defn->typecheck(mgr);
}
for(auto& def_defnn_name : group->members) {
env->generalize(def_defnn_name, mgr);
}
}