Introduce __ReturnsVoidToRx
[hiphop-php.git] / hphp / hack / src / typing / pp_type.ml
blobbce9c06f5993845e91b35213e10dabb34d7f8181
1 (**
2 * Copyright (c) 2015, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
8 *)
10 open Hh_core
11 open Typing_defs
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 "(@[";
28 Reason.pp fmt a0;
29 Format.fprintf fmt ",@ ";
30 pp_ty_ fmt a1;
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";
44 pp_ty fmt x.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 ->
52 match ty with
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"
59 | Tapply (a0,a1) ->
60 Format.fprintf fmt "(@[<2>Tapply (@,";
61 let () = Nast.pp_sid fmt a0 in
62 Format.fprintf fmt ",@ ";
63 Format.fprintf fmt "@[<2>[";
64 ignore
65 (List.fold_left
66 ~f:(fun sep x ->
67 if sep then Format.fprintf fmt ";@ ";
68 pp_ty fmt x;
69 true)
70 ~init:false
71 a1);
72 Format.fprintf fmt "@,]@]";
73 Format.fprintf fmt "@,))@]"
74 | Tgeneric a0 ->
75 Format.fprintf fmt "(@[<2>Tgeneric@ ";
76 Format.fprintf fmt "%S" a0;
77 Format.fprintf fmt "@])"
78 | Taccess a0 ->
79 Format.fprintf fmt "(@[<2>Taccess@ ";
80 pp_taccess_type fmt a0;
81 Format.fprintf fmt "@])"
82 | Tarray (a0,a1) ->
83 Format.fprintf fmt "(@[<2>Tarray (@,";
84 (match a0 with
85 | None -> Format.pp_print_string fmt "None"
86 | Some x ->
87 Format.pp_print_string fmt "(Some ";
88 pp_ty fmt x;
89 Format.pp_print_string fmt ")"
91 Format.fprintf fmt ",@ ";
92 (match a1 with
93 | None -> Format.pp_print_string fmt "None"
94 | Some x ->
95 Format.pp_print_string fmt "(Some ";
96 pp_ty fmt x;
97 Format.pp_print_string fmt ")"
99 Format.fprintf fmt "@,))@]"
100 | Tdarray (a0,a1) ->
101 Format.fprintf fmt "(@[<2>Tdarray (@,";
102 pp_ty fmt a0;
103 Format.fprintf fmt ",@ ";
104 pp_ty fmt a1;
105 Format.fprintf fmt "@,))@]"
106 | Tvarray a0 ->
107 Format.fprintf fmt "(@[<2>Tvarray@ ";
108 pp_ty fmt a0;
109 Format.fprintf fmt "@])"
110 | Tvarray_or_darray a0 ->
111 Format.fprintf fmt "(@[<2>Tvarray_or_darray@ ";
112 pp_ty fmt a0;
113 Format.fprintf fmt "@])"
114 | Toption a0 ->
115 Format.fprintf fmt "(@[<2>Toption@ ";
116 pp_ty fmt a0;
117 Format.fprintf fmt "@])"
118 | Tprim a0 ->
119 Format.fprintf fmt "(@[<2>Tprim@ ";
120 Nast.pp_tprim fmt a0;
121 Format.fprintf fmt "@])"
122 | Tfun a0 ->
123 Format.fprintf fmt "(@[<2>Tfun@ ";
124 pp_fun_type fmt a0;
125 Format.fprintf fmt "@])"
126 | Ttuple a0 ->
127 Format.fprintf fmt "(@[<2>Ttuple@ ";
128 Format.fprintf fmt "@[<2>[";
129 ignore
130 (List.fold_left
131 ~f:(fun sep x ->
132 if sep then Format.fprintf fmt ";@ ";
133 pp_ty fmt x;
134 true)
135 ~init:false
136 a0);
137 Format.fprintf fmt "@,]@]";
138 Format.fprintf fmt "@])"
139 | Tshape (a0,a1) ->
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 "@,))@]"
145 | Tvar a0 ->
146 Format.fprintf fmt "(@[<2>Tvar@ ";
147 Ident.pp fmt a0;
148 Format.fprintf fmt "@])"
149 | Tabstract (a0,a1) ->
150 Format.fprintf fmt "(@[<2>Tabstract (@,";
151 pp_abstract_kind fmt a0;
152 Format.fprintf fmt ",@ ";
153 (match a1 with
154 | None -> Format.pp_print_string fmt "None"
155 | Some x ->
156 Format.pp_print_string fmt "(Some ";
157 pp_ty fmt x;
158 Format.pp_print_string fmt ")"
160 Format.fprintf fmt "@,))@]"
161 | Tanon (a0,a1) ->
162 Format.fprintf fmt "(@[<2>Tanon (@,";
163 pp_fun_arity fmt a0;
164 Format.fprintf fmt ",@ ";
165 Ident.pp fmt a1;
166 Format.fprintf fmt "@,))@]"
167 | Tunresolved a0 ->
168 Format.fprintf fmt "(@[<2>Tunresolved@ ";
169 Format.fprintf fmt "@[<2>[";
170 ignore
171 (List.fold_left
172 ~f:(fun sep x ->
173 if sep then Format.fprintf fmt ";@ ";
174 pp_ty fmt x;
175 true)
176 ~init:false
177 a0);
178 Format.fprintf fmt "@,]@]";
179 Format.fprintf fmt "@])"
180 | Tobject -> Format.pp_print_string fmt "Tobject"
181 | Tclass (a0,a1) ->
182 Format.fprintf fmt "(@[<2>Tclass (@,";
183 Nast.pp_sid fmt a0;
184 Format.fprintf fmt ",@ ";
185 Format.fprintf fmt "@[<2>[";
186 ignore
187 (List.fold_left
188 ~f:(fun sep x ->
189 if sep then Format.fprintf fmt ";@ ";
190 pp_ty fmt x;
191 true)
192 ~init:false
193 a1);
194 Format.fprintf fmt "@,]@]";
195 Format.fprintf fmt "@,))@]"
196 | Tarraykind a0 ->
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 ->
205 match ak with
206 | AKany -> Format.pp_print_string fmt "AKany"
207 | AKvarray a0 ->
208 Format.fprintf fmt "(@[<2>AKvarray@ ";
209 pp_ty fmt a0;
210 Format.fprintf fmt "@])"
211 | AKvec a0 ->
212 Format.fprintf fmt "(@[<2>AKvec@ ";
213 pp_ty fmt a0;
214 Format.fprintf fmt "@])"
215 | AKdarray (a0,a1) ->
216 Format.fprintf fmt "(@[<2>AKdarray (@,";
217 pp_ty fmt a0;
218 Format.fprintf fmt ",@ ";
219 pp_ty fmt a1;
220 Format.fprintf fmt "@,))@]"
221 | AKvarray_or_darray a0 ->
222 Format.fprintf fmt "(@[<2>AKvarray_or_darray@ ";
223 pp_ty fmt a0;
224 Format.fprintf fmt "@])"
225 | AKmap (a0,a1) ->
226 Format.fprintf fmt "(@[<2>AKmap (@,";
227 pp_ty fmt a0;
228 Format.fprintf fmt ",@ ";
229 pp_ty fmt a1;
230 Format.fprintf fmt "@,))@]"
231 | AKempty -> Format.pp_print_string fmt "AKempty"
232 | AKshape a0 ->
233 Format.fprintf fmt "(@[<2>AKshape@ ";
234 Nast.ShapeMap.pp
235 (fun fmt (tkey,tval) ->
236 Format.fprintf fmt "(@[";
237 pp_ty fmt tkey;
238 Format.fprintf fmt ",@ ";
239 pp_ty fmt tval;
240 Format.fprintf fmt "@])")
243 Format.fprintf fmt "@])"
244 | AKtuple a0 ->
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 ->
253 match ak with
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>[";
259 ignore
260 (List.fold_left
261 ~f:(fun sep x ->
262 if sep then Format.fprintf fmt ";@ ";
263 pp_ty fmt x;
264 true)
265 ~init:false
266 a1);
267 Format.fprintf fmt "@,]@]";
268 Format.fprintf fmt "@,))@]"
269 | AKenum a0 ->
270 Format.fprintf fmt "(@[<2>AKenum@ ";
271 Format.fprintf fmt "%S" a0;
272 Format.fprintf fmt "@])"
273 | AKgeneric a0 ->
274 Format.fprintf fmt "(@[<2>AKgeneric@ ";
275 Format.fprintf fmt "%S" a0;
276 Format.fprintf fmt "@])"
277 | AKdependent a0 ->
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 =
286 fun fmt (a0,a1) ->
287 Format.fprintf fmt "(@[";
288 (match a0 with
289 | `this -> Format.pp_print_string fmt "`this"
290 | `static -> Format.pp_print_string fmt "`static"
291 | `cls x ->
292 Format.fprintf fmt "`cls (@[<hov>";
293 Format.fprintf fmt "%S" x;
294 Format.fprintf fmt "@])"
295 | `expr x ->
296 Format.fprintf fmt "`expr (@[<hov>";
297 Ident.pp fmt x;
298 Format.fprintf fmt "@])"
300 Format.fprintf fmt ",@ ";
301 Format.fprintf fmt "@[<2>[";
302 ignore
303 (List.fold_left
304 ~f:(fun sep x ->
305 if sep then Format.fprintf fmt ";@ ";
306 (Format.fprintf fmt "%S") x;
307 true)
308 ~init:false
309 a1);
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 =
317 fun fmt (a0,a1) ->
318 Format.fprintf fmt "(@[";
319 pp_ty fmt a0;
320 Format.fprintf fmt ",@ ";
321 Format.fprintf fmt "@[<2>[";
322 ignore
323 (List.fold_left
324 ~f:(fun sep x ->
325 if sep then Format.fprintf fmt ";@ ";
326 Nast.pp_sid fmt x;
327 true)
328 ~init:false
329 a1);
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 =
337 fun fmt sfk ->
338 match sfk with
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 ->
349 match r with
350 | Nonreactive ->
351 Format.pp_print_string fmt "Nonreactive"
352 | MaybeReactive v ->
353 Format.pp_print_string fmt "MaybeReactive {";
354 pp_reactivity fmt v;
355 Format.pp_print_string fmt "}"
356 | Local None ->
357 Format.pp_print_string fmt "Local {}";
358 | Local (Some ty) ->
359 Format.pp_print_string fmt "Local {";
360 pp_ty fmt ty;
361 Format.pp_print_string fmt "}"
362 | Shallow None ->
363 Format.pp_print_string fmt "Shallow {}";
364 | Shallow (Some ty) ->
365 Format.pp_print_string fmt "Shallow {";
366 pp_ty fmt ty;
367 Format.pp_print_string fmt "}"
368 | Reactive None ->
369 Format.pp_print_string fmt "Reactive {}";
370 | Reactive (Some ty) ->
371 Format.pp_print_string fmt "Reactive {";
372 pp_ty fmt ty;
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";
382 Pos.pp fmt x.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"
389 | Some x ->
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>[";
414 ignore
415 (List.fold_left
416 ~f:(fun sep x ->
417 if sep then Format.fprintf fmt ";@ ";
418 pp_tparam fmt x;
419 true)
420 ~init:false
421 x.ft_tparams);
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>[";
428 ignore
429 (List.fold_left
430 ~f:(fun sep x ->
431 if sep then Format.fprintf fmt ";@ ";
432 pp_where_constraint fmt x;
433 true)
434 ~init:false
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";
446 pp_ty fmt x.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 =
479 fun fmt fa ->
480 match fa with
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 ",@ ";
491 pp_fun_param fmt a1;
492 Format.fprintf fmt "@,))@]"
493 | Fellipsis a0 ->
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 ->
502 match mode with
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 =
511 fun fmt x ->
512 Format.fprintf fmt "@[<2>{ ";
514 Format.fprintf fmt "@[%s =@ " "fp_pos";
515 Pos.pp fmt x.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"
522 | Some x ->
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";
531 pp_ty fmt x.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 =
555 fun fmt x ->
556 Format.fprintf fmt "@[<2>[";
557 ignore
558 (List.fold_left
559 ~f:(fun sep x ->
560 if sep then Format.fprintf fmt ";@ ";
561 pp_fun_param fmt x;
562 true)
563 ~init:false
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";
638 Pos.pp fmt x.cc_pos;
639 Format.fprintf fmt "@]";
640 Format.fprintf fmt ";@ ";
642 Format.fprintf fmt "@[%s =@ " "cc_type";
643 pp_ty fmt x.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"
650 | Some x ->
651 Format.pp_print_string fmt "(Some ";
652 Nast.pp_expr fmt x;
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 =
668 fun fmt (a0,a1) ->
669 Format.fprintf fmt "(@[";
670 Pos.pp fmt a0;
671 Format.fprintf fmt ",@ ";
672 pp_ty fmt a1;
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";
732 Pos.pp fmt x.tc_pos;
733 Format.fprintf fmt "@]";
734 Format.fprintf fmt ";@ ";
736 Format.fprintf fmt "@[%s =@ " "tc_tparams";
737 Format.fprintf fmt "@[<2>[";
738 ignore
739 (List.fold_left
740 ~f:(fun sep x ->
741 if sep then Format.fprintf fmt ";@ ";
742 pp_tparam fmt x;
743 true)
744 ~init:false
745 x.tc_tparams);
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 "(@[";
783 (match a0 with
784 | None -> Format.pp_print_string fmt "None"
785 | Some x ->
786 Format.pp_print_string fmt "(Some ";
787 pp_class_elt fmt x;
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>[";
803 ignore
804 (List.fold_left
805 ~f:(fun sep x ->
806 if sep then Format.fprintf fmt ";@ ";
807 pp_requirement fmt x;
808 true)
809 ~init:false
810 x.tc_req_ancestors);
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"
828 | Some x ->
829 Format.pp_print_string fmt "(Some ";
830 pp_enum_type fmt x;
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 =
841 fun fmt x ->
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"
852 | Some x ->
853 Format.pp_print_string fmt "(Some ";
854 pp_ty fmt x;
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"
863 | Some x ->
864 Format.pp_print_string fmt "(Some ";
865 pp_ty fmt x;
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";
884 pp_ty fmt x.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"
891 | Some x ->
892 Format.pp_print_string fmt "(Some ";
893 pp_ty fmt x;
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";
907 Pos.pp fmt x.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>[";
918 ignore
919 (List.fold_left
920 ~f:(fun sep x ->
921 if sep then Format.fprintf fmt ";@ ";
922 pp_tparam fmt x;
923 true)
924 ~init:false
925 x.td_tparams);
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"
933 | Some x ->
934 Format.pp_print_string fmt "(Some ";
935 pp_ty fmt x;
936 Format.pp_print_string fmt ")"
938 Format.fprintf fmt "@]";
939 Format.fprintf fmt ";@ ";
941 Format.fprintf fmt "@[%s =@ " "td_type";
942 pp_ty fmt x.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 ",@ ";
955 Ast.pp_id fmt a1;
956 Format.fprintf fmt ",@ ";
957 Format.fprintf fmt "@[<2>[";
958 ignore
959 (List.fold_left
960 ~f:(fun sep x ->
961 if sep then Format.fprintf fmt ";@ ";
962 let (b0, b1) = x in
963 Format.fprintf fmt "(@[";
964 Ast.pp_constraint_kind fmt b0;
965 Format.fprintf fmt ",@ ";
966 pp_ty fmt b1;
967 Format.fprintf fmt "@])";
968 true)
969 ~init:false
970 a2);
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 "(@[";
980 pp_ty fmt a0;
981 Format.fprintf fmt ",@ ";
982 Ast.pp_constraint_kind fmt a1;
983 Format.fprintf fmt ",@ ";
984 pp_ty fmt a2;
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