2 * Copyright (c) 2017, Facebook, Inc.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the "hack" directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
11 include Aast_defs_visitors_ancestors
13 module ShapeMap
= Ast.ShapeMap
15 type 'a shape_map
= 'a
ShapeMap.t
[@@deriving show
]
17 type local_id
= Local_id.t
[@visitors
.opaque
]
18 and lid
= Pos.t
* local_id
21 and is_terminal
= bool
24 | Cnormal
[@visitors
.name
"call_type_Cnormal"] (* when the call looks like f() *)
25 | Cuser_func
[@visitors
.name
"call_type_Cuser_func"] (* when the call looks like call_user_func(...) *)
27 and is_coroutine
= bool
28 and is_reactive
= bool
30 and hint
= Pos.t
* hint_
32 | Hvariadic
of hint
option
36 | Hfun
of is_reactive
* is_coroutine
* hint list
* Ast.param_kind
option list
* variadic_hint
* hint
38 | Happly
of sid
* hint list
39 | Hshape
of nast_shape_info
41 (* This represents the use of a type const. Type consts are accessed like
42 * regular consts in Hack, i.e.
44 * [self | static | Class]::TypeConst
46 * Class => Happly "Class"
47 * self => Happly of the class of definition
48 * static => Habstr ("static",
49 * Habstr ("this", (Constraint_as, Happly of class of definition)))
50 * Type const access can be chained such as
52 * Class::TC1::TC2::TC3
54 * We resolve the root of the type access chain as a type as follows.
56 * This will result in the following representation
58 * Haccess (Happly "Class", ["TC1", "TC2", "TC3"])
60 | Haccess
of hint
* sid list
62 (* The following constructors don't exist in the AST hint type *)
66 | Harray
of hint
option * hint
option
67 | Hdarray
of hint
* hint
69 | Hvarray_or_darray
of hint
73 (* AST types such as Happly("int", []) are resolved to Hprim values *)
85 and shape_field_info
= {
90 and nast_shape_info
= {
91 nsi_allows_unknown_fields
: bool;
92 nsi_field_map
: shape_field_info shape_map
;
112 and tparam
= Ast.variance
* sid
* (Ast.constraint_kind
* hint
) list
115 | Private
[@visitors
.name
"visibility_Private"]
116 | Public
[@visitors
.name
"visibility_Public"]
117 | Protected
[@visitors
.name
"visibility_Protected"]
119 and typedef_visibility
=
125 e_constraint
: hint
option;
129 and instantiated_sid
= sid
* hint list
131 and where_constraint
= hint
* Ast.constraint_kind
* hint
139 ancestors
=["iter_defs_base"];
146 ancestors
=["reduce_defs_base"];
153 ancestors
=["map_defs_base"];
160 ancestors
=["endo_defs_base"];
163 type id
= lid
[@@deriving show
]
164 type pstring
= Ast.pstring
[@@deriving show
]
165 type shape_field_name
= Ast.shape_field_name
[@@deriving show
]
167 type og_null_flavor
= Ast.og_null_flavor
=
171 let pp_og_null_flavor fmt flavor
=
172 Format.pp_print_string fmt
@@
174 | OG_nullthrows
-> "OG_nullthrows"
175 | OG_nullsafe
-> "OG_nullsafe"
177 let pp_kvc_kind fmt _
= Format.pp_print_string fmt
"<kvc_kind>"
178 let pp_vc_kind fmt _
= Format.pp_print_string fmt
"<vc_kind>"