Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file link_js.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2017 Hugo Heuzard
*
* 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!StdlibletsourceMappingURL="//# sourceMappingURL="letsourceMappingURL_base64="//# sourceMappingURL=data:application/json;base64,"typeaction=|Keep|Drop|Build_infoofBuild_info.t|Source_mapofSource_map.tletaction~resolve_sourcemap_url~drop_source_mapfileline=letprefix_kind=matchString.is_prefix~prefix:sourceMappingURLlinewith|false->(matchBuild_info.parselinewith|Somebi->`Build_infobi|None->`Other)|true->(matchString.is_prefix~prefix:sourceMappingURL_base64linewith|true->`Json_base64(String.lengthsourceMappingURL_base64)|false->`Url(String.lengthsourceMappingURL))inmatchprefix_kind,drop_source_mapwith|`Other,(true|false)->Keep|`Build_infobi,_->Build_infobi|(`Json_base64_|`Url_),true->Drop|`Json_base64offset,false->Source_map(Source_map_io.of_string(Base64.decode_exn~off:offsetline))|`Url_,falsewhennotresolve_sourcemap_url->Drop|`Urloffset,false->leturl=String.subline~pos:offset~len:(String.lengthline-offset)inletbase=Filename.dirnamefileinletic=open_in(Filename.concatbaseurl)inletl=in_channel_lengthicinletcontent=really_input_stringiclinclose_inic;Source_map(Source_map_io.of_stringcontent)letlink~output~files~resolve_sourcemap_url~source_map=letsm=ref[]inletline_offset=ref0inletbuild_info=refNoneinletnew_line()=output_stringoutput"\n";incrline_offsetintryList.iter~f:(funfile->letbuild_info_for_file=refNoneinletic=open_infilein(tryoutput_stringoutput(Printf.sprintf"//# 1 %S"file);new_line();letstart_line=!line_offsetinwhiletruedoletline=input_lineicinmatchaction~resolve_sourcemap_url~drop_source_map:Poly.(source_map=None)filelinewith|Keep->output_stringoutputline;new_line()|Build_infobi->(match!build_info_for_filewith|None->build_info_for_file:=Somebi|Somebi'->build_info_for_file:=Some(Build_info.mergefilebi'filebi))|Drop->()|Source_mapx->sm:=(start_line,x)::!smdonewithEnd_of_file->());close_inic;new_line();match!build_info,!build_info_for_filewith|None,None->()|Some_,None->()|None,Somebuild_info_for_file->build_info:=Some(file,build_info_for_file)|Some(first_file,bi),Somebuild_info_for_file->build_info:=Some(first_file,Build_info.mergefirst_filebifilebuild_info_for_file))files;matchsource_mapwith|None->()|Some(file,init_sm)->(matchSource_map.merge((0,init_sm)::List.rev!sm)with|None->()|Somesm->((* preserve some info from [init_sm] *)letsm={smwithversion=init_sm.version;file=init_sm.file;sourceroot=init_sm.sourceroot}inmatchfilewith|None->letdata=Source_map_io.to_stringsminlets=sourceMappingURL_base64^Base64.encode_exndatainoutput_stringoutputs|Somefile->Source_map_io.to_filesmfile;lets=sourceMappingURL^Filename.basenamefileinoutput_stringoutputs))withBuild_info.Incompatible_build_info{key;first=f1,v1;second=f2,v2}->letstring_of_v=function|None->"<empty>"|Somev->vinfailwith(Printf.sprintf"Incompatible build info detected while linking.\n - %s: %s=%s\n - %s: %s=%s"f1key(string_of_vv1)f2key(string_of_vv2))