File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -1339,6 +1339,32 @@ and fmt_crate (ff:Format.formatter) (c:crate) : unit =
1339
1339
let (view,items) = c.node.crate_items in
1340
1340
fmt_mod_view ff view;
1341
1341
fmt_mod_items ff items
1342
+ ;;
1343
+
1344
+ let ty_children (ty :ty ) : ty array =
1345
+ let children_of_ty_tag ty_tag = Array. concat (htab_vals ty_tag) in
1346
+ let children_of_ty_fn ty_fn =
1347
+ let (ty_sig, _) = ty_fn in
1348
+ let in_slots = ty_sig.sig_input_slots in
1349
+ let slots = Array. append in_slots [| ty_sig.sig_output_slot |] in
1350
+ arr_filter_some (Array. map (fun slot -> slot.slot_ty) slots)
1351
+ in
1352
+ match ty with
1353
+ TY_tup tys -> tys
1354
+ | TY_vec ty' | TY_chan ty' | TY_port ty' | TY_box ty' | TY_mutable ty'
1355
+ | TY_constrained (ty' , _ ) ->
1356
+ [| ty' |]
1357
+ | TY_rec fields -> Array. map snd fields
1358
+ | TY_tag ty_tag -> children_of_ty_tag ty_tag
1359
+ | TY_iso ty_iso -> children_of_ty_tag (ty_iso.iso_group.(ty_iso.iso_index))
1360
+ | TY_fn ty_fn -> children_of_ty_fn ty_fn
1361
+ | TY_obj (_ , methods ) ->
1362
+ Array. concat (List. map children_of_ty_fn (htab_vals methods))
1363
+ | TY_any | TY_nil | TY_bool | TY_mach _ | TY_int | TY_uint | TY_char
1364
+ | TY_str | TY_idx _ | TY_task | TY_native _ | TY_param _
1365
+ | TY_named _ | TY_type ->
1366
+ [| |]
1367
+ ;;
1342
1368
1343
1369
let sprintf_expr = sprintf_fmt fmt_expr;;
1344
1370
let sprintf_name = sprintf_fmt fmt_name;;
Original file line number Diff line number Diff line change @@ -341,7 +341,6 @@ let bool_of_option x =
341
341
Some _ -> true
342
342
| None -> false
343
343
344
-
345
344
(*
346
345
* Auxiliary stack functions.
347
346
*)
You can’t perform that action at this time.
0 commit comments