1234567891011121314151617181920212223242526272829303132333435363738394041424344454647(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
*
* This program is free software; 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, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program 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.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)open!StdlibopenCodeletclosurep~bound_vars~f~params~cont:(pc,args)=lets=Subst.from_map(Var.Set.fold(funxs->Var.Map.addx(Var.forkx)s)bound_varsVar.Map.empty)inletfree_pc,m=Code.traverse{fold=Code.fold_children}(funpc(pc',m)->pc'+1,Addr.Map.addpcpc'm)pcp.blocks(p.free_pc,Addr.Map.empty)inletblocks=Code.traverse{fold=Code.fold_children}(funpcblocks->letb=Addr.Map.findpcblocksinletb=Subst.Including_Binders.And_Continuations.blockmsbinAddr.Map.add(Addr.Map.findpcm)bblocks)pcp.blocksp.blocksinletp={pwithblocks;free_pc}inp,sf,List.map~f:sparams,(Addr.Map.findpcm,List.map~f:sargs)