@@ -1338,72 +1338,44 @@ let node_program f ( program : J.program) =
1338
1338
exports cxt f program.exports
1339
1339
1340
1340
1341
- let amd_program f ({modules; block = b ; exports = exp ; side_effect } : J.program )
1341
+ let amd_program f
1342
+ ({modules; block = b ; exports = exp ; side_effect } as program : J.program )
1342
1343
=
1343
- let rec aux cxt f modules =
1344
- match modules with
1345
- | [] -> cxt
1346
- | [(id,_)] -> ident cxt f id
1347
- | (id ,_ ) :: rest ->
1348
- let cxt = ident cxt f id in
1349
- P. string f L. comma;
1350
- aux cxt f rest
1351
- in
1352
1344
P. newline f ;
1353
1345
let cxt = Ext_pp_scope. empty in
1354
- let rec list ~pp_sep pp_v ppf = function
1355
- | [] -> ()
1356
- | [v] -> pp_v ppf v
1357
- | v :: vs ->
1358
- pp_v ppf v;
1359
- pp_sep ppf () ;
1360
- list ~pp_sep pp_v ppf vs in
1361
-
1362
1346
P. vgroup f 1 @@ fun _ ->
1363
1347
P. string f L. define;
1364
1348
P. string f " ([" ;
1365
- list ~pp_sep: (fun f _ -> P. string f L. comma)
1366
- (fun f (_ ,s ) ->
1367
- pp_string f ~utf: true ~quote: (best_string_quote s) s; ) f modules;
1349
+ P. string f (Printf. sprintf " %S" L. exports);
1350
+
1351
+ List. iter (fun (_ ,s ) ->
1352
+ P. string f L. comma ;
1353
+ P. space f;
1354
+ pp_string f ~utf: true ~quote: (best_string_quote s) s;
1355
+ ) modules ;
1368
1356
P. string f " ]" ;
1369
1357
P. string f L. comma;
1370
1358
P. newline f;
1371
1359
P. string f L. function_;
1372
1360
P. string f " (" ;
1373
- let cxt = aux cxt f modules in
1361
+ P. string f L. exports;
1362
+
1363
+ let cxt =
1364
+ List. fold_left (fun cxt (id ,_ ) ->
1365
+ P. string f L. comma;
1366
+ P. space f ;
1367
+ ident cxt f id
1368
+ ) cxt modules
1369
+ in
1374
1370
P. string f " )" ;
1375
1371
P. brace_vgroup f 1 @@ (fun _ ->
1376
1372
let () = P. string f L. strict_directive in
1377
1373
let () = P. newline f in
1378
1374
let cxt = statement_list true cxt f b in
1379
1375
(* FIXME AMD : use {[ function xx ]} or {[ var x = function ..]} *)
1380
1376
P. newline f;
1381
- P. string f L. return;
1382
- P. space f;
1383
- P. brace_vgroup f 1 @@ fun _ ->
1384
- let rec aux cxt f (idents : Ident.t list ) =
1385
- match idents with
1386
- | [] -> cxt
1387
- | [id] ->
1388
- P. string f (Ext_ident. convert id.name);
1389
- P. space f ;
1390
- P. string f L. colon;
1391
- P. space f ;
1392
- ident cxt f id
1393
- | id :: rest
1394
- ->
1395
- P. string f (Ext_ident. convert id.name);
1396
- P. space f ;
1397
- P. string f L. colon;
1398
- P. space f;
1399
- let cxt = ident cxt f id in
1400
- P. string f L. comma;
1401
- P. space f ;
1402
- P. newline f ;
1403
- aux cxt f rest
1404
-
1405
- in
1406
- ignore @@ aux cxt f exp);
1377
+ P. force_newline f;
1378
+ ignore (exports cxt f program.exports));
1407
1379
P. string f " )" ;
1408
1380
;;
1409
1381
0 commit comments