1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495(**************************************************************************)(* *)(* 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)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