@@ -83962,27 +83962,26 @@ and statement_desc =
83962
83962
* Js_closure.t
83963
83963
| Continue of label
83964
83964
| Break (* only used when inline a fucntion *)
83965
- | Return of return_expression (* Here we need track back a bit ?, move Return to Function ...
83965
+ | Return of expression (* Here we need track back a bit ?, move Return to Function ...
83966
83966
Then we can only have one Return, which is not good *)
83967
- | Int_switch of expression * int case_clause list * block option
83968
- | String_switch of expression * string case_clause list * block option
83969
- | Throw of expression
83970
- | Try of block * (exception_ident * block) option * block option
83971
- | Debugger
83972
- and return_expression = {
83973
- (* since in ocaml, it's expression oriented langauge, [return] in
83967
+ (* since in ocaml, it's expression oriented langauge, [return] in
83974
83968
general has no jumps, it only happens when we do
83975
83969
tailcall conversion, in that case there is a jump.
83976
83970
However, currently a single [break] is good to cover
83977
83971
our compilation strategy
83978
-
83979
83972
Attention: we should not insert [break] arbitrarily, otherwise
83980
83973
it would break the semantics
83981
83974
A more robust signature would be
83982
83975
{[ goto : label option ; ]}
83983
83976
*)
83984
- return_value : expression
83985
- }
83977
+
83978
+ | Int_switch of expression * int case_clause list * block option
83979
+ | String_switch of expression * string case_clause list * block option
83980
+ | Throw of expression
83981
+ | Try of block * (exception_ident * block) option * block option
83982
+ | Debugger
83983
+
83984
+
83986
83985
83987
83986
and expression = {
83988
83987
expression_desc : expression_desc;
@@ -84668,7 +84667,7 @@ class virtual fold =
84668
84667
let o = o#block _x_i4 in let o = o#unknown _x_i5 in o
84669
84668
| Continue _x -> let o = o#label _x in o
84670
84669
| Break -> o
84671
- | Return _x -> let o = o#return_expression _x in o
84670
+ | Return _x -> let o = o#expression _x in o
84672
84671
| Int_switch (_x, _x_i1, _x_i2) ->
84673
84672
let o = o#expression _x in
84674
84673
let o =
@@ -84865,6 +84864,16 @@ class virtual fold =
84865
84864
(* only used when inline a fucntion *)
84866
84865
(* Here we need track back a bit ?, move Return to Function ...
84867
84866
Then we can only have one Return, which is not good *)
84867
+ (* since in ocaml, it's expression oriented langauge, [return] in
84868
+ general has no jumps, it only happens when we do
84869
+ tailcall conversion, in that case there is a jump.
84870
+ However, currently a single [break] is good to cover
84871
+ our compilation strategy
84872
+ Attention: we should not insert [break] arbitrarily, otherwise
84873
+ it would break the semantics
84874
+ A more robust signature would be
84875
+ {[ goto : label option ; ]}
84876
+ *)
84868
84877
o#case_clause (fun o -> o#int))
84869
84878
_x_i1 in
84870
84879
let o = o#option (fun o -> o#block) _x_i2 in o
@@ -84887,8 +84896,6 @@ class virtual fold =
84887
84896
fun { statement_desc = _x; comment = _x_i1 } ->
84888
84897
let o = o#statement_desc _x in
84889
84898
let o = o#option (fun o -> o#string) _x_i1 in o
84890
- method return_expression : return_expression -> 'self_type =
84891
- fun { return_value = _x } -> let o = o#expression _x in o
84892
84899
method required_modules : required_modules -> 'self_type = o#unknown
84893
84900
method property_name : property_name -> 'self_type = o#unknown
84894
84901
method property_map : property_map -> 'self_type =
@@ -84987,18 +84994,7 @@ class virtual fold =
84987
84994
let o = o#required_modules _x_i1 in
84988
84995
let o = o#option (fun o -> o#string) _x_i2 in o
84989
84996
method case_clause :
84990
- (* since in ocaml, it's expression oriented langauge, [return] in
84991
- general has no jumps, it only happens when we do
84992
- tailcall conversion, in that case there is a jump.
84993
- However, currently a single [break] is good to cover
84994
- our compilation strategy
84995
-
84996
- Attention: we should not insert [break] arbitrarily, otherwise
84997
- it would break the semantics
84998
- A more robust signature would be
84999
- {[ goto : label option ; ]}
85000
- *)
85001
- 'a. ('self_type -> 'a -> 'self_type) -> 'a case_clause -> 'self_type =
84997
+ 'a. ('self_type -> 'a -> 'self_type) -> 'a case_clause -> 'self_type =
85002
84998
fun _f_a
85003
84999
{
85004
85000
switch_case = _x;
@@ -85413,9 +85409,9 @@ and eq_statement
85413
85409
| Exp b -> eq_expression a b
85414
85410
| _ -> false
85415
85411
end
85416
- | Return { return_value = a ; _} ->
85412
+ | Return a ->
85417
85413
begin match y0 with
85418
- | Return { return_value = b; _} ->
85414
+ | Return b ->
85419
85415
eq_expression a b
85420
85416
| _ -> false
85421
85417
end
@@ -87568,7 +87564,7 @@ let of_block ?comment ?e block : t =
87568
87564
| None -> block
87569
87565
| Some e ->
87570
87566
Ext_list.append block
87571
- [{J.statement_desc = Return {return_value = e } ;
87567
+ [{J.statement_desc = Return e ;
87572
87568
comment}]
87573
87569
end
87574
87570
, Js_fun_env.make 0)
@@ -88246,14 +88242,14 @@ and pp_function ~is_method
88246
88242
(l : Ident.t list) (b : J.block) (env : Js_fun_env.t ) : cxt =
88247
88243
match b with
88248
88244
| [ {statement_desc =
88249
- Return {return_value =
88245
+ Return
88250
88246
{expression_desc =
88251
88247
Call(({expression_desc = Var v ; _} as function_id),
88252
88248
ls ,
88253
88249
{arity = ( Full | NA as arity(* see #234*));
88254
88250
(* TODO: need a case to justify it*)
88255
88251
call_info =
88256
- (Call_builtin_runtime | Call_ml )})}}} ]
88252
+ (Call_builtin_runtime | Call_ml )})}}]
88257
88253
when
88258
88254
(* match such case:
88259
88255
{[ function(x,y){ return u(x,y) } ]}
@@ -89116,7 +89112,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
89116
89112
| Debugger -> debugger_nl f ; cxt
89117
89113
| Break -> break_nl f; cxt
89118
89114
89119
- | Return {return_value = e} ->
89115
+ | Return e ->
89120
89116
begin match e.expression_desc with
89121
89117
| Fun (is_method, l, b, env) ->
89122
89118
let cxt =
@@ -89213,10 +89209,10 @@ and function_body (cxt : cxt) f (b : J.block) : unit =
89213
89209
then_,
89214
89210
[{
89215
89211
statement_desc =
89216
- Return {return_value = { expression_desc = Undefined}} } ])
89212
+ Return {expression_desc = Undefined}} ])
89217
89213
->
89218
89214
ignore (statement false cxt f {s with statement_desc = If(bool,then_, [])} : cxt)
89219
- | Return {return_value = { expression_desc = Undefined } } -> ()
89215
+ | Return {expression_desc = Undefined } -> ()
89220
89216
| _ ->
89221
89217
ignore (statement false cxt f s : cxt)
89222
89218
end
@@ -100866,7 +100862,7 @@ module E = Js_exp_make
100866
100862
type t = J.statement
100867
100863
100868
100864
let return_stmt ?comment e : t =
100869
- {statement_desc = Return {return_value = e; } ; comment}
100865
+ {statement_desc = Return e ; comment}
100870
100866
100871
100867
100872
100868
let empty_stmt : t =
@@ -101065,8 +101061,8 @@ let if_ ?comment ?declaration ?else_ (e : J.expression) (then_ : J.block) : t
101065
101061
| [], [] -> exp e
101066
101062
| [], _ ->
101067
101063
aux ?comment (E.not e) ifnot [] (*Make sure no infinite loop*)
101068
- | [ {statement_desc = Return {return_value = ret_ifso; _} ; _}],
101069
- [ {statement_desc = Return {return_value = ret_ifnot; _} ; _}]
101064
+ | [ {statement_desc = Return ret_ifso; _}],
101065
+ [ {statement_desc = Return ret_ifnot; _}]
101070
101066
->
101071
101067
return_stmt (E.econd e ret_ifso ret_ifnot )
101072
101068
| _, [{statement_desc = Return _ }]
@@ -102845,7 +102841,7 @@ class virtual map =
102845
102841
in ForRange (_x, _x_i1, _x_i2, _x_i3, _x_i4, _x_i5)
102846
102842
| Continue _x -> let _x = o#label _x in Continue _x
102847
102843
| Break -> Break
102848
- | Return _x -> let _x = o#return_expression _x in Return _x
102844
+ | Return _x -> let _x = o#expression _x in Return _x
102849
102845
| Int_switch (_x, _x_i1, _x_i2) ->
102850
102846
let _x = o#expression _x in
102851
102847
let _x_i1 =
@@ -103042,6 +103038,16 @@ class virtual map =
103042
103038
(* only used when inline a fucntion *)
103043
103039
(* Here we need track back a bit ?, move Return to Function ...
103044
103040
Then we can only have one Return, which is not good *)
103041
+ (* since in ocaml, it's expression oriented langauge, [return] in
103042
+ general has no jumps, it only happens when we do
103043
+ tailcall conversion, in that case there is a jump.
103044
+ However, currently a single [break] is good to cover
103045
+ our compilation strategy
103046
+ Attention: we should not insert [break] arbitrarily, otherwise
103047
+ it would break the semantics
103048
+ A more robust signature would be
103049
+ {[ goto : label option ; ]}
103050
+ *)
103045
103051
o#case_clause (fun o -> o#int))
103046
103052
_x_i1 in
103047
103053
let _x_i2 = o#option (fun o -> o#block) _x_i2
@@ -103069,9 +103075,6 @@ class virtual map =
103069
103075
let _x = o#statement_desc _x in
103070
103076
let _x_i1 = o#option (fun o -> o#string) _x_i1
103071
103077
in { statement_desc = _x; comment = _x_i1; }
103072
- method return_expression : return_expression -> return_expression =
103073
- fun { return_value = _x } ->
103074
- let _x = o#expression _x in { return_value = _x; }
103075
103078
method required_modules : required_modules -> required_modules =
103076
103079
o#unknown
103077
103080
method property_name : property_name -> property_name = o#unknown
@@ -103192,18 +103195,7 @@ class virtual map =
103192
103195
let _x_i2 = o#option (fun o -> o#string) _x_i2
103193
103196
in { program = _x; modules = _x_i1; side_effect = _x_i2; }
103194
103197
method case_clause :
103195
- (* since in ocaml, it's expression oriented langauge, [return] in
103196
- general has no jumps, it only happens when we do
103197
- tailcall conversion, in that case there is a jump.
103198
- However, currently a single [break] is good to cover
103199
- our compilation strategy
103200
-
103201
- Attention: we should not insert [break] arbitrarily, otherwise
103202
- it would break the semantics
103203
- A more robust signature would be
103204
- {[ goto : label option ; ]}
103205
- *)
103206
- 'a 'a_out.
103198
+ 'a 'a_out.
103207
103199
('self_type -> 'a -> 'a_out) -> 'a case_clause -> 'a_out case_clause =
103208
103200
fun _f_a
103209
103201
{
@@ -103349,12 +103341,12 @@ let flatten_map =
103349
103341
| _ ->
103350
103342
assert false
103351
103343
end
103352
- | Return ( {return_value = { expression_desc = Cond (a,b,c); comment}})
103344
+ | Return { expression_desc = Cond (a,b,c); comment}
103353
103345
->
103354
103346
{ statement_desc = If (a, [self#statement (S.return_stmt b)],
103355
103347
[ self#statement (S.return_stmt c)]); comment}
103356
103348
103357
- | Return ({return_value = { expression_desc = Seq _; _} as v} ) ->
103349
+ | Return ({expression_desc = Seq _; _} as v) ->
103358
103350
let block = Js_analyzer.rev_flatten_seq v in
103359
103351
begin match block with
103360
103352
| {statement_desc = Exp last_one ; _} :: rest_rev
@@ -104416,9 +104408,9 @@ let subst (export_set : Set_ident.t) stats =
104416
104408
end
104417
104409
104418
104410
| [{statement_desc =
104419
- Return {return_value =
104411
+ Return
104420
104412
{expression_desc =
104421
- Call({expression_desc = Var (Id id)},args,_info)}} } as st ]
104413
+ Call({expression_desc = Var (Id id)},args,_info)} } as st ]
104422
104414
->
104423
104415
begin match Hash_ident.find_opt stats id with
104424
104416
@@ -104450,9 +104442,8 @@ let subst (export_set : Set_ident.t) stats =
104450
104442
end
104451
104443
104452
104444
| [{statement_desc =
104453
- Return {return_value =
104454
- {expression_desc =
104455
- Call({expression_desc = Fun (false, params, block, env)},args,_info)}} } ]
104445
+ Return {expression_desc =
104446
+ Call({expression_desc = Fun (false, params, block, env)},args,_info)}} ]
104456
104447
104457
104448
when Ext_list.same_length params args
104458
104449
->
0 commit comments