@@ -73,13 +73,8 @@ and ty =
73
73
| TY_vec of ty
74
74
| TY_rec of ty_rec
75
75
76
- (*
77
- * Note that ty_idx is only valid inside a ty of a ty_iso group, not
78
- * in a general type term.
79
- *)
76
+ (* NB: non-denotable. *)
80
77
| TY_tag of ty_tag
81
- | TY_iso of ty_iso
82
- | TY_idx of int
83
78
84
79
| TY_fn of ty_fn
85
80
| TY_chan of ty
@@ -113,6 +108,9 @@ and slot = { slot_mode: mode;
113
108
114
109
and ty_tup = ty array
115
110
111
+ and ty_tag = { tag_id : opaque_id ;
112
+ tag_args : ty array }
113
+
116
114
(* In closed type terms a constraint may refer to components of the term by
117
115
* anchoring off the "formal symbol" '*', which represents "the term this
118
116
* constraint is attached to".
@@ -156,21 +154,6 @@ and constrs = constr array
156
154
157
155
and ty_rec = (ident * ty) array
158
156
159
- (* ty_tag is a sum type.
160
- *
161
- * a tag type expression either normalizes to a TY_tag or a TY_iso,
162
- * which (like in ocaml) is an indexed projection from an iso-recursive
163
- * group of TY_tags.
164
- *)
165
-
166
- and ty_tag = (name, ty_tup) Hashtbl. t
167
-
168
- and ty_iso =
169
- {
170
- iso_index : int ;
171
- iso_group : ty_tag array
172
- }
173
-
174
157
and ty_sig =
175
158
{
176
159
sig_input_slots : slot array ;
@@ -428,7 +411,7 @@ and ty_param = ident * (ty_param_idx * effect)
428
411
429
412
and mod_item' =
430
413
MOD_ITEM_type of (effect * ty)
431
- | MOD_ITEM_tag of (header_tup * ty_tag * node_id )
414
+ | MOD_ITEM_tag of (header_slots * opaque_id * int )
432
415
| MOD_ITEM_mod of (mod_view * mod_items)
433
416
| MOD_ITEM_fn of fn
434
417
| MOD_ITEM_obj of obj
@@ -626,34 +609,6 @@ and fmt_ty_fn
626
609
fmt ff " -> " ;
627
610
fmt_slot ff tsig.sig_output_slot;
628
611
629
- and fmt_tag (ff :Format.formatter ) (ttag :ty_tag ) : unit =
630
- fmt ff " @[tag(@[" ;
631
- let first = ref true in
632
- Hashtbl. iter
633
- begin
634
- fun name ttup ->
635
- (if ! first
636
- then first := false
637
- else fmt ff " ,@ " );
638
- fmt_name ff name;
639
- fmt_tys ff ttup
640
- end
641
- ttag;
642
- fmt ff " @])@]"
643
-
644
- and fmt_iso (ff :Format.formatter ) (tiso :ty_iso ) : unit =
645
- fmt ff " @[iso [@[" ;
646
- for i = 0 to (Array. length tiso.iso_group) - 1
647
- do
648
- if i != 0
649
- then fmt ff " ,@ " ;
650
- if i == tiso.iso_index
651
- then fmt ff " <%d>: " i
652
- else fmt ff " %d: " i;
653
- fmt_tag ff tiso.iso_group.(i);
654
- done ;
655
- fmt ff " @]]@]"
656
-
657
612
and fmt_constrained ff (ty , constrs ) : unit =
658
613
fmt ff " @[" ;
659
614
fmt_ty ff ty;
@@ -702,9 +657,11 @@ and fmt_ty (ff:Format.formatter) (t:ty) : unit =
702
657
703
658
| TY_fn tfn -> fmt_ty_fn ff None tfn
704
659
| TY_task -> fmt ff " task"
705
- | TY_tag ttag -> fmt_tag ff ttag
706
- | TY_iso tiso -> fmt_iso ff tiso
707
- | TY_idx idx -> fmt ff " <idx#%d>" idx
660
+ | TY_tag ttag ->
661
+ fmt ff " <tag#%d" (int_of_opaque ttag.tag_id);
662
+ fmt_arr_sep " ," fmt_ty ff ttag.tag_args;
663
+ fmt ff " >" ;
664
+
708
665
| TY_constrained ctrd -> fmt_constrained ff ctrd
709
666
710
667
| TY_obj (effect , fns ) ->
@@ -1363,16 +1320,7 @@ and fmt_decl_params (ff:Format.formatter) (params:ty_param array) : unit =
1363
1320
if Array. length params = 0
1364
1321
then ()
1365
1322
else
1366
- begin
1367
- fmt ff " [" ;
1368
- for i = 0 to (Array. length params) - 1
1369
- do
1370
- if i <> 0
1371
- then fmt ff " , " ;
1372
- fmt_decl_param ff params.(i)
1373
- done ;
1374
- fmt ff " ]"
1375
- end ;
1323
+ fmt_bracketed_arr_sep " [" " ]" " ," fmt_decl_param ff params
1376
1324
1377
1325
and fmt_header_slots (ff :Format.formatter ) (hslots :header_slots ) : unit =
1378
1326
fmt_slots ff
@@ -1462,13 +1410,17 @@ and fmt_mod_item (ff:Format.formatter) (id:ident) (item:mod_item) : unit =
1462
1410
fmt_ty ff ty;
1463
1411
fmt ff " ;" ;
1464
1412
1465
- | MOD_ITEM_tag (hdr , ttag , _ ) ->
1413
+ | MOD_ITEM_tag (hdr , tid , _ ) ->
1466
1414
fmt ff " fn " ;
1467
1415
fmt_ident_and_params ff id params;
1468
- fmt_header_slots ff
1469
- (Array. mapi (fun i s -> (s,(Printf. sprintf " _%d" i))) hdr);
1416
+ fmt_header_slots ff hdr;
1470
1417
fmt ff " -> " ;
1471
- fmt_ty ff (TY_tag ttag);
1418
+ fmt_ty ff (TY_tag
1419
+ { tag_id = tid;
1420
+ tag_args =
1421
+ Array. map
1422
+ (fun (_ ,p ) -> TY_param p)
1423
+ params });
1472
1424
fmt ff " ;" ;
1473
1425
1474
1426
| MOD_ITEM_mod (view ,items ) ->
@@ -1513,32 +1465,6 @@ and fmt_crate (ff:Format.formatter) (c:crate) : unit =
1513
1465
fmt_mod_items ff items
1514
1466
;;
1515
1467
1516
- let ty_children (ty :ty ) : ty array =
1517
- let children_of_ty_tag ty_tag = Array. concat (htab_vals ty_tag) in
1518
- let children_of_ty_fn ty_fn =
1519
- let (ty_sig, _) = ty_fn in
1520
- let in_slots = ty_sig.sig_input_slots in
1521
- let slots = Array. append in_slots [| ty_sig.sig_output_slot |] in
1522
- arr_filter_some (Array. map (fun slot -> slot.slot_ty) slots)
1523
- in
1524
- match ty with
1525
- TY_tup tys -> tys
1526
- | TY_vec ty' | TY_chan ty' | TY_port ty' | TY_box ty' | TY_mutable ty'
1527
- | TY_constrained (ty' , _ ) ->
1528
- [| ty' |]
1529
- | TY_rec fields -> Array. map snd fields
1530
- | TY_tag ty_tag -> children_of_ty_tag ty_tag
1531
- | TY_iso ty_iso ->
1532
- children_of_ty_tag (ty_iso.iso_group.(ty_iso.iso_index))
1533
- | TY_fn ty_fn -> children_of_ty_fn ty_fn
1534
- | TY_obj (_ , methods ) ->
1535
- Array. concat (List. map children_of_ty_fn (htab_vals methods))
1536
- | TY_any | TY_nil | TY_bool | TY_mach _ | TY_int | TY_uint | TY_char
1537
- | TY_str | TY_idx _ | TY_task | TY_native _ | TY_param _
1538
- | TY_named _ | TY_type ->
1539
- [| |]
1540
- ;;
1541
-
1542
1468
let sprintf_binop = sprintf_fmt fmt_binop;;
1543
1469
let sprintf_expr = sprintf_fmt fmt_expr;;
1544
1470
let sprintf_name = sprintf_fmt fmt_name;;
@@ -1549,7 +1475,6 @@ let sprintf_slot = sprintf_fmt fmt_slot;;
1549
1475
let sprintf_slot_key = sprintf_fmt fmt_slot_key;;
1550
1476
let sprintf_ty = sprintf_fmt fmt_ty;;
1551
1477
let sprintf_effect = sprintf_fmt fmt_effect;;
1552
- let sprintf_tag = sprintf_fmt fmt_tag;;
1553
1478
let sprintf_carg = sprintf_fmt fmt_carg;;
1554
1479
let sprintf_constr = sprintf_fmt fmt_constr;;
1555
1480
let sprintf_mod_item =
0 commit comments