Commit a8dfb887 authored by Kim Nguyễn's avatar Kim Nguyễn
Browse files

Silently ignore values and types with unsupported features.

parent 25dec7e5
Stdlib
Stdlib.Buffer
Stdlib.Bytes
Stdlib.Char
......
......@@ -230,6 +230,7 @@ let get_var id =
vars := (id, i) :: !vars;
i
exception Skip
let constr_table = Hashtbl.create 1024
type env = { constrs : StringSet.t; seen : IntSet.t; vars : t IntMap.t }
......@@ -247,8 +248,8 @@ let rec unfold_constr env p args =
let k = (pn, args_id) in
try Hashtbl.find constr_table k
with Not_found ->
if StringSet.mem pn env.constrs then
failwith ("Polymorphic recursion forbidden : " ^ pn);
if StringSet.mem pn env.constrs then raise Skip
(*failwith ("Polymorphic recursion forbidden : " ^ pn)*);
let slot = new_slot () in
slot.recurs <- 1;
Hashtbl.add constr_table k slot;
......@@ -312,7 +313,7 @@ let rec unfold_constr env p args =
| Type_abstract, Some t -> Link (unfold env t)
| Type_abstract, None -> (
match args with [] -> Abstract pn | _l -> raise (PolyAbstract pn))
| Type_open, _ -> failwith "unsupported open type");
| Type_open, _ -> raise Skip);
slot
and unfold env ty =
......@@ -349,7 +350,7 @@ and unfold env ty =
try Link (IntMap.find ty.id env.vars)
with Not_found -> Var (get_var ty.id))
| Tconstr (p, args, _) -> Link (unfold_constr env p args)
| _ -> failwith "Unsupported feature");
| _ -> raise Skip);
slot
let unfold ty =
......@@ -395,7 +396,7 @@ let values_of_sig name sg =
match id.[0] with
| 'a' .. 'z' | '_' -> (
let n = name ^ "." ^ id in
try (n, fst (find_value n)) :: accu with PolyAbstract _ -> accu)
try (n, fst (find_value n)) :: accu with Skip | PolyAbstract _ -> accu)
| _ -> accu
(* operator *))
| _ -> accu)
......@@ -449,9 +450,11 @@ let read_cmi name =
when Mlcompat.Mltypes.is_sig_value_val_reg s ->
if not (Mlcompat.Mltypes.is_sig_value_deprecated s) then begin
let id, t = Mlcompat.Mltypes.get_id_t_from_sig_value s in
let unf, n = unfold t in
if n != 0 then unsupported "polymorphic value";
values := (Ocaml.Ident.name id, t, unf) :: !values
try
let unf, n = unfold t in
if n != 0 then unsupported "polymorphic value";
values := (Ocaml.Ident.name id, t, unf) :: !values
with Skip -> ()
end
| Sig_type _ as s ->
let id, t, rs = Mlcompat.Mltypes.get_sig_type s in
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment