1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980(**************************************************************************)(* This file is part of the Codex semantics library. *)(* *)(* Copyright (C) 2013-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 LICENSE). *)(* *)(**************************************************************************)openCfg_sig;;moduleMake(CL:Control_location):CfgwithmoduleControl_location=CL=structmoduleControl_location=CL;;typenode={id:int;control_location:CL.t;(* Sorted list of succs and preds. *)mutablesuccs:nodelist;mutablepreds:nodelist;};;moduleNode=structmoduleControl_location=CL;;typet=node;;moduleCL_hash=Hashtbl.Make(CL);;letcl_hash=CL_hash.create17;;letcount=ref0;;letfresh()=letv=!countinincrcount;v;;(* Returns get, and a boolean telling if the node is new. *)letgetcl=matchCL_hash.findcl_hashclwith|exceptionNot_found->letcount=fresh()inletn={id=count;control_location=cl;succs=[];preds=[]}inCL_hash.replacecl_hashcln;n|n->n;;letsuccsn=n.succs;;letpredsn=n.preds;;letcompareab=a.id-b.id;;letprettyfmtx=Format.fprintffmt"n%d (%a)"x.idCL.prettyx.control_location;;letequalab=a==b(* by hash-consing, nodes are physically equal. *)lethasha=a.id;;letcontrol_locationx=x.control_location;;endletregister_edgesourcesink=(* Node that [sink] may be already known. *)letn=Node.getsinkinsource.succs<-List.mergeNode.comparesource.succs[n];n.preds<-List.mergeNode.comparen.preds[source];n;;letknown=Node.CL_hash.find_optNode.cl_hash;;end