123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107(* 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!Stdlibtypet=string*intexceptionBad_magic_numberofstringexceptionBad_magic_versionoftletsize=12letkind_of_string=function|"Caml1999X"->"exe"|"Caml1999I"->"cmi"|"Caml1999O"->"cmo"|"Caml1999A"->"cma"|"Caml1999Y"->"cmx"|"Caml1999Z"->"cmxa"|"Caml2007D"->"cmxs"|"Caml2012T"->"cmt"|"Caml1999M"->"impl"|"Caml1999N"->"intf"|_->raiseNot_foundletof_strings=tryifString.lengths<>sizethenraiseNot_found;letkind=String.subs~pos:0~len:9inletv=String.subs~pos:9~len:3inlet_=kind_of_stringkindinkind,int_of_stringvwith_->raise(Bad_magic_numbers)letkind(s,_)=matchkind_of_stringswith|"exe"->`Exe|"cmo"->`Cmo|"cma"->`Cma|other->`Otherotherletto_string(k,v)=Printf.sprintf"%s%03d"kvletcompare(p1,n1)(p2,n2)=ifnot(String.equalp1p2)thenraiseNot_found;comparen1n2letequalab=compareab=0letcurrent_exe=letv=matchOcaml_version.vwith|`V4_02|`V4_03|`V4_04->11|`V4_06->11|`V4_07->23|`V4_08->25|`V4_09->26|`V4_10->27in"Caml1999X",vletcurrent_cmo=letv=matchOcaml_version.vwith|`V4_02->10|`V4_03|`V4_04->11|`V4_06->22|`V4_07->23|`V4_08->25|`V4_09->26|`V4_10->27in"Caml1999O",vletcurrent_cma=letv=matchOcaml_version.vwith|`V4_02->11|`V4_03|`V4_04->12|`V4_06->22|`V4_07->23|`V4_08->25|`V4_09->26|`V4_10->27in"Caml1999A",vletcurrent=function|`Exe->current_exe|`Cmo->current_cmo|`Cma->current_cma