123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153letget_descx=#ifOCAML_VERSION>=(4,14,0)Types.get_descx#elsex.Types.desc#endiflettoploop_get_directivename=#ifOCAML_VERSION>=(4,13,0)Toploop.get_directivename#elsetrySome(Hashtbl.findToploop.directive_tablename)withNot_found->None#endiflet toploop_all_directive_names()=#ifOCAML_VERSION>=(4,13,0)Toploop.all_directive_names()#elseHashtbl.fold (fundir_acc->dir::acc)Toploop.directive_table[]#endifletget_load_path ()=#ifOCAML_VERSION >=(5,2,0)let{Load_path.visible;hidden}=Load_path.get_paths ()invisible@hidden#elseLoad_path.get_paths()#endifletset_load_pathvisible=#ifOCAML_VERSION >=(5,2,0)Load_path.init~auto_include:Load_path.no_auto_include~visible~hidden:[]#elifOCAML_VERSION>=(5,0,0)Load_path.init~auto_include:Load_path.no_auto_includevisible#elseLoad_path.initvisible#endiflettoploop_use_silentlyfmtname=#ifOCAML_VERSION>=(4,14,0)Toploop.use_silentlyfmt(matchnamewith""->Stdin|_->Filename)#elseToploop.use_silentlyfmtname#endiflettoploop_set_paths()=#ifOCAML_VERSION>=(5,0,0)Toploop.set_paths~auto_include:Load_path.no_auto_include()#elseToploop.set_paths()#endiflettoploop_load_fileppffn=#ifOCAML_VERSION >=(4,13,0)Toploop.load_fileppffn#elseTopdirs.load_fileppffn#endif(** Returns whether the given path is persistent. *)letrecis_persistent_path=function|Path.Pidentid->Ident.persistentid|Path.Pdot(p,_)->is_persistent_pathp|Path.Papply(_,p)->is_persistent_pathp#ifOCAML_VERSION>=(5,1,0)|Path.Pextra_ty(p,_)->is_persistent_pathp#endif#ifOCAML_VERSION>=(5,2,0)letinline_code=#ifOCAML_VERSION>=(5,3,0)(Format_doc.compatMisc.Style.inline_code)#elseMisc.Style.inline_code#endif#endifletinvalid_package_error_to_stringerr=#ifOCAML_VERSION>=(5,2,0)(* NOTE: from https://github.com/ocaml/ocaml/blob/9b059b1e7a66e9d2f04d892a4de34c418cd96f69/parsing/parse.ml#L149 *)letinvalidppfipt =matchiptwith|Syntaxerr.Parameterized_types->Format.fprintfppf"parametrized types are not supported"|Constrained_types->Format.fprintfppf"constrained types are not supported"|Private_types->Format.fprintfppf"private types are not supported"|Not_with_type->Format.fprintfppf"only %a constraints are supported"inline_code"with type t="|Neither_identifier_nor_with_type->Format.fprintfppf"onlymodule type identifier and %a constraints are supported"inline_code "with type"inletbuf=Buffer.create128 inletfmt=Format.formatter_of_bufferbufinFormat.fprintffmt"Invalid package type: %a%!"invaliderr;Buffer.contentsbuf#elseerr#endifmoduleExp=structopenAst_helper#ifOCAML_VERSION >=(5,2,0)openParsetreeletfun_~locpe=let args=[{pparam_loc=loc;pparam_desc=Pparam_val(Nolabel,None,p);}]in(Exp.function_argsNone(Pfunction_bodye))#elseletfun_~locpe=Exp.fun_~locNolabelNonepe#endifendletabstract_type_kind =#if OCAML_VERSION>=(5,2,0)Types.(Type_abstractDefinition)#elseTypes.Type_abstract#endifletfind_in_path_normalized=#ifOCAML_VERSION >=(5,2,0)Misc.find_in_path_normalized#elseMisc.find_in_path_uncap#endifletvisible_paths_for_cmt_infos(cmt_infos:Cmt_format.cmt_infos)=#ifOCAML_VERSION>=(5,2,0)cmt_infos.cmt_loadpath.visible#elsecmt_infos.cmt_loadpath#endifletadd_cmi_hookf=let default_load=!Persistent_env.Persistent_signature.loadin#ifOCAML_VERSION>=(5,2,0)letload~allow_hidden~unit_name=letres=default_load~unit_name~allow_hiddenin#elseletload~unit_name=letres=default_load~unit_namein#endif(matchreswithNone->()|Somex->fx.cmi);resinPersistent_env.Persistent_signature.load:=load