2 * Copyright (c) 2015, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
13 (* Pretty-printing for the Typing_defs.ty data structure.
15 * This was (largely) automatically generated by the ppx_deriving show plugin.
16 * Since that plugin does not support GADTs, we must add locally abstract types
17 * to its output and manually maintain it here.
19 * This differs from Typing_print in that it is intended for pretty-printing the
20 * Typing_defs.ty data structure and other data structures containing a ty, in
21 * the typical format used for OCaml data structures. Typing_print prints
22 * human-readable (for error and IDE display) and JSON (for tooling)
23 * representations of types.
26 let rec pp_ty : type a
. Format.formatter
-> a ty
-> unit = fun fmt
(a0
,a1
) ->
27 Format.fprintf fmt
"(@[";
29 Format.fprintf fmt
",@ ";
31 Format.fprintf fmt
"@])"
33 and show_ty
: type a
. a ty
-> string = fun x
->
34 Format.asprintf
"%a" pp_ty x
36 and pp_shape_field_type
37 : type a
. Format.formatter
-> a shape_field_type
-> unit = fun fmt x
->
38 Format.fprintf fmt
"@[<2>{ ";
39 Format.fprintf fmt
"@[%s =@ " "sft_optional";
40 Format.fprintf fmt
"%B" x
.sft_optional
;
41 Format.fprintf fmt
"@]";
42 Format.fprintf fmt
";@ ";
43 Format.fprintf fmt
"@[%s =@ " "sft_ty";
45 Format.fprintf fmt
"@]";
46 Format.fprintf fmt
"@ }@]"
48 and show_shape_field_type
: type a
. a shape_field_type
-> string = fun x
->
49 Format.asprintf
"%a" pp_shape_field_type x
51 and pp_ty_
: type a
. Format.formatter
-> a ty_
-> unit = fun fmt ty
->
53 | Tany
-> Format.pp_print_string fmt
"Tany"
54 | Terr
-> Format.pp_print_string fmt
"Terr"
55 | Tthis
-> Format.pp_print_string fmt
"Tthis"
56 | Tmixed
-> Format.pp_print_string fmt
"Tmixed"
57 | Tdynamic
-> Format.pp_print_string fmt
"Tdynamic"
58 | Tnonnull
-> Format.pp_print_string fmt
"Tnonnull"
60 Format.fprintf fmt
"(@[<2>Tapply (@,";
61 let () = Nast.pp_sid fmt a0
in
62 Format.fprintf fmt
",@ ";
63 Format.fprintf fmt
"@[<2>[";
67 if sep
then Format.fprintf fmt
";@ ";
72 Format.fprintf fmt
"@,]@]";
73 Format.fprintf fmt
"@,))@]"
75 Format.fprintf fmt
"(@[<2>Tgeneric@ ";
76 Format.fprintf fmt
"%S" a0
;
77 Format.fprintf fmt
"@])"
79 Format.fprintf fmt
"(@[<2>Taccess@ ";
80 pp_taccess_type fmt a0
;
81 Format.fprintf fmt
"@])"
83 Format.fprintf fmt
"(@[<2>Tarray (@,";
85 | None
-> Format.pp_print_string fmt
"None"
87 Format.pp_print_string fmt
"(Some ";
89 Format.pp_print_string fmt
")"
91 Format.fprintf fmt
",@ ";
93 | None
-> Format.pp_print_string fmt
"None"
95 Format.pp_print_string fmt
"(Some ";
97 Format.pp_print_string fmt
")"
99 Format.fprintf fmt
"@,))@]"
101 Format.fprintf fmt
"(@[<2>Tdarray (@,";
103 Format.fprintf fmt
",@ ";
105 Format.fprintf fmt
"@,))@]"
107 Format.fprintf fmt
"(@[<2>Tvarray@ ";
109 Format.fprintf fmt
"@])"
110 | Tvarray_or_darray a0
->
111 Format.fprintf fmt
"(@[<2>Tvarray_or_darray@ ";
113 Format.fprintf fmt
"@])"
115 Format.fprintf fmt
"(@[<2>Toption@ ";
117 Format.fprintf fmt
"@])"
119 Format.fprintf fmt
"(@[<2>Tprim@ ";
120 Nast.pp_tprim fmt a0
;
121 Format.fprintf fmt
"@])"
123 Format.fprintf fmt
"(@[<2>Tfun@ ";
125 Format.fprintf fmt
"@])"
127 Format.fprintf fmt
"(@[<2>Ttuple@ ";
128 Format.fprintf fmt
"@[<2>[";
132 if sep
then Format.fprintf fmt
";@ ";
137 Format.fprintf fmt
"@,]@]";
138 Format.fprintf fmt
"@])"
140 Format.fprintf fmt
"(@[<2>Tshape (@,";
141 pp_shape_fields_known fmt a0
;
142 Format.fprintf fmt
",@ ";
143 Nast.ShapeMap.pp pp_shape_field_type fmt a1
;
144 Format.fprintf fmt
"@,))@]"
146 Format.fprintf fmt
"(@[<2>Tvar@ ";
148 Format.fprintf fmt
"@])"
149 | Tabstract
(a0
,a1
) ->
150 Format.fprintf fmt
"(@[<2>Tabstract (@,";
151 pp_abstract_kind fmt a0
;
152 Format.fprintf fmt
",@ ";
154 | None
-> Format.pp_print_string fmt
"None"
156 Format.pp_print_string fmt
"(Some ";
158 Format.pp_print_string fmt
")"
160 Format.fprintf fmt
"@,))@]"
162 Format.fprintf fmt
"(@[<2>Tanon (@,";
164 Format.fprintf fmt
",@ ";
166 Format.fprintf fmt
"@,))@]"
168 Format.fprintf fmt
"(@[<2>Tunresolved@ ";
169 Format.fprintf fmt
"@[<2>[";
173 if sep
then Format.fprintf fmt
";@ ";
178 Format.fprintf fmt
"@,]@]";
179 Format.fprintf fmt
"@])"
180 | Tobject
-> Format.pp_print_string fmt
"Tobject"
182 Format.fprintf fmt
"(@[<2>Tclass (@,";
184 Format.fprintf fmt
",@ ";
185 Format.fprintf fmt
"@[<2>[";
189 if sep
then Format.fprintf fmt
";@ ";
194 Format.fprintf fmt
"@,]@]";
195 Format.fprintf fmt
"@,))@]"
197 Format.fprintf fmt
"(@[<2>Tarraykind@ ";
198 pp_array_kind fmt a0
;
199 Format.fprintf fmt
"@])"
201 and show_ty_
: type a
. a ty_
-> string = fun x
->
202 Format.asprintf
"%a" pp_ty_ x
204 and pp_array_kind
: Format.formatter
-> array_kind
-> unit = fun fmt ak
->
206 | AKany
-> Format.pp_print_string fmt
"AKany"
208 Format.fprintf fmt
"(@[<2>AKvarray@ ";
210 Format.fprintf fmt
"@])"
212 Format.fprintf fmt
"(@[<2>AKvec@ ";
214 Format.fprintf fmt
"@])"
215 | AKdarray
(a0
,a1
) ->
216 Format.fprintf fmt
"(@[<2>AKdarray (@,";
218 Format.fprintf fmt
",@ ";
220 Format.fprintf fmt
"@,))@]"
221 | AKvarray_or_darray a0
->
222 Format.fprintf fmt
"(@[<2>AKvarray_or_darray@ ";
224 Format.fprintf fmt
"@])"
226 Format.fprintf fmt
"(@[<2>AKmap (@,";
228 Format.fprintf fmt
",@ ";
230 Format.fprintf fmt
"@,))@]"
231 | AKempty
-> Format.pp_print_string fmt
"AKempty"
233 Format.fprintf fmt
"(@[<2>AKshape@ ";
235 (fun fmt
(tkey
,tval
) ->
236 Format.fprintf fmt
"(@[";
238 Format.fprintf fmt
",@ ";
240 Format.fprintf fmt
"@])")
243 Format.fprintf fmt
"@])"
245 Format.fprintf fmt
"(@[<2>AKtuple@ ";
246 IMap.pp
pp_ty fmt a0
;
247 Format.fprintf fmt
"@])"
249 and show_array_kind
: array_kind
-> string = fun x
->
250 Format.asprintf
"%a" pp_array_kind x
252 and pp_abstract_kind
: Format.formatter
-> abstract_kind
-> unit = fun fmt ak
->
254 | AKnewtype
(a0
,a1
) ->
255 Format.fprintf fmt
"(@[<2>AKnewtype (@,";
256 Format.fprintf fmt
"%S" a0
;
257 Format.fprintf fmt
",@ ";
258 Format.fprintf fmt
"@[<2>[";
262 if sep
then Format.fprintf fmt
";@ ";
267 Format.fprintf fmt
"@,]@]";
268 Format.fprintf fmt
"@,))@]"
270 Format.fprintf fmt
"(@[<2>AKenum@ ";
271 Format.fprintf fmt
"%S" a0
;
272 Format.fprintf fmt
"@])"
274 Format.fprintf fmt
"(@[<2>AKgeneric@ ";
275 Format.fprintf fmt
"%S" a0
;
276 Format.fprintf fmt
"@])"
278 Format.fprintf fmt
"(@[<2>AKdependent@ ";
279 pp_dependent_type fmt a0
;
280 Format.fprintf fmt
"@])"
282 and show_abstract_kind
: abstract_kind
-> string = fun x
->
283 Format.asprintf
"%a" pp_abstract_kind x
285 and pp_dependent_type
: Format.formatter
-> dependent_type
-> unit =
287 Format.fprintf fmt
"(@[";
289 | `this
-> Format.pp_print_string fmt
"`this"
290 | `static
-> Format.pp_print_string fmt
"`static"
292 Format.fprintf fmt
"`cls (@[<hov>";
293 Format.fprintf fmt
"%S" x
;
294 Format.fprintf fmt
"@])"
296 Format.fprintf fmt
"`expr (@[<hov>";
298 Format.fprintf fmt
"@])"
300 Format.fprintf fmt
",@ ";
301 Format.fprintf fmt
"@[<2>[";
305 if sep
then Format.fprintf fmt
";@ ";
306 (Format.fprintf fmt
"%S") x
;
310 Format.fprintf fmt
"@,]@]";
311 Format.fprintf fmt
"@])"
313 and show_dependent_type
: dependent_type
-> string = fun x
->
314 Format.asprintf
"%a" pp_dependent_type x
316 and pp_taccess_type
: Format.formatter
-> taccess_type
-> unit =
318 Format.fprintf fmt
"(@[";
320 Format.fprintf fmt
",@ ";
321 Format.fprintf fmt
"@[<2>[";
325 if sep
then Format.fprintf fmt
";@ ";
330 Format.fprintf fmt
"@,]@]";
331 Format.fprintf fmt
"@])"
333 and show_taccess_type
: taccess_type
-> string = fun x
->
334 Format.asprintf
"%a" pp_taccess_type x
336 and pp_shape_fields_known
: Format.formatter
-> shape_fields_known
-> unit =
339 | FieldsFullyKnown
-> Format.pp_print_string fmt
"FieldsFullyKnown"
340 | FieldsPartiallyKnown a0
->
341 Format.fprintf fmt
"(@[<2>FieldsPartiallyKnown@ ";
342 Nast.ShapeMap.pp
Pos.pp fmt a0
;
343 Format.fprintf fmt
"@])"
345 and show_shape_fields_known
: shape_fields_known
-> string = fun x
->
346 Format.asprintf
"%a" pp_shape_fields_known x
348 and pp_reactivity
: Format.formatter
-> reactivity
-> unit = fun fmt r
->
351 Format.pp_print_string fmt
"Nonreactive"
353 Format.pp_print_string fmt
"MaybeReactive {";
355 Format.pp_print_string fmt
"}"
357 Format.pp_print_string fmt
"Local {}";
359 Format.pp_print_string fmt
"Local {";
361 Format.pp_print_string fmt
"}"
363 Format.pp_print_string fmt
"Shallow {}";
364 | Shallow
(Some ty
) ->
365 Format.pp_print_string fmt
"Shallow {";
367 Format.pp_print_string fmt
"}"
369 Format.pp_print_string fmt
"Reactive {}";
370 | Reactive
(Some ty
) ->
371 Format.pp_print_string fmt
"Reactive {";
373 Format.pp_print_string fmt
"}"
375 and show_reactivity
: reactivity
-> string = fun x
->
376 Format.asprintf
"%a" pp_reactivity x
378 and pp_fun_type
: type a
. Format.formatter
-> a fun_type
-> unit = fun fmt x
->
379 Format.fprintf fmt
"@[<2>{ ";
381 Format.fprintf fmt
"@[%s =@ " "ft_pos";
383 Format.fprintf fmt
"@]";
384 Format.fprintf fmt
";@ ";
386 Format.fprintf fmt
"@[%s =@ " "ft_deprecated";
387 (match x
.ft_deprecated
with
388 | None
-> Format.pp_print_string fmt
"None"
390 Format.pp_print_string fmt
"(Some ";
391 Format.fprintf fmt
"%S" x
;
392 Format.pp_print_string fmt
")"
394 Format.fprintf fmt
"@]";
395 Format.fprintf fmt
";@ ";
397 Format.fprintf fmt
"@[%s =@ " "ft_abstract";
398 Format.fprintf fmt
"%B" x
.ft_abstract
;
399 Format.fprintf fmt
"@]";
400 Format.fprintf fmt
";@ ";
402 Format.fprintf fmt
"@[%s =@ " "ft_is_coroutine";
403 Format.fprintf fmt
"%B" x
.ft_is_coroutine
;
404 Format.fprintf fmt
"@]";
405 Format.fprintf fmt
";@ ";
407 Format.fprintf fmt
"@[%s =@ " "ft_arity";
408 pp_fun_arity fmt x
.ft_arity
;
409 Format.fprintf fmt
"@]";
410 Format.fprintf fmt
";@ ";
412 Format.fprintf fmt
"@[%s =@ " "ft_tparams";
413 Format.fprintf fmt
"@[<2>[";
417 if sep
then Format.fprintf fmt
";@ ";
422 Format.fprintf fmt
"@,]@]";
423 Format.fprintf fmt
"@]";
424 Format.fprintf fmt
";@ ";
426 Format.fprintf fmt
"@[%s =@ " "ft_where_constraints";
427 Format.fprintf fmt
"@[<2>[";
431 if sep
then Format.fprintf fmt
";@ ";
432 pp_where_constraint fmt x
;
435 x
.ft_where_constraints
);
436 Format.fprintf fmt
"@,]@]";
437 Format.fprintf fmt
"@]";
438 Format.fprintf fmt
";@ ";
440 Format.fprintf fmt
"@[%s =@ " "ft_params";
441 pp_fun_params fmt x
.ft_params
;
442 Format.fprintf fmt
"@]";
443 Format.fprintf fmt
";@ ";
445 Format.fprintf fmt
"@[%s =@ " "ft_ret";
447 Format.fprintf fmt
"@]";
448 Format.fprintf fmt
";@ ";
450 Format.fprintf fmt
"@[%s =@ " "ft_ret_by_ref";
451 Format.fprintf fmt
"%B" x
.ft_ret_by_ref
;
452 Format.fprintf fmt
"@]";
453 Format.fprintf fmt
";@ ";
455 Format.fprintf fmt
"@[%s =@ " "ft_reactive";
456 pp_reactivity fmt x
.ft_reactive
;
457 Format.fprintf fmt
"@]";
458 Format.fprintf fmt
";@ ";
460 Format.fprintf fmt
"@[%s =@ " "ft_return_disposable";
461 Format.fprintf fmt
"%B" x
.ft_return_disposable
;
462 Format.fprintf fmt
"@]";
463 Format.fprintf fmt
";@ ";
465 Format.fprintf fmt
"@[%s =@ " "ft_mutable";
466 Format.fprintf fmt
"%B" x
.ft_mutable
;
467 Format.fprintf fmt
"@]";
468 Format.fprintf fmt
";@ ";
470 Format.fprintf fmt
"@[%s =@ " "ft_returns_mutable";
471 Format.fprintf fmt
"%B" x
.ft_returns_mutable
;
472 Format.fprintf fmt
"@]";
473 Format.fprintf fmt
"@ }@]"
475 and show_fun_type
: type a
. a fun_type
-> string = fun x
->
476 Format.asprintf
"%a" pp_fun_type x
478 and pp_fun_arity
: type a
. Format.formatter
-> a fun_arity
-> unit =
481 | Fstandard
(a0
,a1
) ->
482 Format.fprintf fmt
"(@[<2>Fstandard (@,";
483 Format.fprintf fmt
"%d" a0
;
484 Format.fprintf fmt
",@ ";
485 Format.fprintf fmt
"%d" a1
;
486 Format.fprintf fmt
"@,))@]"
487 | Fvariadic
(a0
,a1
) ->
488 Format.fprintf fmt
"(@[<2>Fvariadic (@,";
489 Format.fprintf fmt
"%d" a0
;
490 Format.fprintf fmt
",@ ";
492 Format.fprintf fmt
"@,))@]"
494 Format.fprintf fmt
"(@[<2>Fellipsis@ ";
495 Format.fprintf fmt
"%d" a0
;
496 Format.fprintf fmt
"@])"
498 and show_fun_arity
: type a
. a fun_arity
-> string = fun x
->
499 Format.asprintf
"%a" pp_fun_arity x
501 and pp_param_mode
: Format.formatter
-> param_mode
-> unit = fun fmt mode
->
503 | FPnormal
-> Format.pp_print_string fmt
"FPnormal"
504 | FPref
-> Format.pp_print_string fmt
"FPref"
505 | FPinout
-> Format.pp_print_string fmt
"FPinout"
507 and show_param_mode
: param_mode
-> string = fun x
->
508 Format.asprintf
"%a" pp_param_mode x
510 and pp_fun_param
: type a
. Format.formatter
-> a fun_param
-> unit =
512 Format.fprintf fmt
"@[<2>{ ";
514 Format.fprintf fmt
"@[%s =@ " "fp_pos";
516 Format.fprintf fmt
"@]";
517 Format.fprintf fmt
";@ ";
519 Format.fprintf fmt
"@[%s =@ " "fp_name";
520 (match x
.fp_name
with
521 | None
-> Format.pp_print_string fmt
"None"
523 Format.pp_print_string fmt
"(Some ";
524 Format.fprintf fmt
"%S" x
;
525 Format.pp_print_string fmt
")"
527 Format.fprintf fmt
"@]";
528 Format.fprintf fmt
";@ ";
530 Format.fprintf fmt
"@[%s =@ " "fp_type";
532 Format.fprintf fmt
"@]";
533 Format.fprintf fmt
";@ ";
535 Format.fprintf fmt
"@[%s =@ " "fp_kind";
536 pp_param_mode fmt x
.fp_kind
;
537 Format.fprintf fmt
"@]";
538 Format.fprintf fmt
";@ ";
540 Format.fprintf fmt
"@[%s =@ " "fp_accept_disposable";
541 Format.fprintf fmt
"%B" x
.fp_accept_disposable
;
542 Format.fprintf fmt
"@]";
543 Format.fprintf fmt
";@ ";
545 Format.fprintf fmt
"@[%s =@ " "fp_mutable";
546 Format.fprintf fmt
"%B" x
.fp_mutable
;
547 Format.fprintf fmt
"@]";
549 Format.fprintf fmt
"@ }@]"
551 and show_fun_param
: type a
. a fun_param
-> string = fun x
->
552 Format.asprintf
"%a" pp_fun_param x
554 and pp_fun_params
: type a
. Format.formatter
-> a fun_params
-> unit =
556 Format.fprintf fmt
"@[<2>[";
560 if sep
then Format.fprintf fmt
";@ ";
565 Format.fprintf fmt
"@,]@]"
567 and show_fun_params
: type a
. a fun_params
-> string = fun x
->
568 Format.asprintf
"%a" pp_fun_params x
570 and pp_class_elt
: Format.formatter
-> class_elt
-> unit = fun fmt x
->
571 Format.fprintf fmt
"@[<2>{ ";
573 Format.fprintf fmt
"@[%s =@ " "ce_final";
574 Format.fprintf fmt
"%B" x
.ce_final
;
575 Format.fprintf fmt
"@]";
576 Format.fprintf fmt
";@ ";
578 Format.fprintf fmt
"@[%s =@ " "ce_is_xhp_attr";
579 Format.fprintf fmt
"%B" x
.ce_is_xhp_attr
;
580 Format.fprintf fmt
"@]";
581 Format.fprintf fmt
";@ ";
583 Format.fprintf fmt
"@[%s =@ " "ce_override";
584 Format.fprintf fmt
"%B" x
.ce_override
;
585 Format.fprintf fmt
"@]";
586 Format.fprintf fmt
";@ ";
588 Format.fprintf fmt
"@[%s =@ " "ce_synthesized";
589 Format.fprintf fmt
"%B" x
.ce_synthesized
;
590 Format.fprintf fmt
"@]";
591 Format.fprintf fmt
";@ ";
593 Format.fprintf fmt
"@[%s =@ " "ce_visibility";
594 Format.pp_print_string fmt
@@
595 (match x
.ce_visibility
with
596 | Vpublic
-> "Vpublic"
597 | Vprivate s
-> "Vprivate " ^ s
598 | Vprotected s
-> "Vprotected " ^ s
600 Format.fprintf fmt
"@]";
601 Format.fprintf fmt
";@ ";
603 Format.fprintf fmt
"@[%s =@ " "ce_const";
604 Format.fprintf fmt
"%B" x
.ce_const
;
605 Format.fprintf fmt
"@]";
606 Format.fprintf fmt
";@ ";
608 Format.fprintf fmt
"@[%s =@ " "ce_type";
609 if Lazy.is_val x
.ce_type
610 then pp_ty fmt
(Lazy.force x
.ce_type
)
611 else Format.pp_print_string fmt
"<not evaluated>";
612 Format.fprintf fmt
"@]";
613 Format.fprintf fmt
";@ ";
615 Format.fprintf fmt
"@[%s =@ " "ce_origin";
616 Format.fprintf fmt
"%S" x
.ce_origin
;
617 Format.fprintf fmt
"@]";
619 Format.fprintf fmt
"@ }@]"
621 and show_class_elt
: class_elt
-> string = fun x
->
622 Format.asprintf
"%a" pp_class_elt x
624 and pp_class_const
: Format.formatter
-> class_const
-> unit = fun fmt x
->
625 Format.fprintf fmt
"@[<2>{ ";
627 Format.fprintf fmt
"@[%s =@ " "cc_synthesized";
628 Format.fprintf fmt
"%B" x
.cc_synthesized
;
629 Format.fprintf fmt
"@]";
630 Format.fprintf fmt
";@ ";
632 Format.fprintf fmt
"@[%s =@ " "cc_abstract";
633 Format.fprintf fmt
"%B" x
.cc_abstract
;
634 Format.fprintf fmt
"@]";
635 Format.fprintf fmt
";@ ";
637 Format.fprintf fmt
"@[%s =@ " "cc_pos";
639 Format.fprintf fmt
"@]";
640 Format.fprintf fmt
";@ ";
642 Format.fprintf fmt
"@[%s =@ " "cc_type";
644 Format.fprintf fmt
"@]";
645 Format.fprintf fmt
";@ ";
647 Format.fprintf fmt
"@[%s =@ " "cc_expr";
648 (match x
.cc_expr
with
649 | None
-> Format.pp_print_string fmt
"None"
651 Format.pp_print_string fmt
"(Some ";
653 Format.pp_print_string fmt
")"
655 Format.fprintf fmt
"@]";
656 Format.fprintf fmt
";@ ";
658 Format.fprintf fmt
"@[%s =@ " "cc_origin";
659 Format.fprintf fmt
"%S" x
.cc_origin
;
660 Format.fprintf fmt
"@]";
662 Format.fprintf fmt
"@ }@]"
664 and show_class_const
: class_const
-> string = fun x
->
665 Format.asprintf
"%a" pp_class_const x
667 and pp_requirement
: Format.formatter
-> requirement
-> unit =
669 Format.fprintf fmt
"(@[";
671 Format.fprintf fmt
",@ ";
673 Format.fprintf fmt
"@])"
675 and show_requirement
: requirement
-> string = fun x
->
676 Format.asprintf
"%a" pp_requirement x
678 and pp_class_type
: Format.formatter
-> class_type
-> unit = fun fmt x
->
679 Format.fprintf fmt
"@[<2>{ ";
681 Format.fprintf fmt
"@[%s =@ " "tc_need_init";
682 Format.fprintf fmt
"%B" x
.tc_need_init
;
683 Format.fprintf fmt
"@]";
684 Format.fprintf fmt
";@ ";
686 Format.fprintf fmt
"@[%s =@ " "tc_members_fully_known";
687 Format.fprintf fmt
"%B" x
.tc_members_fully_known
;
688 Format.fprintf fmt
"@]";
689 Format.fprintf fmt
";@ ";
691 Format.fprintf fmt
"@[%s =@ " "tc_abstract";
692 Format.fprintf fmt
"%B" x
.tc_abstract
;
693 Format.fprintf fmt
"@]";
694 Format.fprintf fmt
";@ ";
696 Format.fprintf fmt
"@[%s =@ " "tc_final";
697 Format.fprintf fmt
"%B" x
.tc_final
;
698 Format.fprintf fmt
"@]";
699 Format.fprintf fmt
";@ ";
701 Format.fprintf fmt
"@[%s =@ " "tc_const";
702 Format.fprintf fmt
"%B" x
.tc_const
;
703 Format.fprintf fmt
"@]";
704 Format.fprintf fmt
";@ ";
706 Format.fprintf fmt
"@[%s =@ " "tc_deferred_init_members";
707 SSet.pp fmt x
.tc_deferred_init_members
;
708 Format.fprintf fmt
"@]";
709 Format.fprintf fmt
";@ ";
711 Format.fprintf fmt
"@[%s =@ " "tc_kind";
712 Ast.pp_class_kind fmt x
.tc_kind
;
713 Format.fprintf fmt
"@]";
714 Format.fprintf fmt
";@ ";
716 Format.fprintf fmt
"@[%s =@ " "tc_is_xhp";
717 Format.fprintf fmt
"%B" x
.tc_is_xhp
;
718 Format.fprintf fmt
"@]";
719 Format.fprintf fmt
";@ ";
721 Format.fprintf fmt
"@[%s =@ " "tc_is_disposable";
722 Format.fprintf fmt
"%B" x
.tc_is_disposable
;
723 Format.fprintf fmt
"@]";
724 Format.fprintf fmt
";@ ";
726 Format.fprintf fmt
"@[%s =@ " "tc_name";
727 Format.fprintf fmt
"%S" x
.tc_name
;
728 Format.fprintf fmt
"@]";
729 Format.fprintf fmt
";@ ";
731 Format.fprintf fmt
"@[%s =@ " "tc_pos";
733 Format.fprintf fmt
"@]";
734 Format.fprintf fmt
";@ ";
736 Format.fprintf fmt
"@[%s =@ " "tc_tparams";
737 Format.fprintf fmt
"@[<2>[";
741 if sep
then Format.fprintf fmt
";@ ";
746 Format.fprintf fmt
"@,]@]";
747 Format.fprintf fmt
"@]";
748 Format.fprintf fmt
";@ ";
750 Format.fprintf fmt
"@[%s =@ " "tc_consts";
751 SMap.pp pp_class_const fmt x
.tc_consts
;
752 Format.fprintf fmt
"@]";
753 Format.fprintf fmt
";@ ";
755 Format.fprintf fmt
"@[%s =@ " "tc_typeconsts";
756 SMap.pp pp_typeconst_type fmt x
.tc_typeconsts
;
757 Format.fprintf fmt
"@]";
758 Format.fprintf fmt
";@ ";
760 Format.fprintf fmt
"@[%s =@ " "tc_props";
761 SMap.pp pp_class_elt fmt x
.tc_props
;
762 Format.fprintf fmt
"@]";
763 Format.fprintf fmt
";@ ";
765 Format.fprintf fmt
"@[%s =@ " "tc_sprops";
766 SMap.pp pp_class_elt fmt x
.tc_sprops
;
767 Format.fprintf fmt
"@]";
768 Format.fprintf fmt
";@ ";
770 Format.fprintf fmt
"@[%s =@ " "tc_methods";
771 SMap.pp pp_class_elt fmt x
.tc_methods
;
772 Format.fprintf fmt
"@]";
773 Format.fprintf fmt
";@ ";
775 Format.fprintf fmt
"@[%s =@ " "tc_smethods";
776 SMap.pp pp_class_elt fmt x
.tc_smethods
;
777 Format.fprintf fmt
"@]";
778 Format.fprintf fmt
";@ ";
780 Format.fprintf fmt
"@[%s =@ " "tc_construct";
781 let (a0
, a1
) = x
.tc_construct
in
782 Format.fprintf fmt
"(@[";
784 | None
-> Format.pp_print_string fmt
"None"
786 Format.pp_print_string fmt
"(Some ";
788 Format.pp_print_string fmt
")"
790 Format.fprintf fmt
",@ ";
791 Format.fprintf fmt
"%B" a1
;
792 Format.fprintf fmt
"@])";
793 Format.fprintf fmt
"@]";
794 Format.fprintf fmt
";@ ";
796 Format.fprintf fmt
"@[%s =@ " "tc_ancestors";
797 SMap.pp
pp_ty fmt x
.tc_ancestors
;
798 Format.fprintf fmt
"@]";
799 Format.fprintf fmt
";@ ";
801 Format.fprintf fmt
"@[%s =@ " "tc_req_ancestors";
802 Format.fprintf fmt
"@[<2>[";
806 if sep
then Format.fprintf fmt
";@ ";
807 pp_requirement fmt x
;
811 Format.fprintf fmt
"@,]@]";
812 Format.fprintf fmt
"@]";
813 Format.fprintf fmt
";@ ";
815 Format.fprintf fmt
"@[%s =@ " "tc_req_ancestors_extends";
816 SSet.pp fmt x
.tc_req_ancestors_extends
;
817 Format.fprintf fmt
"@]";
818 Format.fprintf fmt
";@ ";
820 Format.fprintf fmt
"@[%s =@ " "tc_extends";
821 SSet.pp fmt x
.tc_extends
;
822 Format.fprintf fmt
"@]";
823 Format.fprintf fmt
";@ ";
825 Format.fprintf fmt
"@[%s =@ " "tc_enum_type";
826 (match x
.tc_enum_type
with
827 | None
-> Format.pp_print_string fmt
"None"
829 Format.pp_print_string fmt
"(Some ";
831 Format.pp_print_string fmt
")"
833 Format.fprintf fmt
"@]";
835 Format.fprintf fmt
"@ }@]"
837 and show_class_type
: class_type
-> string = fun x
->
838 Format.asprintf
"%a" pp_class_type x
840 and pp_typeconst_type
: Format.formatter
-> typeconst_type
-> unit =
842 Format.fprintf fmt
"@[<2>{ ";
844 Format.fprintf fmt
"@[%s =@ " "ttc_name";
845 Nast.pp_sid fmt x
.ttc_name
;
846 Format.fprintf fmt
"@]";
847 Format.fprintf fmt
";@ ";
849 Format.fprintf fmt
"@[%s =@ " "ttc_constraint";
850 (match x
.ttc_constraint
with
851 | None
-> Format.pp_print_string fmt
"None"
853 Format.pp_print_string fmt
"(Some ";
855 Format.pp_print_string fmt
")"
857 Format.fprintf fmt
"@]";
858 Format.fprintf fmt
";@ ";
860 Format.fprintf fmt
"@[%s =@ " "ttc_type";
861 (match x
.ttc_type
with
862 | None
-> Format.pp_print_string fmt
"None"
864 Format.pp_print_string fmt
"(Some ";
866 Format.pp_print_string fmt
")"
868 Format.fprintf fmt
"@]";
869 Format.fprintf fmt
";@ ";
871 Format.fprintf fmt
"@[%s =@ " "ttc_origin";
872 Format.fprintf fmt
"%S" x
.ttc_origin
;
873 Format.fprintf fmt
"@]";
875 Format.fprintf fmt
"@ }@]"
877 and show_typeconst_type
: typeconst_type
-> string = fun x
->
878 Format.asprintf
"%a" pp_typeconst_type x
880 and pp_enum_type
: Format.formatter
-> enum_type
-> unit = fun fmt x
->
881 Format.fprintf fmt
"@[<2>{ ";
883 Format.fprintf fmt
"@[%s =@ " "te_base";
885 Format.fprintf fmt
"@]";
886 Format.fprintf fmt
";@ ";
888 Format.fprintf fmt
"@[%s =@ " "te_constraint";
889 (match x
.te_constraint
with
890 | None
-> Format.pp_print_string fmt
"None"
892 Format.pp_print_string fmt
"(Some ";
894 Format.pp_print_string fmt
")"
896 Format.fprintf fmt
"@]";
898 Format.fprintf fmt
"@ }@]"
900 and show_enum_type
: enum_type
-> string = fun x
->
901 Format.asprintf
"%a" pp_enum_type x
903 and pp_typedef_type
: Format.formatter
-> typedef_type
-> unit = fun fmt x
->
904 Format.fprintf fmt
"@[<2>{ ";
906 Format.fprintf fmt
"@[%s =@ " "td_pos";
908 Format.fprintf fmt
"@]";
909 Format.fprintf fmt
";@ ";
911 Format.fprintf fmt
"@[%s =@ " "td_vis";
912 Nast.pp_typedef_visibility fmt x
.td_vis
;
913 Format.fprintf fmt
"@]";
914 Format.fprintf fmt
";@ ";
916 Format.fprintf fmt
"@[%s =@ " "td_tparams";
917 Format.fprintf fmt
"@[<2>[";
921 if sep
then Format.fprintf fmt
";@ ";
926 Format.fprintf fmt
"@,]@]";
927 Format.fprintf fmt
"@]";
928 Format.fprintf fmt
";@ ";
930 Format.fprintf fmt
"@[%s =@ " "td_constraint";
931 (match x
.td_constraint
with
932 | None
-> Format.pp_print_string fmt
"None"
934 Format.pp_print_string fmt
"(Some ";
936 Format.pp_print_string fmt
")"
938 Format.fprintf fmt
"@]";
939 Format.fprintf fmt
";@ ";
941 Format.fprintf fmt
"@[%s =@ " "td_type";
943 Format.fprintf fmt
"@]";
945 Format.fprintf fmt
"@ }@]"
947 and show_typedef_type
: typedef_type
-> string = fun x
->
948 Format.asprintf
"%a" pp_typedef_type x
950 and pp_tparam
: type a
. Format.formatter
-> a tparam
-> unit =
951 fun fmt
(a0
,a1
,a2
) ->
952 Format.fprintf fmt
"(@[";
953 Ast.pp_variance fmt a0
;
954 Format.fprintf fmt
",@ ";
956 Format.fprintf fmt
",@ ";
957 Format.fprintf fmt
"@[<2>[";
961 if sep
then Format.fprintf fmt
";@ ";
963 Format.fprintf fmt
"(@[";
964 Ast.pp_constraint_kind fmt b0
;
965 Format.fprintf fmt
",@ ";
967 Format.fprintf fmt
"@])";
971 Format.fprintf fmt
"@,]@]";
972 Format.fprintf fmt
"@])"
974 and show_tparam
: type a
. a tparam
-> string = fun x
->
975 Format.asprintf
"%a" pp_tparam x
977 and pp_where_constraint
978 : type a
. Format.formatter
-> a where_constraint
-> unit = fun fmt
(a0
,a1
,a2
) ->
979 Format.fprintf fmt
"(@[";
981 Format.fprintf fmt
",@ ";
982 Ast.pp_constraint_kind fmt a1
;
983 Format.fprintf fmt
",@ ";
985 Format.fprintf fmt
"@])"
987 and show_where_constraint
: type a
. a where_constraint
-> string = fun x
->
988 Format.asprintf
"%a" pp_where_constraint x