@@ -259,9 +259,9 @@ and stmt_alt_type =
259
259
260
260
and stmt_alt_port =
261
261
{
262
- (* else lval is a timeout value. *)
263
- alt_port_arms : ( lval * lval ) array ;
264
- alt_port_else : (lval * block ) option ;
262
+ (* else atom is a timeout value. *)
263
+ alt_port_arms : port_arm array ;
264
+ alt_port_else : (atom * block ) option ;
265
265
}
266
266
267
267
and block' = stmt array
@@ -325,6 +325,13 @@ and tag_arm = tag_arm' identified
325
325
and type_arm' = ident * slot * block
326
326
and type_arm = type_arm' identified
327
327
328
+ and port_arm' = port_case * block
329
+ and port_arm = port_arm' identified
330
+
331
+ and port_case =
332
+ PORT_CASE_send of (lval * lval)
333
+ | PORT_CASE_recv of (lval * lval)
334
+
328
335
and atom =
329
336
ATOM_literal of (lit identified)
330
337
| ATOM_lval of lval
@@ -495,7 +502,6 @@ let sane_name (n:name) : bool =
495
502
496
503
(* **********************************************************************)
497
504
498
- (* FIXME (issue #19): finish all parts with ?foo? as their output. *)
499
505
500
506
let fmt_ident (ff :Format.formatter ) (i :ident ) : unit =
501
507
fmt ff " %s" i
@@ -658,7 +664,7 @@ and fmt_constrained ff (ty, constrs) : unit =
658
664
fmt_constrs ff constrs;
659
665
fmt ff " @]" ;
660
666
fmt ff " @]" ;
661
-
667
+
662
668
663
669
and fmt_ty (ff :Format.formatter ) (t :ty ) : unit =
664
670
match t with
@@ -701,7 +707,7 @@ and fmt_ty (ff:Format.formatter) (t:ty) : unit =
701
707
| TY_tag ttag -> fmt_tag ff ttag
702
708
| TY_iso tiso -> fmt_iso ff tiso
703
709
| TY_idx idx -> fmt ff " <idx#%d>" idx
704
- | TY_constrained ctrd -> fmt_constrained ff ctrd
710
+ | TY_constrained ctrd -> fmt_constrained ff ctrd
705
711
706
712
| TY_obj (effect , fns ) ->
707
713
fmt_obox ff;
@@ -1228,15 +1234,15 @@ and fmt_stmt_body (ff:Format.formatter) (s:stmt) : unit =
1228
1234
Array. iter (fmt_tag_arm ff) at.alt_tag_arms;
1229
1235
fmt_cbb ff;
1230
1236
1231
- | STMT_alt_type at ->
1237
+ | STMT_alt_type at ->
1232
1238
fmt_obox ff;
1233
1239
fmt ff " alt type (" ;
1234
1240
fmt_lval ff at.alt_type_lval;
1235
1241
fmt ff " ) " ;
1236
1242
fmt_obr ff;
1237
1243
Array. iter (fmt_type_arm ff) at.alt_type_arms;
1238
1244
begin
1239
- match at.alt_type_else with
1245
+ match at.alt_type_else with
1240
1246
None -> ()
1241
1247
| Some block ->
1242
1248
fmt ff " @\n " ;
@@ -1247,26 +1253,46 @@ and fmt_stmt_body (ff:Format.formatter) (s:stmt) : unit =
1247
1253
fmt_cbb ff;
1248
1254
end ;
1249
1255
fmt_cbb ff;
1250
- | STMT_alt_port _ -> fmt ff " ?stmt_alt_port?"
1251
- | STMT_note at ->
1256
+
1257
+ | STMT_alt_port at ->
1258
+ fmt_obox ff;
1259
+ fmt ff " alt " ;
1260
+ fmt_obr ff;
1261
+ Array. iter (fmt_port_arm ff) at.alt_port_arms;
1262
+ begin
1263
+ match at.alt_port_else with
1264
+ None -> ()
1265
+ | Some (timeout , block ) ->
1266
+ fmt ff " @\n " ;
1267
+ fmt_obox ff;
1268
+ fmt ff " case (_) " ;
1269
+ fmt_atom ff timeout;
1270
+ fmt ff " " ;
1271
+ fmt_obr ff;
1272
+ fmt_stmts ff block.node;
1273
+ fmt_cbb ff;
1274
+ end ;
1275
+ fmt_cbb ff;
1276
+
1277
+ | STMT_note at ->
1252
1278
begin
1253
1279
fmt ff " note " ;
1254
1280
fmt_atom ff at;
1255
1281
fmt ff " ;"
1256
1282
end
1257
- | STMT_slice (dst , src , slice ) ->
1283
+ | STMT_slice (dst , src , slice ) ->
1258
1284
fmt_lval ff dst;
1259
1285
fmt ff " = " ;
1260
1286
fmt_lval ff src;
1261
1287
fmt ff " ." ;
1262
1288
fmt_slice ff slice;
1263
1289
fmt ff " ;" ;
1264
1290
end
1265
-
1266
- and fmt_arm
1267
- (ff :Format.formatter )
1291
+
1292
+ and fmt_arm
1293
+ (ff :Format.formatter )
1268
1294
(fmt_arm_case_expr : Format.formatter -> unit )
1269
- (block : block )
1295
+ (block : block )
1270
1296
: unit =
1271
1297
fmt ff " @\n " ;
1272
1298
fmt_obox ff;
@@ -1276,15 +1302,25 @@ and fmt_arm
1276
1302
fmt_obr ff;
1277
1303
fmt_stmts ff block.node;
1278
1304
fmt_cbb ff;
1279
-
1305
+
1280
1306
and fmt_tag_arm (ff :Format.formatter ) (tag_arm :tag_arm ) : unit =
1281
1307
let (pat, block) = tag_arm.node in
1282
1308
fmt_arm ff (fun ff -> fmt_pat ff pat) block;
1283
-
1309
+
1284
1310
and fmt_type_arm (ff :Format.formatter ) (type_arm :type_arm ) : unit =
1285
1311
let (_, slot, block) = type_arm.node in
1286
1312
fmt_arm ff (fun ff -> fmt_slot ff slot) block;
1287
-
1313
+
1314
+
1315
+ and fmt_port_arm (ff :Format.formatter ) (port_arm :port_arm ) : unit =
1316
+ let (port_case, block) = port_arm.node in
1317
+ fmt_arm ff (fun ff -> fmt_port_case ff port_case) block;
1318
+
1319
+ and fmt_port_case (ff :Format.formatter ) (port_case :port_case ) : unit =
1320
+ let stmt' = match port_case with
1321
+ PORT_CASE_send params -> STMT_send params
1322
+ | PORT_CASE_recv params -> STMT_recv params in
1323
+ fmt_stmt ff {node = stmt'; id = Node 0 };
1288
1324
1289
1325
and fmt_pat (ff :Format.formatter ) (pat :pat ) : unit =
1290
1326
match pat with
@@ -1315,9 +1351,9 @@ and fmt_slice (ff:Format.formatter) (slice:slice) : unit =
1315
1351
fmt ff " @]" ;
1316
1352
end ;
1317
1353
fmt ff " @])" ;
1318
-
1319
1354
1320
-
1355
+
1356
+
1321
1357
1322
1358
and fmt_decl_param (ff :Format.formatter ) (param :ty_param ) : unit =
1323
1359
let (ident, (i, e)) = param in
0 commit comments