1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071(**************************************************************************)(* *)(* This file is part of Frama-C. *)(* *)(* Copyright (C) 2007-2025 *)(* 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). *)(* *)(**************************************************************************)typeformat=Dot|Jsonletoutputformatcontextfilename=letgraph=Context.get_graphcontextinletoutput_functionchannel=matchformatwith|Dot->Dive_graph.output_to_dotchannelgraph|Json->Server_interface.output_to_jsonchannelgraphinSelf.result"output to %a"Filepath.prettyfilename;matchFilesystem.with_open_outfilenameoutput_functionwith|Ok()->()|Errorerror->Self.warning"failed to output graph: %s"errorletmain()=ifnot(Self.FromBases.is_empty()&&Self.FromFunctionAlarms.is_empty())thenbegin(* Make sure Eva is computed *)Eva.Analysis.compute();(* Create the initial graph *)letcontext=Context.create()in(* Handle parameters *)Self.UnfoldedBases.iter(Context.unfoldcontext);Self.HiddenBases.iter(Context.hidecontext);letdepth=Self.DepthLimit.get()in(* Add targeted vars to it *)letadd_varvi=letnode=Build.add_varcontextviinBuild.explore_backward~depthcontextnodeinSelf.FromBases.iteradd_var;(* Add alarms *)letadd_alarm_emitterkfstmt~rank:_alarm_code_annot=ifSelf.FromFunctionAlarms.memkfthenbeginletnode=Build.add_alarmcontextstmtalarminBuild.explore_backward~depthcontextnodeendinifnot(Self.FromFunctionAlarms.is_empty())thenAlarms.iteradd_alarm;(* Output it *)ifnot(Self.OutputDot.is_empty())thenoutputDotcontext(Self.OutputDot.get());ifnot(Self.OutputJson.is_empty())thenoutputJsoncontext(Self.OutputJson.get());endlet()=Boot.Main.extendmain