De-duplicate code in get_resolved_ty, make recursive, add a case for tup.

This commit is contained in:
Graydon Hoare 2010-06-30 21:01:28 -07:00
parent d2e7c1a5dc
commit 0b252a96b1
1 changed files with 9 additions and 28 deletions

View File

@ -1528,42 +1528,23 @@ let process_crate (cx:ctxt) (crate:Ast.crate) : unit =
| _ -> bug () "check_auto_tyvar: no slot defn"
in
let get_resolved_ty tv id =
let rec get_resolved_ty tv id =
let ts = !(resolve_tyvar tv) in
match ts with
TYSPEC_resolved ([||], ty) -> ty
| TYSPEC_exterior tv ->
begin
match !(resolve_tyvar tv) with
TYSPEC_resolved ([||], ty) ->
(Ast.TY_exterior ty)
| _ ->
err (Some id)
"unresolved exterior type in %s (%d)"
(tyspec_to_str ts) (int_of_node id)
end
Ast.TY_exterior (get_resolved_ty tv id)
| TYSPEC_mutable tv ->
begin
match !(resolve_tyvar tv) with
TYSPEC_resolved ([||], ty) ->
(Ast.TY_mutable ty)
| _ ->
err (Some id)
"unresolved mutable type in %s (%d)"
(tyspec_to_str ts) (int_of_node id)
end
Ast.TY_mutable (get_resolved_ty tv id)
| TYSPEC_vector tv ->
begin
match !(resolve_tyvar tv) with
TYSPEC_resolved ([||], ty) ->
(Ast.TY_vec ty)
| _ ->
err (Some id)
"unresolved vector-element type in %s (%d)"
(tyspec_to_str ts) (int_of_node id)
end
Ast.TY_vec (get_resolved_ty tv id)
| TYSPEC_tuple tvs ->
Ast.TY_tup
(Array.map
(fun tv -> get_resolved_ty tv id) tvs)
| _ -> err (Some id)
"unresolved type %s (%d)"