Apply Ocamlvalue derive to oxidized aast related types
[hiphop-php.git] / hphp / hack / src / oxidized / gen / typing_defs.rs
blobc7e189ff7ddd5f8c5511959da53e6e1522e04d5f
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<<ba056df1b5addc42c4f6034ccb8b3bc5>>
7 //
8 // To regenerate this file, run:
9 //   hphp/hack/src/oxidized/regen.sh
11 use ocamlrep_derive::IntoOcamlRep;
13 use crate::aast;
14 use crate::ast_defs;
15 use crate::errors;
16 use crate::ident;
17 use crate::lazy;
18 use crate::nast;
19 use crate::pos;
20 use crate::s_map;
21 use crate::s_set;
23 pub use crate::typing_reason as reason;
25 #[derive(Clone, Debug, IntoOcamlRep)]
26 pub enum Visibility {
27     Vpublic,
28     Vprivate(String),
29     Vprotected(String),
32 #[derive(Clone, Debug, IntoOcamlRep)]
33 pub enum Exact {
34     Exact,
35     Nonexact,
38 #[derive(Clone, Debug, IntoOcamlRep)]
39 pub struct Ty(pub reason::Reason, pub Box<Ty_>);
41 #[derive(Clone, Debug, IntoOcamlRep)]
42 pub struct ShapeFieldType {
43     pub optional: bool,
44     pub ty: Ty,
47 #[derive(Clone, Debug, IntoOcamlRep)]
48 pub enum Ty_ {
49     Tthis,
50     Tapply(nast::Sid, Vec<Ty>),
51     Tgeneric(String),
52     Taccess(TaccessType),
53     Tarray(Option<Ty>, Option<Ty>),
54     Tdarray(Ty, Ty),
55     Tvarray(Ty),
56     TvarrayOrDarray(Ty),
57     Tmixed,
58     Tnothing,
59     Tlike(Ty),
60     Tany,
61     Tnonnull,
62     Tdynamic,
63     Terr,
64     Toption(Ty),
65     Tprim(aast::Tprim),
66     Tfun(FunType),
67     Ttuple(Vec<Ty>),
68     Tshape(ShapeKind, nast::shape_map::ShapeMap<ShapeFieldType>),
71 #[derive(Clone, Debug, IntoOcamlRep)]
72 pub enum ArrayKind {
73     AKany,
74     AKvarray(Ty),
75     AKdarray(Ty, Ty),
76     AKvarrayOrDarray(Ty),
77     AKvec(Ty),
78     AKmap(Ty, Ty),
79     AKempty,
82 #[derive(Clone, Debug, IntoOcamlRep)]
83 pub enum AbstractKind {
84     AKnewtype(String, Vec<Ty>),
85     AKgeneric(String),
86     AKdependent(DependentType),
89 #[derive(Clone, Debug, IntoOcamlRep)]
90 pub enum DependentType {
91     DTthis,
92     DTcls(String),
93     DTexpr(ident::Ident),
96 #[derive(Clone, Debug, IntoOcamlRep)]
97 pub struct TaccessType(pub Ty, pub Vec<nast::Sid>);
99 #[derive(Clone, Debug, IntoOcamlRep)]
100 pub enum ShapeKind {
101     ClosedShape,
102     OpenShape,
105 #[derive(Clone, Debug, IntoOcamlRep)]
106 pub enum Reactivity {
107     Nonreactive,
108     Local(Option<Ty>),
109     Shallow(Option<Ty>),
110     Reactive(Option<Ty>),
111     MaybeReactive(Box<Reactivity>),
112     RxVar(Option<Box<Reactivity>>),
115 #[derive(Clone, Debug, IntoOcamlRep)]
116 pub enum ValKind {
117     Lval,
118     LvalSubexpr,
119     Other,
122 #[derive(Clone, Debug, IntoOcamlRep)]
123 pub enum ParamMutability {
124     ParamOwnedMutable,
125     ParamBorrowedMutable,
126     ParamMaybeMutable,
129 #[derive(Clone, Debug, IntoOcamlRep)]
130 pub enum FunTparamsKind {
131     FTKtparams,
132     FTKinstantiatedTargs,
135 #[derive(Clone, Debug, IntoOcamlRep)]
136 pub struct FunType {
137     pub pos: pos::Pos,
138     pub deprecated: Option<String>,
139     pub abstract_: bool,
140     pub is_coroutine: bool,
141     pub arity: FunArity,
142     pub tparams: (Vec<Tparam>, FunTparamsKind),
143     pub where_constraints: Vec<WhereConstraint>,
144     pub params: FunParams,
145     pub ret: PossiblyEnforcedTy,
146     pub fun_kind: ast_defs::FunKind,
147     pub reactive: Reactivity,
148     pub return_disposable: bool,
149     pub mutability: Option<ParamMutability>,
150     pub returns_mutable: bool,
151     pub decl_errors: Option<errors::Errors>,
152     pub returns_void_to_rx: bool,
155 #[derive(Clone, Debug, IntoOcamlRep)]
156 pub enum FunArity {
157     Fstandard(isize, isize),
158     Fvariadic(isize, FunParam),
159     Fellipsis(isize, pos::Pos),
162 #[derive(Clone, Debug, IntoOcamlRep)]
163 pub enum ParamMode {
164     FPnormal,
165     FPref,
166     FPinout,
169 #[derive(Clone, Debug, IntoOcamlRep)]
170 pub enum ParamRxAnnotation {
171     ParamRxVar,
172     ParamRxIfImpl(Ty),
175 #[derive(Clone, Debug, IntoOcamlRep)]
176 pub struct PossiblyEnforcedTy {
177     pub enforced: bool,
178     pub type_: Ty,
181 #[derive(Clone, Debug, IntoOcamlRep)]
182 pub struct FunParam {
183     pub pos: pos::Pos,
184     pub name: Option<String>,
185     pub type_: PossiblyEnforcedTy,
186     pub kind: ParamMode,
187     pub accept_disposable: bool,
188     pub mutability: Option<ParamMutability>,
189     pub rx_annotation: Option<ParamRxAnnotation>,
192 pub type FunParams = Vec<FunParam>;
194 #[derive(Clone, Debug, IntoOcamlRep)]
195 pub enum XhpAttrTag {
196     Required,
197     Lateinit,
200 #[derive(Clone, Debug, IntoOcamlRep)]
201 pub struct XhpAttr {
202     pub tag: Option<XhpAttrTag>,
203     pub has_default: bool,
206 #[derive(Clone, Debug, IntoOcamlRep)]
207 pub struct ClassElt {
208     pub abstract_: bool,
209     pub final_: bool,
210     pub xhp_attr: Option<XhpAttr>,
211     pub override_: bool,
212     pub lsb: bool,
213     pub memoizelsb: bool,
214     pub synthesized: bool,
215     pub visibility: Visibility,
216     pub const_: bool,
217     pub lateinit: bool,
218     pub type_: lazy::Lazy<Ty>,
219     pub origin: String,
222 #[derive(Clone, Debug, IntoOcamlRep)]
223 pub struct ClassConst {
224     pub synthesized: bool,
225     pub abstract_: bool,
226     pub pos: pos::Pos,
227     pub type_: Ty,
228     pub visibility: Visibility,
229     pub expr: Option<nast::Expr>,
230     pub origin: String,
233 #[derive(Clone, Debug, IntoOcamlRep)]
234 pub struct Requirement(pub pos::Pos, pub Ty);
236 #[derive(Clone, Debug, IntoOcamlRep)]
237 pub enum ConsistentKind {
238     Inconsistent,
239     ConsistentConstruct,
240     FinalClass,
243 #[derive(Clone, Debug, IntoOcamlRep)]
244 pub struct ClassType {
245     pub need_init: bool,
246     pub members_fully_known: bool,
247     pub abstract_: bool,
248     pub final_: bool,
249     pub const_: bool,
250     pub ppl: bool,
251     pub deferred_init_members: s_set::SSet,
252     pub kind: ast_defs::ClassKind,
253     pub is_xhp: bool,
254     pub is_disposable: bool,
255     pub name: String,
256     pub pos: pos::Pos,
257     pub tparams: Vec<Tparam>,
258     pub where_constraints: Vec<WhereConstraint>,
259     pub consts: s_map::SMap<ClassConst>,
260     pub typeconsts: s_map::SMap<TypeconstType>,
261     pub props: s_map::SMap<ClassElt>,
262     pub sprops: s_map::SMap<ClassElt>,
263     pub methods: s_map::SMap<ClassElt>,
264     pub smethods: s_map::SMap<ClassElt>,
265     pub construct: (Option<ClassElt>, ConsistentKind),
266     pub ancestors: s_map::SMap<Ty>,
267     pub req_ancestors: Vec<Requirement>,
268     pub req_ancestors_extends: s_set::SSet,
269     pub extends: s_set::SSet,
270     pub enum_type: Option<EnumType>,
271     pub sealed_whitelist: Option<s_set::SSet>,
272     pub decl_errors: Option<errors::Errors>,
275 #[derive(Clone, Debug, IntoOcamlRep)]
276 pub enum TypeconstAbstractKind {
277     TCAbstract(Option<Ty>),
278     TCPartiallyAbstract,
279     TCConcrete,
282 #[derive(Clone, Debug, IntoOcamlRep)]
283 pub struct TypeconstType {
284     pub abstract_: TypeconstAbstractKind,
285     pub visibility: Visibility,
286     pub name: nast::Sid,
287     pub constraint: Option<Ty>,
288     pub type_: Option<Ty>,
289     pub origin: String,
290     pub enforceable: (pos::Pos, bool),
291     pub reifiable: Option<pos::Pos>,
294 #[derive(Clone, Debug, IntoOcamlRep)]
295 pub struct EnumType {
296     pub base: Ty,
297     pub constraint: Option<Ty>,
300 #[derive(Clone, Debug, IntoOcamlRep)]
301 pub struct TypedefType {
302     pub pos: pos::Pos,
303     pub vis: aast::TypedefVisibility,
304     pub tparams: Vec<Tparam>,
305     pub constraint: Option<Ty>,
306     pub type_: Ty,
307     pub decl_errors: Option<errors::Errors>,
310 #[derive(Clone, Debug, IntoOcamlRep)]
311 pub struct Tparam {
312     pub variance: ast_defs::Variance,
313     pub name: ast_defs::Id,
314     pub constraints: Vec<(ast_defs::ConstraintKind, Ty)>,
315     pub reified: aast::ReifyKind,
316     pub user_attributes: Vec<nast::UserAttribute>,
319 #[derive(Clone, Debug, IntoOcamlRep)]
320 pub struct WhereConstraint(pub Ty, pub ast_defs::ConstraintKind, pub Ty);
322 #[derive(Clone, Debug, IntoOcamlRep)]
323 pub enum DeserializationError {
324     WrongPhase(String),
325     NotSupported(String),
326     DeserializationError(String),