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

Revert return wrap

The method of hooking on to previously marked log elements causes issues and unmarked entry points. I need to redo this properly from js_of_ast with marking of returns to log directly.
parent 6b24abe8
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
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