diff --git a/generator/log.ml b/generator/log.ml index 8862bc6f2429cea5eba92b07999598e7ad4b8b7b..58d3810f012e8610b0a027146680767cf4f0fe1f 100644 --- a/generator/log.ml +++ b/generator/log.ml @@ -117,21 +117,10 @@ 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) 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 *) -(* TODO: Handle skipping of case where return does not contain function evaluation. (By regexp? No Brackets?) *) -let ppf_return_wrap l s = - let funccall = List.hd @@ Str.split (Str.regexp "\n?.*return ") s in - Format.sprintf "return (function () {@;<1 2>@[<v 1>\ - log_custom({line: %d, type: \"enter\"});\ - @,var res = %s\ - @,log_custom({line: %d, type: \"exit\"});\ - @,return res; - @]}());@,@," l funccall l + (* 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 let add_log_info s = let buf = Buffer.create 16 in @@ -164,7 +153,7 @@ let ppf_return_wrap l s = | Redef _ -> "" (* Actually not used *) | Del _ -> "" (* Actually not used *) in Buffer.add_string buf log_info; - Buffer.add_string buf (ppf_return_wrap (i+1) str); (* i is line number of line preceding return *) + Buffer.add_string buf str; (* i is line number of line preceding return *) aux (i + 1) xs in aux 0 ls; Buffer.contents buf