Skip to content

Commit 155ae3c

Browse files
committed
snapshot
1 parent bd26419 commit 155ae3c

File tree

3 files changed

+153
-180
lines changed

3 files changed

+153
-180
lines changed

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 51 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -83962,27 +83962,26 @@ and statement_desc =
8396283962
* Js_closure.t
8396383963
| Continue of label
8396483964
| 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 ...
8396683966
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
8397483968
general has no jumps, it only happens when we do
8397583969
tailcall conversion, in that case there is a jump.
8397683970
However, currently a single [break] is good to cover
8397783971
our compilation strategy
83978-
8397983972
Attention: we should not insert [break] arbitrarily, otherwise
8398083973
it would break the semantics
8398183974
A more robust signature would be
8398283975
{[ goto : label option ; ]}
8398383976
*)
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+
8398683985

8398783986
and expression = {
8398883987
expression_desc : expression_desc;
@@ -84668,7 +84667,7 @@ class virtual fold =
8466884667
let o = o#block _x_i4 in let o = o#unknown _x_i5 in o
8466984668
| Continue _x -> let o = o#label _x in o
8467084669
| Break -> o
84671-
| Return _x -> let o = o#return_expression _x in o
84670+
| Return _x -> let o = o#expression _x in o
8467284671
| Int_switch (_x, _x_i1, _x_i2) ->
8467384672
let o = o#expression _x in
8467484673
let o =
@@ -84865,6 +84864,16 @@ class virtual fold =
8486584864
(* only used when inline a fucntion *)
8486684865
(* Here we need track back a bit ?, move Return to Function ...
8486784866
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+
*)
8486884877
o#case_clause (fun o -> o#int))
8486984878
_x_i1 in
8487084879
let o = o#option (fun o -> o#block) _x_i2 in o
@@ -84887,8 +84896,6 @@ class virtual fold =
8488784896
fun { statement_desc = _x; comment = _x_i1 } ->
8488884897
let o = o#statement_desc _x in
8488984898
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
8489284899
method required_modules : required_modules -> 'self_type = o#unknown
8489384900
method property_name : property_name -> 'self_type = o#unknown
8489484901
method property_map : property_map -> 'self_type =
@@ -84987,18 +84994,7 @@ class virtual fold =
8498784994
let o = o#required_modules _x_i1 in
8498884995
let o = o#option (fun o -> o#string) _x_i2 in o
8498984996
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 =
8500284998
fun _f_a
8500384999
{
8500485000
switch_case = _x;
@@ -85413,9 +85409,9 @@ and eq_statement
8541385409
| Exp b -> eq_expression a b
8541485410
| _ -> false
8541585411
end
85416-
| Return { return_value = a ; _} ->
85412+
| Return a ->
8541785413
begin match y0 with
85418-
| Return { return_value = b; _} ->
85414+
| Return b ->
8541985415
eq_expression a b
8542085416
| _ -> false
8542185417
end
@@ -87568,7 +87564,7 @@ let of_block ?comment ?e block : t =
8756887564
| None -> block
8756987565
| Some e ->
8757087566
Ext_list.append block
87571-
[{J.statement_desc = Return {return_value = e } ;
87567+
[{J.statement_desc = Return e ;
8757287568
comment}]
8757387569
end
8757487570
, Js_fun_env.make 0)
@@ -88246,14 +88242,14 @@ and pp_function ~is_method
8824688242
(l : Ident.t list) (b : J.block) (env : Js_fun_env.t ) : cxt =
8824788243
match b with
8824888244
| [ {statement_desc =
88249-
Return {return_value =
88245+
Return
8825088246
{expression_desc =
8825188247
Call(({expression_desc = Var v ; _} as function_id),
8825288248
ls ,
8825388249
{arity = ( Full | NA as arity(* see #234*));
8825488250
(* TODO: need a case to justify it*)
8825588251
call_info =
88256-
(Call_builtin_runtime | Call_ml )})}}}]
88252+
(Call_builtin_runtime | Call_ml )})}}]
8825788253
when
8825888254
(* match such case:
8825988255
{[ function(x,y){ return u(x,y) } ]}
@@ -89116,7 +89112,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
8911689112
| Debugger -> debugger_nl f ; cxt
8911789113
| Break -> break_nl f; cxt
8911889114

89119-
| Return {return_value = e} ->
89115+
| Return e ->
8912089116
begin match e.expression_desc with
8912189117
| Fun (is_method, l, b, env) ->
8912289118
let cxt =
@@ -89213,10 +89209,10 @@ and function_body (cxt : cxt) f (b : J.block) : unit =
8921389209
then_,
8921489210
[{
8921589211
statement_desc =
89216-
Return {return_value = {expression_desc = Undefined}} }])
89212+
Return {expression_desc = Undefined}} ])
8921789213
->
8921889214
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 } -> ()
8922089216
| _ ->
8922189217
ignore (statement false cxt f s : cxt)
8922289218
end
@@ -100866,7 +100862,7 @@ module E = Js_exp_make
100866100862
type t = J.statement
100867100863

