Do the first round of revisions on part 3
This commit is contained in:
parent
802e551ff4
commit
7e98477450
20
03/ast.cpp
20
03/ast.cpp
|
@ -28,28 +28,22 @@ type_ptr ast_binop::typecheck(type_mgr& mgr, const type_env& env) const {
|
|||
type_ptr ftype = env.lookup(op_name(op));
|
||||
if(!ftype) throw 0;
|
||||
|
||||
type_ptr place_a = mgr.new_type();
|
||||
type_ptr place_b = mgr.new_type();
|
||||
type_ptr place_c = mgr.new_type();
|
||||
type_ptr arrow_one = type_ptr(new type_arr(place_b, place_c));
|
||||
type_ptr arrow_two = type_ptr(new type_arr(place_a, arrow_one));
|
||||
type_ptr return_type = mgr.new_type();
|
||||
type_ptr arrow_one = type_ptr(new type_arr(rtype, return_type));
|
||||
type_ptr arrow_two = type_ptr(new type_arr(ltype, arrow_one));
|
||||
|
||||
mgr.unify(arrow_two, ftype);
|
||||
mgr.unify(place_a, ltype);
|
||||
mgr.unify(place_b, rtype);
|
||||
return place_c;
|
||||
return return_type;
|
||||
}
|
||||
|
||||
type_ptr ast_app::typecheck(type_mgr& mgr, const type_env& env) const {
|
||||
type_ptr ltype = left->typecheck(mgr, env);
|
||||
type_ptr rtype = right->typecheck(mgr, env);
|
||||
|
||||
type_ptr place_a = mgr.new_type();
|
||||
type_ptr place_b = mgr.new_type();
|
||||
type_ptr arrow = type_ptr(new type_arr(place_a, place_b));
|
||||
type_ptr return_type = mgr.new_type();
|
||||
type_ptr arrow = type_ptr(new type_arr(rtype, return_type));
|
||||
mgr.unify(arrow, ltype);
|
||||
mgr.unify(place_a, rtype);
|
||||
return place_b;
|
||||
return return_type;
|
||||
}
|
||||
|
||||
type_ptr ast_case::typecheck(type_mgr& mgr, const type_env& env) const {
|
||||
|
|
Loading…
Reference in New Issue
Block a user