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

@@ -18,7 +18,7 @@ void ast_int::find_free(type_mgr& mgr, type_env_ptr& env, std::set<std::string>&
}
type_ptr ast_int::typecheck(type_mgr& mgr) {
return type_ptr(new type_base("Int"));
return type_ptr(new type_app(env->lookup_type("Int")));
}
void ast_int::compile(const env_ptr& env, std::vector<instruction_ptr>& into) const {
@@ -161,7 +161,9 @@ type_ptr ast_case::typecheck(type_mgr& mgr) {
}
input_type = mgr.resolve(case_type, var);
if(!dynamic_cast<type_data*>(input_type.get())) {
type_app* app_type;
if(!(app_type = dynamic_cast<type_app*>(input_type.get())) ||
!dynamic_cast<type_data*>(app_type->constructor.get())) {
throw type_error("attempting case analysis of non-data type");
}
@@ -169,7 +171,8 @@ type_ptr ast_case::typecheck(type_mgr& mgr) {
}
void ast_case::compile(const env_ptr& env, std::vector<instruction_ptr>& into) const {
type_data* type = dynamic_cast<type_data*>(input_type.get());
type_app* app_type = dynamic_cast<type_app*>(input_type.get());
type_data* type = dynamic_cast<type_data*>(app_type->constructor.get());
of->compile(env, into);
into.push_back(instruction_ptr(new instruction_eval()));