From 99e196294f3de42f5f7285cbc7fa40f8171026a6 Mon Sep 17 00:00:00 2001 From: gmelquio Date: Tue, 6 Oct 2009 16:56:03 +0000 Subject: Relaxed error severity when encountering unknown library objects or tactic extensions. This makes it possible to load .vo compiled with a nonstandard toplevel, e.g. ssreflect, which defines new tactics and new hint databases. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@12375 85f007b7-540e-0410-9357-904b9bb8a0f7 --- library/libobject.ml | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'library/libobject.ml') diff --git a/library/libobject.ml b/library/libobject.ml index 9beb32cfc..4bd701e13 100644 --- a/library/libobject.ml +++ b/library/libobject.ml @@ -124,26 +124,30 @@ let declare_object odecl = dyn_rebuild_function = rebuild }; (infun,outfun) +let missing_tab = (Hashtbl.create 17 : (string, unit) Hashtbl.t) + (* this function describes how the cache, load, open, and export functions are triggered. In relaxed mode, this function just return a meaningless value instead of raising an exception when they fail. *) let apply_dyn_fun deflt f lobj = let tag = object_tag lobj in - try - let dodecl = - try - Hashtbl.find cache_tab tag - with Not_found -> - if !relax_flag then - failwith "local to_apply_dyn_fun" - else - error - ("Cannot find library functions for an object with tag "^tag^ - " (maybe a plugin is missing)") in - f dodecl - with - Failure "local to_apply_dyn_fun" -> deflt;; + try + let dodecl = + try + Hashtbl.find cache_tab tag + with Not_found -> + failwith "local to_apply_dyn_fun" in + f dodecl + with + Failure "local to_apply_dyn_fun" -> + if not (!relax_flag || Hashtbl.mem missing_tab tag) then + begin + Pp.warning ("Cannot find library functions for an object with tag " + ^ tag ^ " (a plugin may be missing)"); + Hashtbl.add missing_tab tag () + end; + deflt let cache_object ((_,lobj) as node) = apply_dyn_fun () (fun d -> d.dyn_cache_function node) lobj -- cgit v1.2.3