Skip to content

Commit c071513

Browse files
committed
use create_await_expression fn
1 parent 38a0dd1 commit c071513

File tree

4 files changed

+152
-232
lines changed

4 files changed

+152
-232
lines changed

jscomp/frontend/ast_await.ml

Lines changed: 38 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -12,66 +12,46 @@ let create_await_module_expression (e : Parsetree.module_expr) =
1212
in
1313
let module_expr_without_attr = { e with pmod_attributes = [] } in
1414
let import_pexp_desc = Parsetree.Pexp_ident { txt; loc = e.pmod_loc } in
15-
let txt =
16-
Longident.Ldot (Longident.Ldot (Lident "Js", "Promise"), "unsafe_await")
17-
in
18-
let await_pexp_desc = Parsetree.Pexp_ident { txt; loc = e.pmod_loc } in
1915
{
2016
module_expr_without_attr with
2117
pmod_desc =
2218
Pmod_unpack
23-
{
24-
pexp_desc =
25-
Pexp_apply
26-
( {
27-
pexp_desc = await_pexp_desc;
28-
pexp_attributes = [];
29-
pexp_loc = e.pmod_loc;
30-
},
31-
[
32-
( Nolabel,
33-
{
34-
pexp_desc =
35-
Pexp_apply
36-
( {
37-
pexp_desc = import_pexp_desc;
38-
pexp_attributes = [];
39-
pexp_loc = e.pmod_loc;
40-
},
41-
[
42-
( Nolabel,
43-
{
44-
pexp_desc =
45-
Pexp_constraint
46-
( {
47-
pexp_desc =
48-
Pexp_pack module_expr_without_attr;
49-
pexp_loc = e.pmod_loc;
50-
pexp_attributes = [];
51-
},
52-
{
53-
ptyp_desc =
54-
Ptyp_package
55-
( {
56-
txt = Lident "BeltList";
57-
loc = e.pmod_loc;
58-
},
59-
[] );
60-
ptyp_loc = e.pmod_loc;
61-
ptyp_attributes = [];
62-
} );
63-
pexp_attributes = [];
64-
pexp_loc = e.pmod_loc;
65-
} );
66-
] );
67-
pexp_attributes =
68-
[
69-
({ txt = "res.await"; loc = Location.none }, PStr []);
70-
];
71-
pexp_loc = e.pmod_loc;
72-
} );
73-
] );
74-
pexp_loc = e.pmod_loc;
75-
pexp_attributes = [];
76-
};
19+
(create_await_expression
20+
{
21+
pexp_desc =
22+
Pexp_apply
23+
( {
24+
pexp_desc = import_pexp_desc;
25+
pexp_attributes = [];
26+
pexp_loc = e.pmod_loc;
27+
},
28+
[
29+
( Nolabel,
30+
{
31+
pexp_desc =
32+
Pexp_constraint
33+
( {
34+
pexp_desc = Pexp_pack module_expr_without_attr;
35+
pexp_loc = e.pmod_loc;
36+
pexp_attributes = [];
37+
},
38+
{
39+
ptyp_desc =
40+
Ptyp_package
41+
( {
42+
txt = Lident "BeltList";
43+
loc = e.pmod_loc;
44+
},
45+
[] );
46+
ptyp_loc = e.pmod_loc;
47+
ptyp_attributes = [];
48+
} );
49+
pexp_attributes = [];
50+
pexp_loc = e.pmod_loc;
51+
} );
52+
] );
53+
pexp_attributes =
54+
[ ({ txt = "res.await"; loc = Location.none }, PStr []) ];
55+
pexp_loc = e.pmod_loc;
56+
});
7757
}

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 38 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -264817,68 +264817,48 @@ let create_await_module_expression (e : Parsetree.module_expr) =
264817264817
in
264818264818
let module_expr_without_attr = { e with pmod_attributes = [] } in
264819264819
let import_pexp_desc = Parsetree.Pexp_ident { txt; loc = e.pmod_loc } in
264820-
let txt =
264821-
Longident.Ldot (Longident.Ldot (Lident "Js", "Promise"), "unsafe_await")
264822-
in
264823-
let await_pexp_desc = Parsetree.Pexp_ident { txt; loc = e.pmod_loc } in
264824264820
{
264825264821
module_expr_without_attr with
264826264822
pmod_desc =
264827264823
Pmod_unpack
264828-
{
264829-
pexp_desc =
264830-
Pexp_apply
264831-
( {
264832-
pexp_desc = await_pexp_desc;
264833-
pexp_attributes = [];
264834-
pexp_loc = e.pmod_loc;
264835-
},
264836-
[
264837-
( Nolabel,
264838-
{
264839-
pexp_desc =
264840-
Pexp_apply
264841-
( {
264842-
pexp_desc = import_pexp_desc;
264843-
pexp_attributes = [];
264844-
pexp_loc = e.pmod_loc;
264845-
},
264846-
[
264847-
( Nolabel,
264848-
{
264849-
pexp_desc =
264850-
Pexp_constraint
264851-
( {
264852-
pexp_desc =
264853-
Pexp_pack module_expr_without_attr;
264854-
pexp_loc = e.pmod_loc;
264855-
pexp_attributes = [];
264856-
},
264857-
{
264858-
ptyp_desc =
264859-
Ptyp_package
264860-
( {
264861-
txt = Lident "BeltList";
264862-
loc = e.pmod_loc;
264863-
},
264864-
[] );
264865-
ptyp_loc = e.pmod_loc;
264866-
ptyp_attributes = [];
264867-
} );
264868-
pexp_attributes = [];
264869-
pexp_loc = e.pmod_loc;
264870-
} );
264871-
] );
264872-
pexp_attributes =
264873-
[
264874-
({ txt = "res.await"; loc = Location.none }, PStr []);
264875-
];
264876-
pexp_loc = e.pmod_loc;
264877-
} );
264878-
] );
264879-
pexp_loc = e.pmod_loc;
264880-
pexp_attributes = [];
264881-
};
264824+
(create_await_expression
264825+
{
264826+
pexp_desc =
264827+
Pexp_apply
264828+
( {
264829+
pexp_desc = import_pexp_desc;
264830+
pexp_attributes = [];
264831+
pexp_loc = e.pmod_loc;
264832+
},
264833+
[
264834+
( Nolabel,
264835+
{
264836+
pexp_desc =
264837+
Pexp_constraint
264838+
( {
264839+
pexp_desc = Pexp_pack module_expr_without_attr;
264840+
pexp_loc = e.pmod_loc;
264841+
pexp_attributes = [];
264842+
},
264843+
{
264844+
ptyp_desc =
264845+
Ptyp_package
264846+
( {
264847+
txt = Lident "BeltList";
264848+
loc = e.pmod_loc;
264849+
},
264850+
[] );
264851+
ptyp_loc = e.pmod_loc;
264852+
ptyp_attributes = [];
264853+
} );
264854+
pexp_attributes = [];
264855+
pexp_loc = e.pmod_loc;
264856+
} );
264857+
] );
264858+
pexp_attributes =
264859+
[ ({ txt = "res.await"; loc = Location.none }, PStr []) ];
264860+
pexp_loc = e.pmod_loc;
264861+
});
264882264862
}
264883264863

