123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113(**************************************************************************)(* *)(* This file is part of Frama-C. *)(* *)(* Copyright (C) 2007-2023 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It 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 *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)openCil_typesmoduleTable=Datatype.String.Hashtbltypet={globals:varinfoTable.t;functions:varinfoTable.t;typedefs:typeinfoTable.t;structs:compinfoTable.t;unions:compinfoTable.t;enums:enuminfoTable.t;}letempty():t={globals=Table.create17;functions=Table.create17;typedefs=Table.create17;structs=Table.create17;unions=Table.create17;enums=Table.create17;}letadd_global(env:t)(vi:varinfo):unit=Table.addenv.globalsvi.vnameviletadd_function(env:t)(vi:varinfo):unit=Table.addenv.functionsvi.vnameviletadd_typeinfo(env:t)(typeinfo:typeinfo):unit=Table.addenv.typedefstypeinfo.torig_nametypeinfoletadd_compinfo(env:t)(compinfo:compinfo):unit=lettable=ifcompinfo.cstructthenenv.structselseenv.unionsinTable.addtablecompinfo.corig_namecompinfoletadd_enuminfo(env:t)(enuminfo:enuminfo):unit=Table.addenv.enumsenuminfo.eorig_nameenuminfoletfind_global(env:t)(vname:string):varinfo=Table.findenv.globalsvnameletfind_function(env:t)(vname:string):varinfo=Table.findenv.functionsvnameletfind_typedef(env:t)(tname:string):typeinfo=Table.findenv.typedefstnameletfind_struct(env:t)(tname:string):compinfo=Table.findenv.structstnameletfind_union(env:t)(tname:string):compinfo=Table.findenv.unionstnameletfind_enum(env:t)(tname:string):enuminfo=Table.findenv.enumstnameletfind_type(env:t)(namespace:Logic_typing.type_namespace)(tname:string):typ=matchnamespacewith|Logic_typing.Typedef->TNamed(find_typedefenvtname,[])|Logic_typing.Struct->TComp(find_structenvtname,[])|Logic_typing.Union->TComp(find_unionenvtname,[])|Logic_typing.Enum->TEnum(find_enumenvtname,[])letfrom_file(file:file):t=letenv=empty()inletv=objectinheritCil.nopCilVisitormethod!vglobglob=beginmatchglobwith|GFunDecl(_,vi,_)|GFun({svar=vi},_)->add_functionenvvi|GVarDecl(vi,_)|GVar(vi,_,_)->add_globalenvvi|GType(typeinfo,_)->add_typeinfoenvtypeinfo|GCompTag(compinfo,_)->add_compinfoenvcompinfo|GEnumTag(enuminfo,_)->add_enuminfoenvenuminfo|_->()end;Cil.SkipChildrenendinCil.visitCilFilevfile;env