123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687(* Yoann Padioleau
*
* Copyright (C) 2010 Facebook
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation, with the
* special exception on linking described in file license.txt.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
* license.txt for more details.
*)openCommonmoduleV=Visitor_ml(*****************************************************************************)(* Filemames *)(*****************************************************************************)letfind_source_files_of_dir_or_filesxs=Common.files_of_dir_or_files_no_vcs_nofilterxs|>List.filter(funfilename->matchFile_type.file_type_of_filefilenamewith|File_type.PL(File_type.ML("ml"|"mli"))->true|_->false)|>Common.sortletfind_ml_files_of_dir_or_filesxs=Common.files_of_dir_or_files_no_vcs_nofilterxs|>List.filter(funfilename->matchFile_type.file_type_of_filefilenamewith|File_type.PL(File_type.ML("ml"))->true|_->false)|>Common.sortletfind_cmt_files_of_dir_or_filesxs=Common.files_of_dir_or_files_no_vcs_nofilterxs|>List.filter(funfilename->matchFile_type.file_type_of_filefilenamewith|File_type.Obj("cmt"|"cmti")->true|_->false)(* ocaml 4.07 stdlib now has those .p.cmt files that cause dupe errors *)|>Common.exclude(funfilename->filename=~".*\\.p\\.cmt")(* sometimes there is just a .cmti and no corresponding .cmt because
* people put the information only in a .mli
*)|>(funxs->lethfiles=Hashtbl.create101inxs|>List.iter(funfile->let(d,b,e)=Common2.dbe_of_filenamefileinHashtbl.addhfiles(d,b)e);Common2.hkeyshfiles|>List.map(fun(d,b)->letxs=Hashtbl.find_allhfiles(d,b)in(matchxswith|["cmt";"cmti"]|["cmti";"cmt"]|["cmt"]->Common2.filename_of_dbe(d,b,"cmt")|["cmti"]->Common2.filename_of_dbe(d,b,"cmti")|_->raiseImpossible)))|>Common.sort(*****************************************************************************)(* Extract infos *)(*****************************************************************************)letextract_info_visitorrecursor=letglobals=ref[]inlethooks={V.default_visitorwithV.kinfo=(fun(_k,_)i->Common.pushiglobals)}inbeginletvout=V.mk_visitorhooksinrecursorvout;List.rev!globalsendletii_of_anyany=extract_info_visitor(funvisitor->visitorany)