Skip to content

Commit e29009b

Browse files
committed
fix some bactracking behaviors, we need more rigorious refactoring to remove all cases
1 parent 7217de9 commit e29009b

File tree

5 files changed

+287
-46
lines changed

5 files changed

+287
-46
lines changed

jscomp/bin/whole_compiler.ml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92989,14 +92989,19 @@ and
9298992989
])
9299092990
end
9299192991
| Assign id ->
92992-
begin match
92992+
(*
92993+
#if BS_DEBUG then
92994+
let () = Ext_log.dwarn __LOC__ "\n@[[TIME:]Lifthenelse: %f@]@." (Sys.time () *. 1000.) in
92995+
#end
92996+
*)
92997+
(* match
9299392998
compile_lambda {cxt with st = NeedValue} t_br,
9299492999
compile_lambda {cxt with st = NeedValue} f_br with
9299593000
| {block = []; value = Some out1},
9299693001
{block = []; value = Some out2} ->
9299793002
(* Invariant: should_return is false *)
9299893003
Js_output.make [S.assign id (E.econd e out1 out2)]
92999-
| _, _ ->
93004+
| _, _ -> *)
9300093005
let then_output =
9300193006
Js_output.to_block @@
9300293007
(compile_lambda cxt t_br) in
@@ -93008,14 +93013,11 @@ and
9300893013
then_output
9300993014
~else_:else_output
9301093015
])
93011-
end
9301293016
| EffectCall ->
9301393017
begin match should_return,
9301493018
compile_lambda {cxt with st = NeedValue} t_br,
9301593019
compile_lambda {cxt with st = NeedValue} f_br with
93016-
| True _, {block = []; value = Some out1},
93017-
{block = []; value = Some out2} ->
93018-
Js_output.make [S.return (E.econd e out1 out2)] ~finished:True
93020+
9301993021
(* see PR#83 *)
9302093022
| False , {block = []; value = Some out1},
9302193023
{block = []; value = Some out2} ->
@@ -93066,11 +93068,20 @@ and
9306693068
compile_lambda cxt t_br)
9306793069
?else_])
9306893070

93069-
93071+
| True _, {block = []; value = Some out1},
93072+
{block = []; value = Some out2} ->
93073+
(*
93074+
#if BS_DEBUG then
93075+
let () = Ext_log.dwarn __LOC__ "\n@[[TIME:]Lifthenelse: %f@]@." (Sys.time () *. 1000.) in
93076+
#end
93077+
*)
93078+
Js_output.make [S.return (E.econd e out1 out2)] ~finished:True
9307093079
| _, _, _ ->
93071-
(* #if BS_DEBUG then
93072-
let () = Ext_log.dwarn __LOC__ "\n@[[TIME:]Lifthenelse: %f@]@." (Sys.time () *. 1000.) in
93073-
#end *)
93080+
(*
93081+
#if BS_DEBUG then
93082+
let () = Ext_log.dwarn __LOC__ "\n@[[TIME:]Lifthenelse: %f@]@." (Sys.time () *. 1000.) in
93083+
#end
93084+
*)
9307493085
let then_output =
9307593086
Js_output.to_block @@
9307693087
(compile_lambda cxt t_br) in

jscomp/core/lam_compile.ml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,14 +1037,19 @@ and
10371037
])
10381038
end
10391039
| Assign id ->
1040-
begin match
1040+
(*
1041+
#if BS_DEBUG then
1042+
let () = Ext_log.dwarn __LOC__ "\n@[[TIME:]Lifthenelse: %f@]@." (Sys.time () *. 1000.) in
1043+
#end
1044+
*)
1045+
(* match
10411046
compile_lambda {cxt with st = NeedValue} t_br,
10421047
compile_lambda {cxt with st = NeedValue} f_br with
10431048
| {block = []; value = Some out1},
10441049
{block = []; value = Some out2} ->
10451050
(* Invariant: should_return is false *)
10461051
Js_output.make [S.assign id (E.econd e out1 out2)]
1047-
| _, _ ->
1052+
| _, _ -> *)
10481053
let then_output =
10491054
Js_output.to_block @@
10501055
(compile_lambda cxt t_br) in
@@ -1056,14 +1061,11 @@ and
10561061
then_output
10571062
~else_:else_output
10581063
])
1059-
end
10601064
| EffectCall ->
10611065
begin match should_return,
10621066
compile_lambda {cxt with st = NeedValue} t_br,
10631067
compile_lambda {cxt with st = NeedValue} f_br with
1064-
| True _, {block = []; value = Some out1},
1065-
{block = []; value = Some out2} ->
1066-
Js_output.make [S.return (E.econd e out1 out2)] ~finished:True
1068+
10671069
(* see PR#83 *)
10681070
| False , {block = []; value = Some out1},
10691071
{block = []; value = Some out2} ->
@@ -1114,11 +1116,20 @@ and
11141116
compile_lambda cxt t_br)
11151117
?else_])
11161118

