Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file tree_adv.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167(**************************************************************************)(* *)(* Copyright (C) Johannes Kanig, Stephane Lescuyer *)(* Jean-Christophe Filliatre, Romain Bardou and Francois Bobot *)(* *)(* This software is free software; you can redistribute it and/or *)(* modify it under the terms of the GNU Library General Public *)(* License version 2.1, with the special exception on linking *)(* described in file LICENSE. *)(* *)(* This software 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. *)(* *)(**************************************************************************)type'at=Nodeof'a*'atlistletrecmapf(Node(x,l))=Node(fx,List.map(mapf)l)letrecmap2f(Node(x,l1))(Node(y,l2))=Node(fxy,List.map2(map2f)l1l2)letreccombine(Node(x,l1))(Node(y,l2))=Node((x,y),List.map2combinel1l2)letrecsplit(Node((x,y),l))=letl1,l2=List.split(List.mapsplitl)in(Node(x,l1),Node(y,l2))letrecfoldfacc(Node(x,l))=letacc=List.fold_left(foldf)acclinfaccxletrecfold_childfacc(Node(x,l))=List.fold_left(funacc(Node(y,_)asn)->fold_childf(faccxy)n)acclletfilter_optionft=letrecaux(Node(x,l))=matchfxwith|None->None|Somex->letl=List.mapauxlinletl=List.filter(functionNone->false|Some_->true)linletl=List.map(functionNone->assertfalse|Somex->x)linSome(Node(x,l))inmatchauxtwithNone->invalid_arg"Tree_adv.filter"|Somex->xletfilterft=filter_option(funa->iffathenNoneelseSomea)tletroot_mapft=letrecauxr(Node(x,l))=Node(frx,List.map(aux(Somex))l)inauxNonetletmap_childrenft=letrecaux(Node(x,l))=letchild=List.map(functionNode(x,_)->x)linNode(fxchild,List.mapauxl)inauxtmodulePlace(X:Signature.Boxlike)=structletgen_place~placet=letbox_from_az=Box.empty~width:(X.widthz)~height:(X.heightz)()inletbox_tree=mapbox_from_atinletb=placebox_treeinmap2(funze->X.set_pos(Box.ctr(Box.subeb))z)tbox_treeletplace?(cs=Num.bp5.)?(ls=Num.bp12.)?(valign=`Center)?(halign=`North)t=letrecaux(Node(x,l))=letl=Box.hbox~padding:cs~pos:halign(List.mapauxl)inBox.vbox~padding:ls~pos:valign[x;l]inauxtletplace?ls?cs?valign?halignt=gen_place~place:(place?ls?cs?valign?halign)tendopenCommandletdrawto_boxt=fold(funaccx->acc++Box.draw(to_boxx))Command.noptletgen_draw_arrowsdefault~style~cornert=root_map(funab->matchawith|None->default|Somea->style(corner`Southa)(corner`Northb))tletwrap_whs_boxgive_boxmod_boxf=letwidtha=Box.width(give_boxa)inletheighta=Box.height(give_boxa)inletset_pospa=mod_boxa(Box.centerp(give_boxa))inf~width~height~set_posletwrap_corner_boxgive_boxf=letcornerpa=Box.cornerp(give_boxa)inf~cornermoduleOverlays=structtypeinterval=|Betofint*int(** \[|a,b|\] *)|Befofint(** \]|-oo,a|\] *)|Aftofint(** \[|a,+oo|\[ *)|Nev(** emptyset *)|Alw(** N *)letin_intervali=function|Bet(x,y)whenx<=i&&i<=y->true|Befxwheni<=x->true|Aftxwhenx<=i->true|Alw->true|_->falseletmin_intervaln=function|Bet(a,_)->minan|Befa->minan|Afta->minan|_->nletmax_intervaln=function|Bet(_,b)->maxbn|Befb->maxbn|Aftb->maxbn|_->nletmin_treeto_intervalt=letfna=min_intervaln(to_intervala)infoldfmax_inttletmax_treeto_intervalt=letfna=max_intervaln(to_intervala)infoldfmin_intttype'aspec=(interval*'a)listletrecassoqn=function|[]->raiseNot_found|(i,a)::_whenin_intervalni->a|_::l->assoqnlletmaxto_num=function|[]->invalid_arg"Tree_adv.Overlays.width"|(_,a)::l->List.fold_left(funw(_,p)->Num.maxnw(to_nump))(to_numa)lletset_possppos=List.map(fun(i,b)->(i,spposb))endmoduleOverlays_Boxlike(X:Signature.Boxlike):Signature.Boxlikewithtypet=X.tOverlays.spec=structopenOverlaystypet=X.tspecletwidth=maxX.widthletheight=maxX.heightletset_pos=set_posX.set_posend