Skip to content

Commit 5b5bcf9

Browse files
committed
Merge commit 'tohava/master'
Conflicts: src/boot/fe/ast.ml
2 parents dbe8760 + b1c86be commit 5b5bcf9

File tree

1 file changed

+56
-20
lines changed

1 file changed

+56
-20
lines changed

src/boot/fe/ast.ml

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ and stmt_alt_type =
259259

260260
and stmt_alt_port =
261261
{
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;
265265
}
266266

267267
and block' = stmt array
@@ -325,6 +325,13 @@ and tag_arm = tag_arm' identified
325325
and type_arm' = ident * slot * block
326326
and type_arm = type_arm' identified
327327

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+
328335
and atom =
329336
ATOM_literal of (lit identified)
330337
| ATOM_lval of lval
@@ -495,7 +502,6 @@ let sane_name (n:name) : bool =
495502

496503
(***********************************************************************)
497504

498-
(* FIXME (issue #19): finish all parts with ?foo? as their output. *)
499505

500506
let fmt_ident (ff:Format.formatter) (i:ident) : unit =
501507
fmt ff "%s" i
@@ -658,7 +664,7 @@ and fmt_constrained ff (ty, constrs) : unit =
658664
fmt_constrs ff constrs;
659665
fmt ff "@]";
660666
fmt ff "@]";
661-
667+
662668

663669
and fmt_ty (ff:Format.formatter) (t:ty) : unit =
664670
match t with
@@ -701,7 +707,7 @@ and fmt_ty (ff:Format.formatter) (t:ty) : unit =
701707
| TY_tag ttag -> fmt_tag ff ttag
702708
| TY_iso tiso -> fmt_iso ff tiso
703709
| TY_idx idx -> fmt ff "<idx#%d>" idx
704-
| TY_constrained ctrd -> fmt_constrained ff ctrd
710+
| TY_constrained ctrd -> fmt_constrained ff ctrd
705711

706712
| TY_obj (effect, fns) ->
707713
fmt_obox ff;
@@ -1228,15 +1234,15 @@ and fmt_stmt_body (ff:Format.formatter) (s:stmt) : unit =
12281234
Array.iter (fmt_tag_arm ff) at.alt_tag_arms;
12291235
fmt_cbb ff;
12301236

1231-
| STMT_alt_type at ->
1237+
| STMT_alt_type at ->
12321238
fmt_obox ff;
12331239
fmt ff "alt type (";
12341240
fmt_lval ff at.alt_type_lval;
12351241
fmt ff ") ";
12361242
fmt_obr ff;
12371243
Array.iter (fmt_type_arm ff) at.alt_type_arms;
12381244
begin
1239-
match at.alt_type_else with
1245+
match at.alt_type_else with
12401246
None -> ()
12411247
| Some block ->
12421248
fmt ff "@\n";
@@ -1247,26 +1253,46 @@ and fmt_stmt_body (ff:Format.formatter) (s:stmt) : unit =
12471253
fmt_cbb ff;
12481254
end;
12491255
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 ->
12521278
begin
12531279
fmt ff "note ";
12541280
fmt_atom ff at;
12551281
fmt ff ";"
12561282
end
1257-
| STMT_slice (dst, src, slice) ->
1283+
| STMT_slice (dst, src, slice) ->
12581284
fmt_lval ff dst;
12591285
fmt ff " = ";
12601286
fmt_lval ff src;
12611287
fmt ff ".";
12621288
fmt_slice ff slice;
12631289
fmt ff ";";
12641290
end
1265-
1266-
and fmt_arm
1267-
(ff:Format.formatter)
1291+
1292+
and fmt_arm
1293+
(ff:Format.formatter)
12681294
(fmt_arm_case_expr : Format.formatter -> unit)
1269-
(block : block)
1295+
(block : block)
12701296
: unit =
12711297
fmt ff "@\n";
12721298
fmt_obox ff;
@@ -1276,15 +1302,25 @@ and fmt_arm
12761302
fmt_obr ff;
12771303
fmt_stmts ff block.node;
12781304
fmt_cbb ff;
1279-
1305+
12801306
and fmt_tag_arm (ff:Format.formatter) (tag_arm:tag_arm) : unit =
12811307
let (pat, block) = tag_arm.node in
12821308
fmt_arm ff (fun ff -> fmt_pat ff pat) block;
1283-
1309+
12841310
and fmt_type_arm (ff:Format.formatter) (type_arm:type_arm) : unit =
12851311
let (_, slot, block) = type_arm.node in
12861312
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};
12881324

12891325
and fmt_pat (ff:Format.formatter) (pat:pat) : unit =
12901326
match pat with
@@ -1315,9 +1351,9 @@ and fmt_slice (ff:Format.formatter) (slice:slice) : unit =
13151351
fmt ff "@]";
13161352
end;
13171353
fmt ff "@])";
1318-
13191354

1320-
1355+
1356+
13211357

13221358
and fmt_decl_param (ff:Format.formatter) (param:ty_param) : unit =
13231359
let (ident, (i, e)) = param in

0 commit comments

Comments
 (0)