1117-
1119+
| True _, {block = []; value = Some out1},
1120+
{block = []; value = Some out2} ->
1121+
(*
1122+
#if BS_DEBUG then
1123+
let () = Ext_log.dwarn __LOC__ "\n@[[TIME:]Lifthenelse: %f@]@." (Sys.time () *. 1000.) in
1124+
#end
1125+
*)
1126+
Js_output.make [S.return (E.econd e out1 out2)] ~finished:True
11181127
| _, _, _ ->
1119-
(* #if BS_DEBUG then
1120-
let () = Ext_log.dwarn __LOC__ "\n@[[TIME:]Lifthenelse: %f@]@." (Sys.time () *. 1000.) in
1121-
#end *)
1128+
(*
1129+
#if BS_DEBUG then
1130+
let () = Ext_log.dwarn __LOC__ "\n@[[TIME:]Lifthenelse: %f@]@." (Sys.time () *. 1000.) in
1131+
#end
1132+
*)
11221133
let then_output =
11231134
Js_output.to_block @@
11241135
(compile_lambda cxt t_br) in

jscomp/test/flow_parser_reg_test.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13157,16 +13157,22 @@ function module_item(env) {
1315713157
switch (match$11.tag | 0) {
1315813158
case 18 :
1315913159
var match$12 = match$11[0][/* id */0];
13160-
names = match$12 ? /* :: */[
13160+
if (match$12) {
13161+
names = /* :: */[
1316113162
/* tuple */[
1316213163
loc$1,
1316313164
extract_ident_name(match$12[0])
1316413165
],
1316513166
/* [] */0
13166-
] : (error_at(env$2, /* tuple */[
13167-
loc$1,
13168-
/* ExportNamelessFunction */56
13169-
]), /* [] */0);
13167+
];
13168+
}
13169+
else {
13170+
error_at(env$2, /* tuple */[
13171+
loc$1,
13172+
/* ExportNamelessFunction */56
13173+
]);
13174+
names = /* [] */0;
13175+
}
1317013176
break;
1317113177
case 19 :
1317213178
names = List.fold_left(function (names, param) {
@@ -13181,16 +13187,22 @@ function module_item(env) {
1318113187
break;
1318213188
case 20 :
1318313189
var match$13 = match$11[0][/* id */0];
13184-
names = match$13 ? /* :: */[
13190+
if (match$13) {
13191+
names = /* :: */[
1318513192
/* tuple */[
1318613193
loc$1,
1318713194
extract_ident_name(match$13[0])
1318813195
],
1318913196
/* [] */0
13190-
] : (error_at(env$2, /* tuple */[
13191-
loc$1,
13192-
/* ExportNamelessClass */55
13193-
]), /* [] */0);
13197+
];
13198+
}
13199+
else {
13200+
error_at(env$2, /* tuple */[
13201+
loc$1,
13202+
/* ExportNamelessClass */55
13203+
]);
13204+
names = /* [] */0;
13205+
}
1319413206
break;
1319513207
default:
1319613208
throw [

0 commit comments

Comments
 (0)