264884264864
end

lib/4.06.1/unstable/js_playground_compiler.ml

Lines changed: 38 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -266280,68 +266280,48 @@ let create_await_module_expression (e : Parsetree.module_expr) =
266280266280
in
266281266281
let module_expr_without_attr = { e with pmod_attributes = [] } in
266282266282
let import_pexp_desc = Parsetree.Pexp_ident { txt; loc = e.pmod_loc } in
266283-
let txt =
266284-
Longident.Ldot (Longident.Ldot (Lident "Js", "Promise"), "unsafe_await")
266285-
in
266286-
let await_pexp_desc = Parsetree.Pexp_ident { txt; loc = e.pmod_loc } in
266287266283
{
266288266284
module_expr_without_attr with
266289266285
pmod_desc =
266290266286
Pmod_unpack
266291-
{
266292-
pexp_desc =
266293-
Pexp_apply
266294-
( {
266295-
pexp_desc = await_pexp_desc;
266296-
pexp_attributes = [];
266297-
pexp_loc = e.pmod_loc;
266298-
},
266299-
[
266300-
( Nolabel,
266301-
{
266302-
pexp_desc =
266303-
Pexp_apply
266304-
( {
266305-
pexp_desc = import_pexp_desc;
266306-
pexp_attributes = [];
266307-
pexp_loc = e.pmod_loc;
266308-
},
266309-
[
266310-
( Nolabel,
266311-
{
266312-
pexp_desc =
266313-
Pexp_constraint
266314-
( {
266315-
pexp_desc =
266316-
Pexp_pack module_expr_without_attr;
266317-
pexp_loc = e.pmod_loc;
266318-
pexp_attributes = [];
266319-
},
266320-
{
266321-
ptyp_desc =
266322-
Ptyp_package
266323-
( {
266324-
txt = Lident "BeltList";
266325-
loc = e.pmod_loc;
266326-
},
266327-
[] );
266328-
ptyp_loc = e.pmod_loc;
266329-
ptyp_attributes = [];
266330-
} );
266331-
pexp_attributes = [];
266332-
pexp_loc = e.pmod_loc;
266333-
} );
266334-
] );
266335-
pexp_attributes =
266336-
[
266337-
({ txt = "res.await"; loc = Location.none }, PStr []);
266338-
];
266339-
pexp_loc = e.pmod_loc;
266340-
} );
266341-
] );
266342-
pexp_loc = e.pmod_loc;
266343-
pexp_attributes = [];
266344-
};
266287+
(create_await_expression
266288+
{
266289+
pexp_desc =
266290+
Pexp_apply
266291+
( {
266292+
pexp_desc = import_pexp_desc;
266293+
pexp_attributes = [];
266294+
pexp_loc = e.pmod_loc;
266295+
},
266296+
[
266297+
( Nolabel,
266298+
{
266299+
pexp_desc =
266300+
Pexp_constraint
266301+
( {
266302+
pexp_desc = Pexp_pack module_expr_without_attr;
266303+
pexp_loc = e.pmod_loc;
266304+
pexp_attributes = [];
266305+
},
266306+
{
266307+
ptyp_desc =
266308+
Ptyp_package
266309+
( {
266310+
txt = Lident "BeltList";
266311+
loc = e.pmod_loc;
266312+
},
266313+
[] );
266314+
ptyp_loc = e.pmod_loc;
266315+
ptyp_attributes = [];
266316+
} );
266317+
pexp_attributes = [];
266318+
pexp_loc = e.pmod_loc;
266319+
} );
266320+
] );
266321+
pexp_attributes =
266322+
[ ({ txt = "res.await"; loc = Location.none }, PStr []) ];
266323+
pexp_loc = e.pmod_loc;
266324+
});
266345266325
}
266346266326

266347266327
end

0 commit comments

Comments
 (0)