12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697(**************************************************************************)(* *)(* OCaml *)(* *)(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 2002 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(* Consistency tables: for checking consistency of module CRCs *)openMiscmoduleMake(Module_name:sigtypetmoduleSet:Set.Swithtypeelt=tmoduleMap:Map.Swithtypekey=tmoduleTbl:Hashtbl.Swithtypekey=tvalcompare:t->t->intend)=structtypet=(Digest.t*filepath)Module_name.Tbl.tletcreate()=Module_name.Tbl.create13letclear=Module_name.Tbl.clearexceptionInconsistencyof{unit_name:Module_name.t;inconsistent_source:string;original_source:string;}exceptionNot_availableofModule_name.tletcheck_tblnamecrcsource=let(old_crc,old_source)=Module_name.Tbl.findtblnameinifcrc<>old_crcthenraise(Inconsistency{unit_name=name;inconsistent_source=source;original_source=old_source;})letchecktblnamecrcsource=trycheck_tblnamecrcsourcewithNot_found->Module_name.Tbl.addtblname(crc,source)letcheck_noaddtblnamecrcsource=trycheck_tblnamecrcsourcewithNot_found->raise(Not_availablename)letsettblnamecrcsource=Module_name.Tbl.addtblname(crc,source)letsourcetblname=snd(Module_name.Tbl.findtblname)letextractltbl=letl=List.sort_uniqModule_name.comparelinList.fold_left(funasscname->trylet(crc,_)=Module_name.Tbl.findtblnamein(name,Somecrc)::asscwithNot_found->(name,None)::assc)[]lletextract_mapmod_namestbl=Module_name.Set.fold(funnameresult->trylet(crc,_)=Module_name.Tbl.findtblnameinModule_name.Map.addname(Somecrc)resultwithNot_found->Module_name.Map.addnameNoneresult)mod_namesModule_name.Map.emptyletfilterptbl=letto_remove=ref[]inModule_name.Tbl.iter(funname_->ifnot(pname)thento_remove:=name::!to_remove)tbl;List.iter(funname->whileModule_name.Tbl.memtblnamedoModule_name.Tbl.removetblnamedone)!to_removeend