Skip to content
Snippets Groups Projects
Commit e1bf9e6e authored by Alan Schmitt's avatar Alan Schmitt Committed by Thomas Wood
Browse files

better printing of returns

parent ba2c170b
No related branches found
No related tags found
No related merge requests found
...@@ -131,16 +131,6 @@ let map_cstr_fields ?loc bind (cstr : constructor_description) elements = ...@@ -131,16 +131,6 @@ let map_cstr_fields ?loc bind (cstr : constructor_description) elements =
let ppf_lambda_wrap s = let ppf_lambda_wrap s =
Printf.sprintf "(function () {@;<1 2>@[<v 0>%s@]@,}())@," s Printf.sprintf "(function () {@;<1 2>@[<v 0>%s@]@,}())@," s
let ppf_branch case binders expr =
Printf.sprintf "%s: @[<v 0>%s@,return %s;@]"
case binders expr
let ppf_let_in decl exp =
let s =
Printf.sprintf "%s@,return %s;"
decl exp
in ppf_lambda_wrap s
let ppf_function args body= let ppf_function args body=
(L.log_line (Printf.sprintf "function (%s) {" args) [L.Enter; (L.CreateCtx args)]) ^ (Printf.sprintf "@;<1 2>return@[<hov 2>@ %s;@]@,}" body) (L.log_line (Printf.sprintf "function (%s) {" args) [L.Enter; (L.CreateCtx args)]) ^ (Printf.sprintf "@;<1 2>return@[<hov 2>@ %s;@]@,}" body)
...@@ -166,11 +156,6 @@ let ppf_array values = ...@@ -166,11 +156,6 @@ let ppf_array values =
let ppf_tuple = ppf_array let ppf_tuple = ppf_array
let ppf_ifthen cond iftrue =
Printf.sprintf "(function () {@[<v 2>if (%s) {@,return %s;@,}@]@,})()"
cond iftrue
let ppf_sequence exp1 exp2 = let ppf_sequence exp1 exp2 =
Printf.sprintf "%s;@,%s" Printf.sprintf "%s;@,%s"
exp1 exp2 exp1 exp2
...@@ -331,7 +316,7 @@ let ctx_initial = ...@@ -331,7 +316,7 @@ let ctx_initial =
(*--------- if ---------*) (*--------- if ---------*)
let ppf_ifthenelse arg iftrue iffalse = let ppf_ifthenelse arg iftrue iffalse =
Printf.sprintf "@[<v 0>if (%s) {@;<1 2>@[<v 0>%s@]@,} else {@;<1 2>@[<v 0>%s@]@,}@]" Printf.sprintf "@[<v 0>if (%s) {@;<1 2>@[<v 0>%s@]@,} else {@;<1 2>@[<hv 0>%s@]@,}@]"
arg iftrue iffalse arg iftrue iffalse
let generate_logged_if loc ctx sintro sarg siftrue siffalse = let generate_logged_if loc ctx sintro sarg siftrue siffalse =
...@@ -488,9 +473,9 @@ let generate_logged_return loc ctx sbody = ...@@ -488,9 +473,9 @@ let generate_logged_return loc ctx sbody =
match !current_mode with match !current_mode with
| Mode_cmi -> assert false | Mode_cmi -> assert false
| Mode_unlogged -> | Mode_unlogged ->
Printf.sprintf "return %s;" sbody Printf.sprintf "@[<hv 2>return@ %s;@]" sbody
| Mode_line_token -> | Mode_line_token ->
Printf.sprintf "%sreturn %s;%s" token_start sbody token_stop Printf.sprintf "@[<hv 2>%sreturn@ %s;%s@]" token_start sbody token_stop
| Mode_logged -> | Mode_logged ->
let id = id_fresh "_return_" in let id = id_fresh "_return_" in
Printf.sprintf "var %s = %s;@,log_event(%s, ctx_push(%s, [{key: \"#RETURN_VALUE#\", val: %s}]), \"return\");@,return %s; " Printf.sprintf "var %s = %s;@,log_event(%s, ctx_push(%s, [{key: \"#RETURN_VALUE#\", val: %s}]), \"return\");@,return %s; "
......
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