Allow function pointer builtins in constant initializers
[hiphop-php.git] / hphp / hack / src / oxidized / gen / typing_defs.rs
blob0ca6f1020c9d2ca2b84b1fbdf508089331526240
1 // Copyright (c) Facebook, Inc. and its affiliates.
2 //
3 // This source code is licensed under the MIT license found in the
4 // LICENSE file in the "hack" directory of this source tree.
5 //
6 // @generated SignedSource<<a38d9ba2a4cbdbfa37d5f352de46503e>>
7 //
8 // To regenerate this file, run:
9 //   hphp/hack/src/oxidized/regen.sh
11 use ocamlrep_derive::OcamlRep;
12 use ocamlvalue_macro::Ocamlvalue;
14 use crate::aast;
15 use crate::ast_defs;
16 use crate::errors;
17 use crate::ident;
18 use crate::lazy;
19 use crate::nast;
20 use crate::pos;
21 use crate::s_map;
22 use crate::s_set;
23 use crate::tany_sentinel;
25 pub use crate::typing_reason as reason;
27 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
28 pub enum Visibility {
29     Vpublic,
30     Vprivate(String),
31     Vprotected(String),
34 #[derive(Clone, Copy, Debug, Eq, OcamlRep, Ocamlvalue, PartialEq)]
35 pub enum Exact {
36     Exact,
37     Nonexact,
40 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
41 pub enum PuKind {
42     PuPlain,
43     PuAtom(String),
46 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
47 pub struct Ty(pub reason::Reason, pub Box<Ty_>);
49 pub type DeclTy = Ty;
51 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
52 pub struct ShapeFieldType {
53     pub optional: bool,
54     pub ty: Ty,
57 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
58 pub enum Ty_ {
59     Tthis,
60     Tapply(nast::Sid, Vec<DeclTy>),
61     Tgeneric(String),
62     Taccess(TaccessType),
63     Tarray(Option<DeclTy>, Option<DeclTy>),
64     Tdarray(DeclTy, DeclTy),
65     Tvarray(DeclTy),
66     TvarrayOrDarray(DeclTy),
67     Tmixed,
68     Tnothing,
69     Tlike(DeclTy),
70     Tany(tany_sentinel::TanySentinel),
71     Terr,
72     Tnonnull,
73     Tdynamic,
74     Toption(Ty),
75     Tprim(aast::Tprim),
76     Tfun(FunType<Ty>),
77     Ttuple(Vec<Ty>),
78     Tshape(ShapeKind, nast::shape_map::ShapeMap<ShapeFieldType>),
79     TpuAccess(Ty, nast::Sid),
80     Tvar(ident::Ident),
83 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
84 pub enum DependentType {
85     DTthis,
86     DTcls(String),
87     DTexpr(ident::Ident),
90 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
91 pub struct TaccessType(pub DeclTy, pub Vec<nast::Sid>);
93 #[derive(Clone, Copy, Debug, Eq, OcamlRep, Ocamlvalue, PartialEq)]
94 pub enum ShapeKind {
95     ClosedShape,
96     OpenShape,
99 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
100 pub enum Reactivity {
101     Nonreactive,
102     Local(Option<DeclTy>),
103     Shallow(Option<DeclTy>),
104     Reactive(Option<DeclTy>),
105     MaybeReactive(Box<Reactivity>),
106     RxVar(Option<Box<Reactivity>>),
109 #[derive(Clone, Copy, Debug, Eq, OcamlRep, Ocamlvalue, PartialEq)]
110 pub enum ValKind {
111     Lval,
112     LvalSubexpr,
113     Other,
116 #[derive(Clone, Copy, Debug, Eq, OcamlRep, Ocamlvalue, PartialEq)]
117 pub enum ParamMutability {
118     ParamOwnedMutable,
119     ParamBorrowedMutable,
120     ParamMaybeMutable,
123 #[derive(Clone, Copy, Debug, Eq, OcamlRep, Ocamlvalue, PartialEq)]
124 pub enum FunTparamsKind {
125     FTKtparams,
126     FTKinstantiatedTargs,
129 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
130 pub struct FunType<Ty> {
131     pub pos: pos::Pos,
132     pub deprecated: Option<String>,
133     pub is_coroutine: bool,
134     pub arity: FunArity<Ty>,
135     pub tparams: (Vec<Tparam<Ty>>, FunTparamsKind),
136     pub where_constraints: Vec<WhereConstraint<Ty>>,
137     pub params: FunParams<Ty>,
138     pub ret: PossiblyEnforcedTy<Ty>,
139     pub fun_kind: ast_defs::FunKind,
140     pub reactive: Reactivity,
141     pub return_disposable: bool,
142     pub mutability: Option<ParamMutability>,
143     pub returns_mutable: bool,
144     pub decl_errors: Option<errors::Errors>,
145     pub returns_void_to_rx: bool,
148 pub type DeclFunType = FunType<DeclTy>;
150 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
151 pub enum FunArity<Ty> {
152     Fstandard(isize, isize),
153     Fvariadic(isize, FunParam<Ty>),
154     Fellipsis(isize, pos::Pos),
157 pub type DeclFunArity = FunArity<DeclTy>;
159 #[derive(Clone, Copy, Debug, Eq, OcamlRep, Ocamlvalue, PartialEq)]
160 pub enum ParamMode {
161     FPnormal,
162     FPref,
163     FPinout,
166 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
167 pub enum ParamRxAnnotation {
168     ParamRxVar,
169     ParamRxIfImpl(DeclTy),
172 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
173 pub struct PossiblyEnforcedTy<Ty> {
174     pub enforced: bool,
175     pub type_: Ty,
178 pub type DeclPossiblyEnforcedTy = PossiblyEnforcedTy<DeclTy>;
180 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
181 pub struct FunParam<Ty> {
182     pub pos: pos::Pos,
183     pub name: Option<String>,
184     pub type_: PossiblyEnforcedTy<Ty>,
185     pub kind: ParamMode,
186     pub accept_disposable: bool,
187     pub mutability: Option<ParamMutability>,
188     pub rx_annotation: Option<ParamRxAnnotation>,
191 pub type DeclFunParam = FunParam<DeclTy>;
193 pub type FunParams<Ty> = Vec<FunParam<Ty>>;
195 pub type DeclFunParams = FunParams<DeclTy>;
197 #[derive(Clone, Copy, Debug, Eq, OcamlRep, Ocamlvalue, PartialEq)]
198 pub enum XhpAttrTag {
199     Required,
200     Lateinit,
203 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
204 pub struct XhpAttr {
205     pub tag: Option<XhpAttrTag>,
206     pub has_default: bool,
209 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
210 pub struct ClassElt {
211     pub abstract_: bool,
212     pub final_: bool,
213     pub xhp_attr: Option<XhpAttr>,
214     pub override_: bool,
215     pub lsb: bool,
216     pub memoizelsb: bool,
217     pub synthesized: bool,
218     pub visibility: Visibility,
219     pub const_: bool,
220     pub lateinit: bool,
221     pub type_: lazy::Lazy<DeclTy>,
222     pub origin: String,
225 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
226 pub struct ClassConst {
227     pub synthesized: bool,
228     pub abstract_: bool,
229     pub pos: pos::Pos,
230     pub type_: DeclTy,
231     pub visibility: Visibility,
232     pub expr: Option<nast::Expr>,
233     pub origin: String,
236 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
237 pub struct Requirement(pub pos::Pos, pub DeclTy);
239 #[derive(Clone, Copy, Debug, Eq, OcamlRep, Ocamlvalue, PartialEq)]
240 pub enum ConsistentKind {
241     Inconsistent,
242     ConsistentConstruct,
243     FinalClass,
246 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
247 pub struct ClassType {
248     pub need_init: bool,
249     pub members_fully_known: bool,
250     pub abstract_: bool,
251     pub final_: bool,
252     pub const_: bool,
253     pub ppl: bool,
254     pub deferred_init_members: s_set::SSet,
255     pub kind: ast_defs::ClassKind,
256     pub is_xhp: bool,
257     pub is_disposable: bool,
258     pub name: String,
259     pub pos: pos::Pos,
260     pub tparams: Vec<DeclTparam>,
261     pub where_constraints: Vec<DeclWhereConstraint>,
262     pub consts: s_map::SMap<ClassConst>,
263     pub typeconsts: s_map::SMap<TypeconstType>,
264     pub pu_enums: s_map::SMap<PuEnumType>,
265     pub props: s_map::SMap<ClassElt>,
266     pub sprops: s_map::SMap<ClassElt>,
267     pub methods: s_map::SMap<ClassElt>,
268     pub smethods: s_map::SMap<ClassElt>,
269     pub construct: (Option<ClassElt>, ConsistentKind),
270     pub ancestors: s_map::SMap<DeclTy>,
271     pub req_ancestors: Vec<Requirement>,
272     pub req_ancestors_extends: s_set::SSet,
273     pub extends: s_set::SSet,
274     pub enum_type: Option<EnumType>,
275     pub sealed_whitelist: Option<s_set::SSet>,
276     pub decl_errors: Option<errors::Errors>,
279 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
280 pub enum TypeconstAbstractKind {
281     TCAbstract(Option<DeclTy>),
282     TCPartiallyAbstract,
283     TCConcrete,
286 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
287 pub struct TypeconstType {
288     pub abstract_: TypeconstAbstractKind,
289     pub visibility: Visibility,
290     pub name: nast::Sid,
291     pub constraint: Option<DeclTy>,
292     pub type_: Option<DeclTy>,
293     pub origin: String,
294     pub enforceable: (pos::Pos, bool),
295     pub reifiable: Option<pos::Pos>,
298 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
299 pub struct PuEnumType {
300     pub name: nast::Sid,
301     pub is_final: bool,
302     pub case_types: s_map::SMap<nast::Sid>,
303     pub case_values: s_map::SMap<(nast::Sid, DeclTy)>,
304     pub members: s_map::SMap<PuMemberType>,
307 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
308 pub struct PuMemberType {
309     pub atom: nast::Sid,
310     pub types: s_map::SMap<(nast::Sid, DeclTy)>,
313 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
314 pub struct EnumType {
315     pub base: DeclTy,
316     pub constraint: Option<DeclTy>,
319 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
320 pub struct TypedefType {
321     pub pos: pos::Pos,
322     pub vis: aast::TypedefVisibility,
323     pub tparams: Vec<DeclTparam>,
324     pub constraint: Option<DeclTy>,
325     pub type_: DeclTy,
326     pub decl_errors: Option<errors::Errors>,
329 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
330 pub struct Tparam<Ty> {
331     pub variance: ast_defs::Variance,
332     pub name: ast_defs::Id,
333     pub constraints: Vec<(ast_defs::ConstraintKind, Ty)>,
334     pub reified: aast::ReifyKind,
335     pub user_attributes: Vec<nast::UserAttribute>,
338 pub type DeclTparam = Tparam<DeclTy>;
340 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
341 pub struct WhereConstraint<Ty>(pub Ty, pub ast_defs::ConstraintKind, pub Ty);
343 pub type DeclWhereConstraint = WhereConstraint<DeclTy>;
345 #[derive(Clone, Debug, OcamlRep, Ocamlvalue)]
346 pub enum DeserializationError {
347     WrongPhase(String),
348     NotSupported(String),
349     DeserializationError(String),