Skip to content
Snippets Groups Projects
Commit ee0620ab authored by Cesar Roux Dit Buisson's avatar Cesar Roux Dit Buisson
Browse files

Add run_trm wrap around logged version

Unfortunately pretty formatting and indentation doesn't work correctly, though this doesn't stop it from working.
parent 53d7d13e
No related branches found
No related tags found
No related merge requests found
...@@ -117,6 +117,11 @@ struct ...@@ -117,6 +117,11 @@ struct
let lines_list = snd @@ List.fold_left (fun (st, acc) ed -> (ed, String.sub s st (ed - st) :: acc)) (0, []) (end_line_markers s) let lines_list = snd @@ List.fold_left (fun (st, acc) ed -> (ed, String.sub s st (ed - st) :: acc)) (0, []) (end_line_markers s)
in append_token lines_list in append_token lines_list
(* Wrap the entire logged version in a callable run_trm function, and add a call to return run(code). *)
(* Assumes entry point called run *)
let ppf_run_wrap s =
Format.sprintf "function run_trm(code) {@;<1 2>@[<v 1>@,%s@,return run(code);@,}@]" s
(* Take a String in form of "\n return somefunctions(sas, ad);" and wrap it in order to allow log of function enter and exit *) (* Take a String in form of "\n return somefunctions(sas, ad);" and wrap it in order to allow log of function enter and exit *)
(* TODO: Handle skipping of case where return does not contain function evaluation. (By regexp? No Brackets?) *) (* TODO: Handle skipping of case where return does not contain function evaluation. (By regexp? No Brackets?) *)
let ppf_return_wrap l s = let ppf_return_wrap l s =
...@@ -126,7 +131,7 @@ let ppf_return_wrap l s = ...@@ -126,7 +131,7 @@ let ppf_return_wrap l s =
@,var res = %s\ @,var res = %s\
@,log_custom({line: %d, type: \"exit\"});\ @,log_custom({line: %d, type: \"exit\"});\
@,return res; @,return res;
@]@,}());@,@," l funccall l @]}());@,@," l funccall l
let add_log_info s = let add_log_info s =
let buf = Buffer.create 16 in let buf = Buffer.create 16 in
...@@ -166,7 +171,7 @@ let ppf_return_wrap l s = ...@@ -166,7 +171,7 @@ let ppf_return_wrap l s =
let logged_output s = let logged_output s =
let str_ppf = Format.str_formatter in let str_ppf = Format.str_formatter in
Format.fprintf str_ppf (Scanf.format_from_string s ""); Format.fprintf str_ppf (Scanf.format_from_string s "");
add_log_info (Format.flush_str_formatter ()) ppf_run_wrap (add_log_info (Format.flush_str_formatter ()))
(* let bad_output = Format.flush_str_formatter () in *) (* let bad_output = Format.flush_str_formatter () in *)
(* let pretty_output = global_replace lfs "\n" bad_output in *) (* let pretty_output = global_replace lfs "\n" bad_output in *)
(* add_log_info pretty_output *) (* add_log_info pretty_output *)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment