1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465(* Yoann Padioleau
*
* Copyright (C) 2018 Yoann Padioleau
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation, with the
* special exception on linking described in file license.txt.
*
* This library 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 file
* license.txt for more details.
*)moduleG=Graph_codemoduleJ=Json_type(*****************************************************************************)(* Prelude *)(*****************************************************************************)(*****************************************************************************)(* Helpers *)(*****************************************************************************)letstring_of_entity_kindkind=Entity_code.string_of_entity_kindkindletjson_short_of_node(str,kind)=J.Array[J.Stringstr;J.String(string_of_entity_kindkind);]letjson_of_nodeg(str,kind)=J.Object["name_kind",json_short_of_node(str,kind);"location",J.String(tryG.file_of_node(str,kind)g(* 'Dir' entities have no location for example *)withNot_found->"UNKNOWN LOCATION");](*****************************************************************************)(* Main entry point *)(*****************************************************************************)letgraph_to_jsong=J.Object["nodes",J.Array(G.all_nodesg|>List.map(json_of_nodeg));"edges_Use",J.Array(G.all_use_edgesg|>List.map(fun(src,dst)->J.Object["src",json_short_of_nodesrc;"dst",json_short_of_nodedst;]));"edges_Has",J.String"TODO";]