100868100864
let return_stmt ?comment e : t =
100869-
{statement_desc = Return {return_value = e; } ; comment}
100865+
{statement_desc = Return e; comment}
100870100866

100871100867

100872100868
let empty_stmt : t =
@@ -101065,8 +101061,8 @@ let if_ ?comment ?declaration ?else_ (e : J.expression) (then_ : J.block) : t
101065101061
| [], [] -> exp e
101066101062
| [], _ ->
101067101063
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; _}]
101070101066
->
101071101067
return_stmt (E.econd e ret_ifso ret_ifnot )
101072101068
| _, [{statement_desc = Return _ }]
@@ -102845,7 +102841,7 @@ class virtual map =
102845102841
in ForRange (_x, _x_i1, _x_i2, _x_i3, _x_i4, _x_i5)
102846102842
| Continue _x -> let _x = o#label _x in Continue _x
102847102843
| 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
102849102845
| Int_switch (_x, _x_i1, _x_i2) ->
102850102846
let _x = o#expression _x in
102851102847
let _x_i1 =
@@ -103042,6 +103038,16 @@ class virtual map =
103042103038
(* only used when inline a fucntion *)
103043103039
(* Here we need track back a bit ?, move Return to Function ...
103044103040
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+
*)
103045103051
o#case_clause (fun o -> o#int))
103046103052
_x_i1 in
103047103053
let _x_i2 = o#option (fun o -> o#block) _x_i2
@@ -103069,9 +103075,6 @@ class virtual map =
103069103075
let _x = o#statement_desc _x in
103070103076
let _x_i1 = o#option (fun o -> o#string) _x_i1
103071103077
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; }
103075103078
method required_modules : required_modules -> required_modules =
103076103079
o#unknown
103077103080
method property_name : property_name -> property_name = o#unknown
@@ -103192,18 +103195,7 @@ class virtual map =
103192103195
let _x_i2 = o#option (fun o -> o#string) _x_i2
103193103196
in { program = _x; modules = _x_i1; side_effect = _x_i2; }
103194103197
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.
103207103199
('self_type -> 'a -> 'a_out) -> 'a case_clause -> 'a_out case_clause =
103208103200
fun _f_a
103209103201
{
@@ -103349,12 +103341,12 @@ let flatten_map =
103349103341
| _ ->
103350103342
assert false
103351103343
end
103352-
| Return ( {return_value = {expression_desc = Cond (a,b,c); comment}})
103344+
| Return {expression_desc = Cond (a,b,c); comment}
103353103345
->
103354103346
{ statement_desc = If (a, [self#statement (S.return_stmt b)],
103355103347
[ self#statement (S.return_stmt c)]); comment}
103356103348

103357-
| Return ({return_value = {expression_desc = Seq _; _} as v}) ->
103349+
| Return ({expression_desc = Seq _; _} as v) ->
103358103350
let block = Js_analyzer.rev_flatten_seq v in
103359103351
begin match block with
103360103352
| {statement_desc = Exp last_one ; _} :: rest_rev
@@ -104416,9 +104408,9 @@ let subst (export_set : Set_ident.t) stats =
104416104408
end
104417104409

104418104410
| [{statement_desc =
104419-
Return {return_value =
104411+
Return
104420104412
{expression_desc =
104421-
Call({expression_desc = Var (Id id)},args,_info)}} } as st ]
104413+
Call({expression_desc = Var (Id id)},args,_info)} } as st ]
104422104414
->
104423104415
begin match Hash_ident.find_opt stats id with
104424104416

@@ -104450,9 +104442,8 @@ let subst (export_set : Set_ident.t) stats =
104450104442
end
104451104443

104452104444
| [{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)}} ]
104456104447

104457104448
when Ext_list.same_length params args
104458104449
->

0 commit comments

Comments
 (0)