12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485openCommonmoduleV=Visitor_c(*****************************************************************************)(* Subsystem testing *)(*****************************************************************************)lettest_dump_cilfile=letast=Parse_c.parse_programfileinletenv={Datalog_c.(* only thing that actually matters *)locals=ref[];globals=Graph_code.create();globals_renames=(funx->x);(* not actually used by instrs_of_expr *)scope="";c_file_readable="";long_format=false;facts=ref[];}in(* todo: actually need to build a correct set of locals!
* also when do int v = ...; we just see the ... in kexpr,
* and so there will be a _v_xx = ... but not the = _v_xx;
*)letvisitor=V.mk_visitor{V.default_visitorwithV.kexpr=(fun_ke->letinstrs=Datalog_c.instrs_of_exprenveininstrs|>List.iter(funinstr->letv=Meta_ast_cil.vof_instrinstrinlets=Ocaml.string_of_vvinprs));}invisitor(Ast_c.Programast);()lettest_dataflow_cfile=letfile=Common.fullpathfileinletroot=Sys.getcwd()|>Common.fullpathinGraph_code_c.facts:=Some(ref[]);Datalog_c.long_format:=false;let_g=Graph_code_c.build~verbose:falseroot[file]inletfacts=List.rev!(Common2.some(!Graph_code_c.facts))inCommon2.pr2_xxxxxxxxxxxxxxxxx();(* debug *)facts|>List.iter(funfact->pr2(Datalog_code.string_of_factfact));Common2.pr2_xxxxxxxxxxxxxxxxx();letfacts_file="/tmp/facts.dl"inCommon.with_open_outfilefacts_file(fun(pr_no_nl,_chan)->letprs=pr_no_nl(s^".\n")infacts|>List.iter(funfact->pr(Datalog_code.string_of_factfact)););letlogic_file=Filename.concatConfig_pfff.path"h_program-lang/datalog_code.dl"inletfinal_file="/tmp/datalog.dl"inletcmd=spf"cat %s %s > %s"facts_filelogic_filefinal_fileinCommon.command2cmd;(* using http://www.ccs.neu.edu/home/ramsdell/tools/datalog/datalog.html *)letcmd=spf"datalog %s | sort"final_fileinCommon.command2cmd;()(*****************************************************************************)(* Main entry for Arg *)(*****************************************************************************)letactions()=["-dump_cil"," <file>",Common.mk_action_1_argtest_dump_cil;"-dataflow_c"," <file>",Common.mk_action_1_argtest_dataflow_c;]