1234567891011121314151617181920212223242526272829303132333435363738394041(**************************************************************************)(* 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). *)(* *)(**************************************************************************)type'ahook=(string*('a->unit))Stack.tletadd_hookh~namef=Stack.push(name,f)hletrun_hookharg=h|>Stack.iter(fun(name,f)->(* Printf.printf "Running hook %s\n" name; *)tryfargwithexn->Format.eprintf"ERROR: When running hook '%s': %s@."name(Printexc.to_stringexn))(* let before_init = Stack.create() *)(* let after_init = Stack.create() *)letstartup=Stack.create()letafter_domain_build=Stack.create()letexit=Stack.create()let()=Stdlib.at_exit(fun()->run_hookexit())