1 // Copyright (c) Facebook, Inc. and its affiliates.
3 // This source code is licensed under the MIT license found in the
4 // LICENSE file in the "hack" directory of this source tree.
6 // @generated SignedSource<<59caa083c81456c6dc5b200a6865e540>>
8 // To regenerate this file, run:
9 // hphp/hack/src/oxidized_regen.sh
11 use arena_trait::TrivialDrop;
12 use no_pos_hash::NoPosHash;
13 use ocamlrep_derive::FromOcamlRep;
14 use ocamlrep_derive::FromOcamlRepIn;
15 use ocamlrep_derive::ToOcamlRep;
16 use serde::Deserialize;
19 #[allow(unused_imports)]
23 pub use doc_comment::DocComment;
25 /// Aast.program represents the top-level definitions in a Hack program.
26 /// ex: Expression annotation type (when typechecking, the inferred type)
27 /// fb: Function body tag (e.g. has naming occurred)
28 /// en: Environment (tracking state inside functions and classes)
29 /// hi: Hint annotation (when typechecking it will be the localized type hint or the
30 /// inferred missing type if the hint is missing)
31 pub type Program<Ex, Fb, En, Hi> = Vec<Def<Ex, Fb, En, Hi>>;
47 pub struct Stmt<Ex, Fb, En, Hi>(pub Pos, pub Stmt_<Ex, Fb, En, Hi>);
63 pub enum Stmt_<Ex, Fb, En, Hi> {
64 /// Marker for a switch statement that falls through.
68 /// Standalone expression.
71 Expr(Box<Expr<Ex, Fb, En, Hi>>),
72 /// Break inside a loop or switch statement.
76 /// Continue inside a loop or switch statement.
80 /// Throw an exception.
83 Throw(Box<Expr<Ex, Fb, En, Hi>>),
84 /// Return, with an optional value.
88 Return(Box<Option<Expr<Ex, Fb, En, Hi>>>),
89 /// Yield break, terminating the current generator. This behaves like
90 /// return; but is more explicit, and ensures the function is treated
95 /// Concurrent block. All the await expressions are awaited at the
96 /// same time, similar to genva().
98 /// We store the desugared form. In the below example, the list is:
99 /// [('__tmp$1', f()), (__tmp$2, g()), (None, h())]
100 /// and the block assigns the temporary variables back to the locals.
101 /// { $foo = __tmp$1; $bar = __tmp$2; }
104 /// $foo = await f();
105 /// $bar = await g();
110 Vec<(Option<Lid>, Expr<Ex, Fb, En, Hi>)>,
111 Block<Ex, Fb, En, Hi>,
116 /// if ($foo) { ... } else { ... }
119 Expr<Ex, Fb, En, Hi>,
120 Block<Ex, Fb, En, Hi>,
121 Block<Ex, Fb, En, Hi>,
129 Do(Box<(Block<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>)>),
135 While(Box<(Expr<Ex, Fb, En, Hi>, Block<Ex, Fb, En, Hi>)>),
136 /// Initialize a value that is automatically disposed of.
138 /// using $foo = bar(); // disposed at the end of the function
139 /// using ($foo = bar(), $baz = quux()) {} // disposed after the block
140 Using(Box<UsingStmt<Ex, Fb, En, Hi>>),
141 /// For loop. The initializer and increment parts can include
142 /// multiple comma-separated statements. The termination condition is
145 /// for ($i = 0; $i < 100; $i++) { ... }
146 /// for ($x = 0, $y = 0; ; $x++, $y++) { ... }
149 Vec<Expr<Ex, Fb, En, Hi>>,
150 Option<Expr<Ex, Fb, En, Hi>>,
151 Vec<Expr<Ex, Fb, En, Hi>>,
152 Block<Ex, Fb, En, Hi>,
155 /// Switch statement.
165 Switch(Box<(Expr<Ex, Fb, En, Hi>, Vec<Case<Ex, Fb, En, Hi>>)>),
168 /// foreach ($items as $item) { ... }
169 /// foreach ($items as $key => value) { ... }
170 /// foreach ($items await as $item) { ... } // AsyncIterator<_>
171 /// foreach ($items await as $key => value) { ... } // AsyncKeyedIterator<_>
174 Expr<Ex, Fb, En, Hi>,
175 AsExpr<Ex, Fb, En, Hi>,
176 Block<Ex, Fb, En, Hi>,
179 /// Try statement, with catch blocks and a finally block.
183 /// } catch (SomeException $e) {
190 Block<Ex, Fb, En, Hi>,
191 Vec<Catch<Ex, Fb, En, Hi>>,
192 Block<Ex, Fb, En, Hi>,
195 /// No-op, the empty statement.
199 /// if ($foo) {} // the else is Noop here
201 /// Block, a list of statements in curly braces.
204 Block(Block<Ex, Fb, En, Hi>),
205 /// The mode tag at the beginning of a file.
206 /// TODO: this really belongs in def.
209 Markup(Box<Pstring>),
210 /// Used in IFC to track type inference environments. Not user
212 AssertEnv(Box<(EnvAnnot, LocalIdMap<Ex>)>),
235 impl TrivialDrop for EnvAnnot {}
251 pub struct UsingStmt<Ex, Fb, En, Hi> {
252 pub is_block_scoped: bool,
254 pub exprs: (Pos, Vec<Expr<Ex, Fb, En, Hi>>),
255 pub block: Block<Ex, Fb, En, Hi>,
272 pub enum AsExpr<Ex, Fb, En, Hi> {
273 AsV(Expr<Ex, Fb, En, Hi>),
274 AsKv(Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>),
275 AwaitAsV(Pos, Expr<Ex, Fb, En, Hi>),
276 AwaitAsKv(Pos, Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>),
279 pub type Block<Ex, Fb, En, Hi> = Vec<Stmt<Ex, Fb, En, Hi>>;
295 pub struct ClassId<Ex, Fb, En, Hi>(pub Ex, pub ClassId_<Ex, Fb, En, Hi>);
297 /// Class ID, used in things like instantiation and static property access.
312 pub enum ClassId_<Ex, Fb, En, Hi> {
313 /// The class ID of the parent of the lexically scoped class.
315 /// In a trait, it is the parent class ID of the using class.
317 /// parent::some_meth()
318 /// parent::$prop = 1;
321 /// The class ID of the lexically scoped class.
323 /// In a trait, it is the class ID of the using class.
325 /// self::some_meth()
329 /// The class ID of the late static bound class.
331 /// https://www.php.net/manual/en/language.oop5.late-static-bindings.php
333 /// In a trait, it is the late static bound class ID of the using class.
335 /// static::some_meth()
336 /// static::$prop = 1;
339 /// Dynamic class name.
341 /// TODO: Syntactically this can only be an Lvar/This/Lplacehodller.
342 /// We should use lid rather than expr.
344 /// // Assume $d has type dynamic.
348 CIexpr(Expr<Ex, Fb, En, Hi>),
349 /// Explicit class name. This is the common case.
351 /// Foop::some_meth()
371 pub struct Expr<Ex, Fb, En, Hi>(pub Ex, pub Expr_<Ex, Fb, En, Hi>);
387 pub enum CollectionTarg<Hi> {
388 CollectionTV(Targ<Hi>),
389 CollectionTKV(Targ<Hi>, Targ<Hi>),
406 pub enum FunctionPtrId<Ex, Fb, En, Hi> {
408 FPClassConst(ClassId<Ex, Fb, En, Hi>, Pstring),
425 pub struct ExpressionTree<Ex, Fb, En, Hi> {
427 pub desugared_expr: Expr<Ex, Fb, En, Hi>,
444 pub enum Expr_<Ex, Fb, En, Hi> {
447 /// darray['x' => 0, 'y' => 1]
448 /// darray<string, int>['x' => 0, 'y' => 1]
451 Option<(Targ<Hi>, Targ<Hi>)>,
452 Vec<(Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>)>,
457 /// varray['hello', 'world']
458 /// varray<string>['hello', 'world']
459 Varray(Box<(Option<Targ<Hi>>, Vec<Expr<Ex, Fb, En, Hi>>)>),
462 /// shape('x' => 1, 'y' => 2)
463 Shape(Vec<(ast_defs::ShapeFieldName, Expr<Ex, Fb, En, Hi>)>),
464 /// Collection literal for indexable structures.
468 /// Set<string> {'foo', 'bar'}
471 ValCollection(Box<(VcKind, Option<Targ<Hi>>, Vec<Expr<Ex, Fb, En, Hi>>)>),
472 /// Collection literal for key-value structures.
474 /// dict['x' => 1, 'y' => 2]
475 /// Map<int, string> {}
480 Option<(Targ<Hi>, Targ<Hi>)>,
481 Vec<Field<Ex, Fb, En, Hi>>,
488 /// The local variable representing the current class instance.
500 /// The empty expression.
502 /// list(, $y) = vec[1, 2] // Omitted is the first expression inside list()
504 /// An identifier. Used for method names and global constants.
507 /// $x->foo() // id: "foo"
513 /// The extra variable in a pipe expression.
516 Dollardollar(Box<Lid>),
517 /// Clone expression.
520 Clone(Box<Expr<Ex, Fb, En, Hi>>),
525 ArrayGet(Box<(Expr<Ex, Fb, En, Hi>, Option<Expr<Ex, Fb, En, Hi>>)>),
526 /// Instance property or method access. is_prop_call is always
527 /// false, except when inside a call is accessing a property.
529 /// $foo->bar // (Obj_get false) property access
530 /// $foo->bar() // (Call (Obj_get false)) method call
531 /// ($foo->bar)() // (Call (Obj_get true)) call lambda stored in property
532 /// $foo?->bar // nullsafe access
535 Expr<Ex, Fb, En, Hi>,
536 Expr<Ex, Fb, En, Hi>,
541 /// Static property access.
544 /// $some_classname::$bar
545 /// Foo::${$bar} // only in partial mode
546 ClassGet(Box<(ClassId<Ex, Fb, En, Hi>, ClassGetExpr<Ex, Fb, En, Hi>, bool)>),
547 /// Class constant or static method call. As a standalone expression,
548 /// this is a class constant. Inside a Call node, this is a static
551 /// This is not ambiguous, because constants are not allowed to
552 /// contain functions.
554 /// Foo::some_const // Class_const
555 /// Foo::someStaticMeth() // Call (Class_const)
557 /// This syntax is used for both static and instance methods when
558 /// calling the implementation on the superclass.
560 /// parent::someStaticMeth()
561 /// parent::someInstanceMeth()
562 ClassConst(Box<(ClassId<Ex, Fb, En, Hi>, Pstring)>),
563 /// Function or method call.
567 /// foo<int>(1, 2, ...$rest)
570 /// async { return 1; }
572 /// (async () ==> { return 1; })()
575 Expr<Ex, Fb, En, Hi>,
577 Vec<Expr<Ex, Fb, En, Hi>>,
578 Option<Expr<Ex, Fb, En, Hi>>,
581 /// A reference to a function or method.
584 /// FooCls::meth<int>
585 FunctionPointer(Box<(FunctionPtrId<Ex, Fb, En, Hi>, Vec<Targ<Hi>>)>),
590 /// 0xBEEF // hexadecimal
591 /// 0b11111111 // binary
611 String(bstr::BString),
612 /// Interpolated string literal.
614 /// "hello $foo $bar"
619 String2(Vec<Expr<Ex, Fb, En, Hi>>),
620 /// Prefixed string literal. Only used for regular expressions.
623 PrefixedString(Box<(String, Expr<Ex, Fb, En, Hi>)>),
624 /// Yield expression. The enclosing function should have an Iterator
627 /// yield $foo // enclosing function returns an Iterator
628 /// yield $foo => $bar // enclosing function returns a KeyedIterator
629 Yield(Box<Afield<Ex, Fb, En, Hi>>),
630 /// Await expression.
633 Await(Box<Expr<Ex, Fb, En, Hi>>),
634 /// Readonly expression.
637 ReadonlyExpr(Box<Expr<Ex, Fb, En, Hi>>),
638 /// List expression, only used in destructuring. Allows any arbitrary
639 /// lvalue as a subexpression. May also nest.
641 /// Note that tuple(1, 2) is lowered to a Call, but naming converts it to a List.
642 /// TODO: Define a separate AAST node for tuple.
644 /// list($x, $y) = vec[1, 2];
645 /// list(, $y) = vec[1, 2]; // skipping items
646 /// list(list($x)) = vec[vec[1]]; // nesting
647 /// list($v[0], $x[], $y->foo) = $blah;
648 List(Vec<Expr<Ex, Fb, En, Hi>>),
649 /// Cast expression, converting a value to a different type. Only
650 /// primitive types are supported in the hint position.
654 Cast(Box<(Hint, Expr<Ex, Fb, En, Hi>)>),
660 Unop(Box<(ast_defs::Uop, Expr<Ex, Fb, En, Hi>)>),
664 Binop(Box<(ast_defs::Bop, Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>)>),
665 /// Pipe expression. The lid is the ID of the $$ that is implicitly
666 /// declared by this pipe.
668 /// See also Dollardollar.
670 /// $foo |> bar() // equivalent: bar($foo)
671 /// $foo |> bar(1, $$) // equivalent: bar(1, $foo)
672 Pipe(Box<(Lid, Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>)>),
673 /// Ternary operator, or elvis operator.
675 /// $foo ? $bar : $baz // ternary
676 /// $foo ?: $baz // elvis
679 Expr<Ex, Fb, En, Hi>,
680 Option<Expr<Ex, Fb, En, Hi>>,
681 Expr<Ex, Fb, En, Hi>,
687 Is(Box<(Expr<Ex, Fb, En, Hi>, Hint)>),
692 As(Box<(Expr<Ex, Fb, En, Hi>, Hint, bool)>),
696 /// new Foo<int, T>();
697 /// new Foo('blah', ...$rest);
700 ClassId<Ex, Fb, En, Hi>,
702 Vec<Expr<Ex, Fb, En, Hi>>,
703 Option<Expr<Ex, Fb, En, Hi>>,
709 /// MyRecord['x' => $foo, 'y' => $bar]
710 Record(Box<(Sid, Vec<(Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>)>)>),
711 /// PHP-style lambda. Does not capture variables unless explicitly
714 /// Mnemonic: 'expanded lambda', since we can desugar Lfun to Efun.
716 /// function($x) { return $x; }
717 /// function(int $x): int { return $x; }
718 /// function($x) use ($y) { return $y; }
719 /// function($x): int use ($y, $z) { return $x + $y + $z; }
720 Efun(Box<(Fun_<Ex, Fb, En, Hi>, Vec<Lid>)>),
721 /// Hack lambda. Captures variables automatically.
724 /// (int $x): int ==> $x + $other
725 /// ($x, $y) ==> { return $x + $y; }
726 Lfun(Box<(Fun_<Ex, Fb, En, Hi>, Vec<Lid>)>),
727 /// XHP expression. May contain interpolated expressions.
729 /// <foo x="hello" y={$foo}>hello {$bar}</foo>
733 Vec<XhpAttribute<Ex, Fb, En, Hi>>,
734 Vec<Expr<Ex, Fb, En, Hi>>,
737 /// Explicit calling convention, used for inout. Inout supports any lvalue.
739 /// TODO: This could be a flag on parameters in Call.
742 Callconv(Box<(ast_defs::ParamKind, Expr<Ex, Fb, En, Hi>)>),
743 /// Include or require expression.
745 /// require('foo.php')
746 /// require_once('foo.php')
747 /// include('foo.php')
748 /// include_once('foo.php')
749 Import(Box<(ImportFlavor, Expr<Ex, Fb, En, Hi>)>),
750 /// Collection literal.
752 /// TODO: T38184446 this is redundant with ValCollection/KeyValCollection.
755 Collection(Box<(Sid, Option<CollectionTarg<Hi>>, Vec<Afield<Ex, Fb, En, Hi>>)>),
756 /// Expression tree literal. Expression trees are not evaluated at
757 /// runtime, but desugared to an expression representing the code.
760 /// Foo`$x ==> $x * ${$value}` // splicing $value
761 ExpressionTree(Box<ExpressionTree<Ex, Fb, En, Hi>>),
762 /// Placeholder local variable.
765 Lplaceholder(Box<Pos>),
766 /// Global function reference.
770 /// Instance method reference on a specific instance.
772 /// TODO: This is only created in naming, and ought to happen in
773 /// lowering or be removed. The emitter just sees a normal Call.
775 /// inst_meth($f, 'some_meth') // equivalent: $f->some_meth<>
776 MethodId(Box<(Expr<Ex, Fb, En, Hi>, Pstring)>),
777 /// Instance method reference that can be called with an instance.
779 /// meth_caller(FooClass::class, 'some_meth')
780 /// meth_caller('FooClass', 'some_meth')
782 /// These examples are equivalent to:
784 /// (FooClass $f, ...$args) ==> $f->some_meth(...$args)
785 MethodCaller(Box<(Sid, Pstring)>),
786 /// Static method reference.
788 /// class_meth('FooClass', 'some_static_meth')
789 /// // equivalent: FooClass::some_static_meth<>
790 SmethodId(Box<(ClassId<Ex, Fb, En, Hi>, Pstring)>),
793 /// Pair {$foo, $bar}
796 Option<(Targ<Hi>, Targ<Hi>)>,
797 Expr<Ex, Fb, En, Hi>,
798 Expr<Ex, Fb, En, Hi>,
801 /// Expression tree splice expression. Only valid inside an
802 /// expression tree literal (backticks).
805 ETSplice(Box<Expr<Ex, Fb, En, Hi>>),
806 /// Enum atom used for enum classes.
810 /// Placeholder for expressions that aren't understood by parts of
815 /// Annotation used to record failure in subtyping or coercion of an
816 /// expression and calls to [unsafe_cast] or [enforced_cast].
818 /// The [hole_source] indicates whether this came from an
819 /// explicit call to [unsafe_cast] or [enforced_cast] or was
820 /// generated during typing.
821 Hole(Box<(Expr<Ex, Fb, En, Hi>, Hi, Hi, HoleSource)>),
838 pub enum ClassGetExpr<Ex, Fb, En, Hi> {
840 CGexpr(Expr<Ex, Fb, En, Hi>),
857 pub enum Case<Ex, Fb, En, Hi> {
858 Default(Pos, Block<Ex, Fb, En, Hi>),
859 Case(Expr<Ex, Fb, En, Hi>, Block<Ex, Fb, En, Hi>),
876 pub struct Catch<Ex, Fb, En, Hi>(pub Sid, pub Lid, pub Block<Ex, Fb, En, Hi>);
892 pub struct Field<Ex, Fb, En, Hi>(pub Expr<Ex, Fb, En, Hi>, pub Expr<Ex, Fb, En, Hi>);
908 pub enum Afield<Ex, Fb, En, Hi> {
909 AFvalue(Expr<Ex, Fb, En, Hi>),
910 AFkvalue(Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>),
927 pub struct XhpSimple<Ex, Fb, En, Hi> {
930 pub expr: Expr<Ex, Fb, En, Hi>,
947 pub enum XhpAttribute<Ex, Fb, En, Hi> {
948 XhpSimple(XhpSimple<Ex, Fb, En, Hi>),
949 XhpSpread(Expr<Ex, Fb, En, Hi>),
952 pub type IsVariadic = bool;
968 pub struct FunParam<Ex, Fb, En, Hi> {
970 pub type_hint: TypeHint<Hi>,
971 pub is_variadic: IsVariadic,
974 pub expr: Option<Expr<Ex, Fb, En, Hi>>,
975 pub readonly: Option<ast_defs::ReadonlyKind>,
976 pub callconv: Option<ast_defs::ParamKind>,
977 pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
978 pub visibility: Option<Visibility>,
981 /// Does this function/method take a variable number of arguments?
996 pub enum FunVariadicity<Ex, Fb, En, Hi> {
997 /// Named variadic argument.
999 /// function foo(int ...$args): void {}
1000 FVvariadicArg(FunParam<Ex, Fb, En, Hi>),
1001 /// Unnamed variaidic argument. Partial mode only.
1003 /// function foo(...): void {}
1005 /// Function is not variadic, takes an exact number of arguments.
1023 pub struct Fun_<Ex, Fb, En, Hi> {
1026 pub mode: file_info::Mode,
1027 pub readonly_ret: Option<ast_defs::ReadonlyKind>,
1028 pub ret: TypeHint<Hi>,
1030 pub tparams: Vec<Tparam<Ex, Fb, En, Hi>>,
1031 pub where_constraints: Vec<WhereConstraintHint>,
1032 pub variadic: FunVariadicity<Ex, Fb, En, Hi>,
1033 pub params: Vec<FunParam<Ex, Fb, En, Hi>>,
1034 pub ctxs: Option<Contexts>,
1035 pub unsafe_ctxs: Option<Contexts>,
1036 pub body: FuncBody<Ex, Fb, En, Hi>,
1037 pub fun_kind: ast_defs::FunKind,
1038 pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1039 pub file_attributes: Vec<FileAttribute<Ex, Fb, En, Hi>>,
1040 /// true if this declaration has no body because it is an
1041 /// external function declaration (e.g. from an HHI file)
1043 pub namespace: Nsenv,
1044 pub doc_comment: Option<DocComment>,
1048 /// Naming has two phases and the annotation helps to indicate the phase.
1049 /// In the first pass, it will perform naming on everything except for function
1050 /// and method bodies and collect information needed. Then, another round of
1051 /// naming is performed where function bodies are named. Thus, naming will
1052 /// have named and unnamed variants of the annotation.
1053 /// See BodyNamingAnnotation in nast.ml and the comment in naming.ml
1068 pub struct FuncBody<Ex, Fb, En, Hi> {
1069 pub ast: Block<Ex, Fb, En, Hi>,
1073 /// A type annotation is two things:
1074 /// - the localized hint, or if the hint is missing, the inferred type
1075 /// - The typehint associated to this expression if it exists
1090 pub struct TypeHint<Hi>(pub Hi, pub TypeHint_);
1092 /// Explicit type argument to function, constructor, or collection literal.
1093 /// 'hi = unit in NAST
1094 /// 'hi = Typing_defs.(locl ty) in TAST,
1095 /// and is used to record inferred type arguments, with wildcard hint.
1110 pub struct Targ<Hi>(pub Hi, pub Hint);
1112 pub type TypeHint_ = Option<Hint>;
1128 pub struct UserAttribute<Ex, Fb, En, Hi> {
1130 /// user attributes are restricted to scalar values
1131 pub params: Vec<Expr<Ex, Fb, En, Hi>>,
1148 pub struct FileAttribute<Ex, Fb, En, Hi> {
1149 pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1150 pub namespace: Nsenv,
1167 pub struct Tparam<Ex, Fb, En, Hi> {
1168 pub variance: ast_defs::Variance,
1170 pub parameters: Vec<Tparam<Ex, Fb, En, Hi>>,
1171 pub constraints: Vec<(ast_defs::ConstraintKind, Hint)>,
1172 pub reified: ReifyKind,
1173 pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1190 pub struct UseAsAlias(
1194 pub Vec<UseAsVisibility>,
1211 pub struct InsteadofAlias(pub Sid, pub Pstring, pub Vec<Sid>);
1213 pub type IsExtends = bool;
1250 pub struct Class_<Ex, Fb, En, Hi> {
1253 pub mode: file_info::Mode,
1256 pub has_xhp_keyword: bool,
1257 pub kind: ast_defs::ClassKind,
1259 /// The type parameters of a class A<T> (T is the parameter)
1260 pub tparams: Vec<Tparam<Ex, Fb, En, Hi>>,
1261 pub extends: Vec<ClassHint>,
1262 pub uses: Vec<TraitHint>,
1263 /// PHP feature not supported in hack but required
1264 /// because we have runtime support.
1265 pub use_as_alias: Vec<UseAsAlias>,
1266 /// PHP feature not supported in hack but required
1267 /// because we have runtime support.
1268 pub insteadof_alias: Vec<InsteadofAlias>,
1269 pub xhp_attr_uses: Vec<XhpAttrHint>,
1270 pub xhp_category: Option<(Pos, Vec<Pstring>)>,
1271 pub reqs: Vec<(ClassHint, IsExtends)>,
1272 pub implements: Vec<ClassHint>,
1273 pub implements_dynamic: bool,
1274 pub where_constraints: Vec<WhereConstraintHint>,
1275 pub consts: Vec<ClassConst<Ex, Fb, En, Hi>>,
1276 pub typeconsts: Vec<ClassTypeconst<Ex, Fb, En, Hi>>,
1277 pub vars: Vec<ClassVar<Ex, Fb, En, Hi>>,
1278 pub methods: Vec<Method_<Ex, Fb, En, Hi>>,
1279 pub attributes: Vec<ClassAttr<Ex, Fb, En, Hi>>,
1280 pub xhp_children: Vec<(Pos, XhpChild)>,
1281 pub xhp_attrs: Vec<XhpAttr<Ex, Fb, En, Hi>>,
1282 pub namespace: Nsenv,
1283 pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1284 pub file_attributes: Vec<FileAttribute<Ex, Fb, En, Hi>>,
1285 pub enum_: Option<Enum_>,
1286 pub doc_comment: Option<DocComment>,
1287 pub emit_id: Option<EmitId>,
1290 pub type ClassHint = Hint;
1292 pub type TraitHint = Hint;
1294 pub type XhpAttrHint = Hint;
1312 pub enum XhpAttrTag {
1316 impl TrivialDrop for XhpAttrTag {}
1332 pub struct XhpAttr<Ex, Fb, En, Hi>(
1334 pub ClassVar<Ex, Fb, En, Hi>,
1335 pub Option<XhpAttrTag>,
1336 pub Option<(Pos, Vec<Expr<Ex, Fb, En, Hi>>)>,
1353 pub enum ClassAttr<Ex, Fb, En, Hi> {
1355 CAField(CaField<Ex, Fb, En, Hi>),
1372 pub struct CaField<Ex, Fb, En, Hi> {
1375 pub value: Option<Expr<Ex, Fb, En, Hi>>,
1395 CAEnum(Vec<String>),
1412 pub struct ClassConst<Ex, Fb, En, Hi> {
1413 pub type_: Option<Hint>,
1415 /// expr = None indicates an abstract const
1416 pub expr: Option<Expr<Ex, Fb, En, Hi>>,
1417 pub doc_comment: Option<DocComment>,
1434 pub enum TypeconstAbstractKind {
1435 TCAbstract(Option<Hint>),
1436 TCPartiallyAbstract,
1440 /// This represents a type const definition. If a type const is abstract then
1441 /// then the type hint acts as a constraint. Any concrete definition of the
1442 /// type const must satisfy the constraint.
1444 /// If the type const is not abstract then a type must be specified.
1459 pub struct ClassTypeconst<Ex, Fb, En, Hi> {
1460 pub abstract_: TypeconstAbstractKind,
1462 pub as_constraint: Option<Hint>,
1463 pub super_constraint: Option<Hint>,
1464 pub type_: Option<Hint>,
1465 pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1467 pub doc_comment: Option<DocComment>,
1487 pub struct XhpAttrInfo {
1488 pub xai_tag: Option<XhpAttrTag>,
1505 pub struct ClassVar<Ex, Fb, En, Hi> {
1507 pub xhp_attr: Option<XhpAttrInfo>,
1508 pub abstract_: bool,
1510 pub visibility: Visibility,
1511 pub type_: TypeHint<Hi>,
1513 pub expr: Option<Expr<Ex, Fb, En, Hi>>,
1514 pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1515 pub doc_comment: Option<DocComment>,
1516 pub is_promoted_variadic: bool,
1517 pub is_static: bool,
1535 pub struct Method_<Ex, Fb, En, Hi> {
1539 pub abstract_: bool,
1541 pub readonly_this: bool,
1542 pub visibility: Visibility,
1544 pub tparams: Vec<Tparam<Ex, Fb, En, Hi>>,
1545 pub where_constraints: Vec<WhereConstraintHint>,
1546 pub variadic: FunVariadicity<Ex, Fb, En, Hi>,
1547 pub params: Vec<FunParam<Ex, Fb, En, Hi>>,
1548 pub ctxs: Option<Contexts>,
1549 pub unsafe_ctxs: Option<Contexts>,
1550 pub body: FuncBody<Ex, Fb, En, Hi>,
1551 pub fun_kind: ast_defs::FunKind,
1552 pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1553 pub readonly_ret: Option<ast_defs::ReadonlyKind>,
1554 pub ret: TypeHint<Hi>,
1555 /// true if this declaration has no body because it is an external method
1556 /// declaration (e.g. from an HHI file)
1558 pub doc_comment: Option<DocComment>,
1561 pub type Nsenv = ocamlrep::rc::RcOc<namespace_env::Env>;
1577 pub struct Typedef<Ex, Fb, En, Hi> {
1580 pub tparams: Vec<Tparam<Ex, Fb, En, Hi>>,
1581 pub constraint: Option<Hint>,
1583 pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1584 pub mode: file_info::Mode,
1585 pub vis: TypedefVisibility,
1586 pub namespace: Nsenv,
1588 pub emit_id: Option<EmitId>,
1605 pub struct Gconst<Ex, Fb, En, Hi> {
1607 pub mode: file_info::Mode,
1609 pub type_: Option<Hint>,
1610 pub value: Expr<Ex, Fb, En, Hi>,
1611 pub namespace: Nsenv,
1613 pub emit_id: Option<EmitId>,
1630 pub struct RecordDef<Ex, Fb, En, Hi> {
1633 pub extends: Option<RecordHint>,
1634 pub abstract_: bool,
1635 pub fields: Vec<(Sid, Hint, Option<Expr<Ex, Fb, En, Hi>>)>,
1636 pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1637 pub namespace: Nsenv,
1639 pub doc_comment: Option<DocComment>,
1640 pub emit_id: Option<EmitId>,
1643 pub type RecordHint = Hint;
1645 pub type FunDef<Ex, Fb, En, Hi> = Fun_<Ex, Fb, En, Hi>;
1661 pub enum Def<Ex, Fb, En, Hi> {
1662 Fun(Box<FunDef<Ex, Fb, En, Hi>>),
1663 Class(Box<Class_<Ex, Fb, En, Hi>>),
1664 RecordDef(Box<RecordDef<Ex, Fb, En, Hi>>),
1665 Stmt(Box<Stmt<Ex, Fb, En, Hi>>),
1666 Typedef(Box<Typedef<Ex, Fb, En, Hi>>),
1667 Constant(Box<Gconst<Ex, Fb, En, Hi>>),
1668 Namespace(Box<(Sid, Program<Ex, Fb, En, Hi>)>),
1669 NamespaceUse(Vec<(NsKind, Sid, Sid)>),
1670 SetNamespaceEnv(Box<Nsenv>),
1671 FileAttributes(Box<FileAttribute<Ex, Fb, En, Hi>>),
1693 NSClassAndNamespace,
1697 impl TrivialDrop for NsKind {}
1715 pub enum HoleSource {
1720 impl TrivialDrop for HoleSource {}
1736 pub enum BreakContinueLevel {
1737 LevelOk(Option<isize>),