Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jsexplain
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Verified Software
jsexplain
Commits
e1bf9e6e
Commit
e1bf9e6e
authored
9 years ago
by
Alan Schmitt
Committed by
Thomas Wood
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
better printing of returns
parent
ba2c170b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
generator/js_of_ast.ml
+3
-18
3 additions, 18 deletions
generator/js_of_ast.ml
with
3 additions
and
18 deletions
generator/js_of_ast.ml
+
3
−
18
View file @
e1bf9e6e
...
@@ -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>@[<
h
v 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; "
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment