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<<2c3ee08ffff7a51d30136326a6f6b047>>
8 // To regenerate this file, run:
9 // hphp/hack/src/oxidize_regen.sh
11 use arena_trait::TrivialDrop;
12 use no_pos_hash::NoPosHash;
13 use ocamlrep_derive::FromOcamlRepIn;
14 use ocamlrep_derive::ToOcamlRep;
17 #[allow(unused_imports)]
21 pub use doc_comment::DocComment;
23 /// Aast.program represents the top-level definitions in a Hack program.
24 /// ex: Expression annotation type (when typechecking, the inferred type)
25 /// fb: Function body tag (e.g. has naming occurred)
26 /// en: Environment (tracking state inside functions and classes)
27 /// hi: Hint annotation (when typechecking it will be the localized type hint or the
28 /// inferred missing type if the hint is missing)
29 pub type Program<'a, Ex, Fb, En, Hi> = [Def<'a, Ex, Fb, En, Hi>];
44 pub struct Stmt<'a, Ex, Fb, En, Hi>(pub &'a Pos<'a>, pub Stmt_<'a, Ex, Fb, En, Hi>);
45 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
46 for Stmt<'a, Ex, Fb, En, Hi>
64 pub enum Stmt_<'a, Ex, Fb, En, Hi> {
65 /// Marker for a switch statement that falls through.
69 /// Standalone expression.
72 Expr(&'a Expr<'a, Ex, Fb, En, Hi>),
73 /// Break inside a loop or switch statement.
77 /// Continue inside a loop or switch statement.
81 /// Throw an exception.
84 Throw(&'a Expr<'a, Ex, Fb, En, Hi>),
85 /// Return, with an optional value.
89 Return(Option<&'a Expr<'a, Ex, Fb, En, Hi>>),
90 /// Yield break, terminating the current generator. This behaves like
91 /// return; but is more explicit, and ensures the function is treated
96 /// Concurrent block. All the await expressions are awaited at the
97 /// same time, similar to genva().
99 /// We store the desugared form. In the below example, the list is:
100 /// [('__tmp$1', f()), (__tmp$2, g()), (None, h())]
101 /// and the block assigns the temporary variables back to the locals.
102 /// { $foo = __tmp$1; $bar = __tmp$2; }
105 /// $foo = await f();
106 /// $bar = await g();
111 &'a [(Option<&'a Lid<'a>>, &'a Expr<'a, Ex, Fb, En, Hi>)],
112 &'a Block<'a, Ex, Fb, En, Hi>,
117 /// if ($foo) { ... } else { ... }
120 &'a Expr<'a, Ex, Fb, En, Hi>,
121 &'a Block<'a, Ex, Fb, En, Hi>,
122 &'a Block<'a, Ex, Fb, En, Hi>,
130 Do(&'a (&'a Block<'a, Ex, Fb, En, Hi>, &'a Expr<'a, Ex, Fb, En, Hi>)),
136 While(&'a (&'a Expr<'a, Ex, Fb, En, Hi>, &'a Block<'a, Ex, Fb, En, Hi>)),
137 /// Initialize a value that is automatically disposed of.
139 /// using $foo = bar(); // disposed at the end of the function
140 /// using ($foo = bar(), $baz = quux()) {} // disposed after the block
141 Using(&'a UsingStmt<'a, Ex, Fb, En, Hi>),
142 /// For loop. The initializer and increment parts can include
143 /// multiple comma-separated statements. The termination condition is
146 /// for ($i = 0; $i < 100; $i++) { ... }
147 /// for ($x = 0, $y = 0; ; $x++, $y++) { ... }
150 &'a [&'a Expr<'a, Ex, Fb, En, Hi>],
151 Option<&'a Expr<'a, Ex, Fb, En, Hi>>,
152 &'a [&'a Expr<'a, Ex, Fb, En, Hi>],
153 &'a Block<'a, Ex, Fb, En, Hi>,
156 /// Switch statement.
166 Switch(&'a (&'a Expr<'a, Ex, Fb, En, Hi>, &'a [Case<'a, Ex, Fb, En, Hi>])),
169 /// foreach ($items as $item) { ... }
170 /// foreach ($items as $key => value) { ... }
171 /// foreach ($items await as $item) { ... } // AsyncIterator<_>
172 /// foreach ($items await as $key => value) { ... } // AsyncKeyedIterator<_>
175 &'a Expr<'a, Ex, Fb, En, Hi>,
176 AsExpr<'a, Ex, Fb, En, Hi>,
177 &'a Block<'a, Ex, Fb, En, Hi>,
180 /// Try statement, with catch blocks and a finally block.
184 /// } catch (SomeException $e) {
191 &'a Block<'a, Ex, Fb, En, Hi>,
192 &'a [&'a Catch<'a, Ex, Fb, En, Hi>],
193 &'a Block<'a, Ex, Fb, En, Hi>,
196 /// No-op, the empty statement.
198 /// if ($foo) {} // the else is Noop here
200 /// Block, a list of statements in curly braces.
203 Block(&'a Block<'a, Ex, Fb, En, Hi>),
204 /// The mode tag at the beginning of a file.
205 /// TODO: this really belongs in def.
208 Markup(&'a Pstring<'a>),
209 /// Used in IFC to track type inference environments. Not user
211 AssertEnv(&'a (oxidized::aast::EnvAnnot, &'a LocalIdMap<'a, Ex>)),
213 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
214 for Stmt_<'a, Ex, Fb, En, Hi>
218 pub use oxidized::aast::EnvAnnot;
233 pub struct UsingStmt<'a, Ex, Fb, En, Hi> {
234 pub is_block_scoped: bool,
236 pub exprs: (&'a Pos<'a>, &'a [&'a Expr<'a, Ex, Fb, En, Hi>]),
237 pub block: &'a Block<'a, Ex, Fb, En, Hi>,
239 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
240 for UsingStmt<'a, Ex, Fb, En, Hi>
258 pub enum AsExpr<'a, Ex, Fb, En, Hi> {
259 AsV(&'a Expr<'a, Ex, Fb, En, Hi>),
260 AsKv(&'a (&'a Expr<'a, Ex, Fb, En, Hi>, &'a Expr<'a, Ex, Fb, En, Hi>)),
261 AwaitAsV(&'a (&'a Pos<'a>, &'a Expr<'a, Ex, Fb, En, Hi>)),
265 &'a Expr<'a, Ex, Fb, En, Hi>,
266 &'a Expr<'a, Ex, Fb, En, Hi>,
270 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
271 for AsExpr<'a, Ex, Fb, En, Hi>
275 pub type Block<'a, Ex, Fb, En, Hi> = [&'a Stmt<'a, Ex, Fb, En, Hi>];
290 pub struct ClassId<'a, Ex, Fb, En, Hi>(pub Ex, pub ClassId_<'a, Ex, Fb, En, Hi>);
291 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
292 for ClassId<'a, Ex, Fb, En, Hi>
296 /// Class ID, used in things like instantiation and static property access.
311 pub enum ClassId_<'a, Ex, Fb, En, Hi> {
312 /// The class ID of the parent of the lexically scoped class.
314 /// In a trait, it is the parent class ID of the using class.
316 /// parent::some_meth()
317 /// parent::$prop = 1;
320 /// The class ID of the lexically scoped class.
322 /// In a trait, it is the class ID of the using class.
324 /// self::some_meth()
328 /// The class ID of the late static bound class.
330 /// https://www.php.net/manual/en/language.oop5.late-static-bindings.php
332 /// In a trait, it is the late static bound class ID of the using class.
334 /// static::some_meth()
335 /// static::$prop = 1;
338 /// Dynamic class name.
340 /// TODO: Syntactically this can only be an Lvar/This/Lplacehodller.
341 /// We should use lid rather than expr.
343 /// // Assume $d has type dynamic.
347 CIexpr(&'a Expr<'a, Ex, Fb, En, Hi>),
348 /// Explicit class name. This is the common case.
350 /// Foop::some_meth()
355 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
356 for ClassId_<'a, Ex, Fb, En, Hi>
373 pub struct Expr<'a, Ex, Fb, En, Hi>(pub Ex, pub Expr_<'a, Ex, Fb, En, Hi>);
374 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
375 for Expr<'a, Ex, Fb, En, Hi>
393 pub enum CollectionTarg<'a, Hi> {
394 CollectionTV(&'a Targ<'a, Hi>),
395 CollectionTKV(&'a (&'a Targ<'a, Hi>, &'a Targ<'a, Hi>)),
397 impl<'a, Hi: TrivialDrop> TrivialDrop for CollectionTarg<'a, Hi> {}
413 pub enum FunctionPtrId<'a, Ex, Fb, En, Hi> {
415 FPClassConst(&'a (&'a ClassId<'a, Ex, Fb, En, Hi>, &'a Pstring<'a>)),
417 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
418 for FunctionPtrId<'a, Ex, Fb, En, Hi>
435 pub struct ExpressionTree<'a, Ex, Fb, En, Hi> {
436 pub hint: &'a Hint<'a>,
437 pub src_expr: &'a Expr<'a, Ex, Fb, En, Hi>,
438 pub desugared_expr: &'a Expr<'a, Ex, Fb, En, Hi>,
440 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
441 for ExpressionTree<'a, Ex, Fb, En, Hi>
459 pub enum Expr_<'a, Ex, Fb, En, Hi> {
462 /// darray['x' => 0, 'y' => 1]
463 /// darray<string, int>['x' => 0, 'y' => 1]
466 Option<&'a (&'a Targ<'a, Hi>, &'a Targ<'a, Hi>)>,
467 &'a [(&'a Expr<'a, Ex, Fb, En, Hi>, &'a Expr<'a, Ex, Fb, En, Hi>)],
472 /// varray['hello', 'world']
473 /// varray<string>['hello', 'world']
474 Varray(&'a (Option<&'a Targ<'a, Hi>>, &'a [&'a Expr<'a, Ex, Fb, En, Hi>])),
477 /// shape('x' => 1, 'y' => 2)
478 Shape(&'a [(ast_defs::ShapeFieldName<'a>, &'a Expr<'a, Ex, Fb, En, Hi>)]),
479 /// Collection literal for indexable structures.
483 /// Set<string> {'foo', 'bar'}
488 oxidized::aast::VcKind,
489 Option<&'a Targ<'a, Hi>>,
490 &'a [&'a Expr<'a, Ex, Fb, En, Hi>],
493 /// Collection literal for key-value structures.
495 /// dict['x' => 1, 'y' => 2]
496 /// Map<int, string> {}
500 oxidized::aast::KvcKind,
501 Option<&'a (&'a Targ<'a, Hi>, &'a Targ<'a, Hi>)>,
502 &'a [&'a Field<'a, Ex, Fb, En, Hi>],
509 /// The local variable representing the current class instance.
521 /// The empty expression.
523 /// list(, $y) = vec[1, 2] // Omitted is the first expression inside list()
525 /// An identifier. Used for method names and global constants.
528 /// $x->foo() // id: "foo"
534 /// The extra variable in a pipe expression.
537 Dollardollar(&'a Lid<'a>),
538 /// Clone expression.
541 Clone(&'a Expr<'a, Ex, Fb, En, Hi>),
548 &'a Expr<'a, Ex, Fb, En, Hi>,
549 Option<&'a Expr<'a, Ex, Fb, En, Hi>>,
552 /// Instance property or method access. is_prop_call is always
553 /// false, except when inside a call is accessing a property.
555 /// $foo->bar // (Obj_get false) property access
556 /// $foo->bar() // (Call (Obj_get false)) method call
557 /// ($foo->bar)() // (Call (Obj_get true)) call lambda stored in property
558 /// $foo?->bar // nullsafe access
561 &'a Expr<'a, Ex, Fb, En, Hi>,
562 &'a Expr<'a, Ex, Fb, En, Hi>,
563 oxidized::aast::OgNullFlavor,
567 /// Static property access.
570 /// $some_classname::$bar
571 /// Foo::${$bar} // only in partial mode
574 &'a ClassId<'a, Ex, Fb, En, Hi>,
575 ClassGetExpr<'a, Ex, Fb, En, Hi>,
579 /// Class constant or static method call. As a standalone expression,
580 /// this is a class constant. Inside a Call node, this is a static
583 /// This is not ambiguous, because constants are not allowed to
584 /// contain functions.
586 /// Foo::some_const // Class_const
587 /// Foo::someStaticMeth() // Call (Class_const)
589 /// This syntax is used for both static and instance methods when
590 /// calling the implementation on the superclass.
592 /// parent::someStaticMeth()
593 /// parent::someInstanceMeth()
594 ClassConst(&'a (&'a ClassId<'a, Ex, Fb, En, Hi>, &'a Pstring<'a>)),
595 /// Function or method call.
599 /// foo<int>(1, 2, ...$rest)
602 /// async { return 1; }
604 /// (async () ==> { return 1; })()
607 &'a Expr<'a, Ex, Fb, En, Hi>,
608 &'a [&'a Targ<'a, Hi>],
609 &'a [&'a Expr<'a, Ex, Fb, En, Hi>],
610 Option<&'a Expr<'a, Ex, Fb, En, Hi>>,
613 /// A reference to a function or method.
616 /// FooCls::meth<int>
617 FunctionPointer(&'a (FunctionPtrId<'a, Ex, Fb, En, Hi>, &'a [&'a Targ<'a, Hi>])),
622 /// 0xBEEF // hexadecimal
623 /// 0b11111111 // binary
643 String(&'a bstr::BStr),
644 /// Interpolated string literal.
646 /// "hello $foo $bar"
651 String2(&'a [&'a Expr<'a, Ex, Fb, En, Hi>]),
652 /// Prefixed string literal. Only used for regular expressions.
655 PrefixedString(&'a (&'a str, &'a Expr<'a, Ex, Fb, En, Hi>)),
656 /// Yield expression. The enclosing function should have an Iterator
659 /// yield $foo // enclosing function returns an Iterator
660 /// yield $foo => $bar // enclosing function returns a KeyedIterator
661 Yield(&'a Afield<'a, Ex, Fb, En, Hi>),
662 /// Await expression.
665 Await(&'a Expr<'a, Ex, Fb, En, Hi>),
666 /// List expression, only used in destructuring. Allows any arbitrary
667 /// lvalue as a subexpression. May also nest.
669 /// Note that tuple(1, 2) is lowered to a Call, but naming converts it to a List.
670 /// TODO: Define a separate AAST node for tuple.
672 /// list($x, $y) = vec[1, 2];
673 /// list(, $y) = vec[1, 2]; // skipping items
674 /// list(list($x)) = vec[vec[1]]; // nesting
675 /// list($v[0], $x[], $y->foo) = $blah;
676 List(&'a [&'a Expr<'a, Ex, Fb, En, Hi>]),
677 /// Cast expression, converting a value to a different type. Only
678 /// primitive types are supported in the hint position.
682 Cast(&'a (&'a Hint<'a>, &'a Expr<'a, Ex, Fb, En, Hi>)),
688 Unop(&'a (oxidized::ast_defs::Uop, &'a Expr<'a, Ex, Fb, En, Hi>)),
695 &'a Expr<'a, Ex, Fb, En, Hi>,
696 &'a Expr<'a, Ex, Fb, En, Hi>,
699 /// Pipe expression. The lid is the ID of the $$ that is implicitly
700 /// declared by this pipe.
702 /// See also Dollardollar.
704 /// $foo |> bar() // equivalent: bar($foo)
705 /// $foo |> bar(1, $$) // equivalent: bar(1, $foo)
709 &'a Expr<'a, Ex, Fb, En, Hi>,
710 &'a Expr<'a, Ex, Fb, En, Hi>,
713 /// Ternary operator, or elvis operator.
715 /// $foo ? $bar : $baz // ternary
716 /// $foo ?: $baz // elvis
719 &'a Expr<'a, Ex, Fb, En, Hi>,
720 Option<&'a Expr<'a, Ex, Fb, En, Hi>>,
721 &'a Expr<'a, Ex, Fb, En, Hi>,
727 Is(&'a (&'a Expr<'a, Ex, Fb, En, Hi>, &'a Hint<'a>)),
732 As(&'a (&'a Expr<'a, Ex, Fb, En, Hi>, &'a Hint<'a>, bool)),
736 /// new Foo<int, T>();
737 /// new Foo('blah', ...$rest);
740 &'a ClassId<'a, Ex, Fb, En, Hi>,
741 &'a [&'a Targ<'a, Hi>],
742 &'a [&'a Expr<'a, Ex, Fb, En, Hi>],
743 Option<&'a Expr<'a, Ex, Fb, En, Hi>>,
749 /// MyRecord['x' => $foo, 'y' => $bar]
753 &'a [(&'a Expr<'a, Ex, Fb, En, Hi>, &'a Expr<'a, Ex, Fb, En, Hi>)],
756 /// PHP-style lambda. Does not capture variables unless explicitly
759 /// Mnemonic: 'expanded lambda', since we can desugar Lfun to Efun.
761 /// function($x) { return $x; }
762 /// function(int $x): int { return $x; }
763 /// function($x) use ($y) { return $y; }
764 /// function($x): int use ($y, $z) { return $x + $y + $z; }
765 Efun(&'a (&'a Fun_<'a, Ex, Fb, En, Hi>, &'a [&'a Lid<'a>])),
766 /// Hack lambda. Captures variables automatically.
769 /// (int $x): int ==> $x + $other
770 /// ($x, $y) ==> { return $x + $y; }
771 Lfun(&'a (&'a Fun_<'a, Ex, Fb, En, Hi>, &'a [&'a Lid<'a>])),
772 /// XHP expression. May contain interpolated expressions.
774 /// <foo x="hello" y={$foo}>hello {$bar}</foo>
778 &'a [XhpAttribute<'a, Ex, Fb, En, Hi>],
779 &'a [&'a Expr<'a, Ex, Fb, En, Hi>],
782 /// Explicit calling convention, used for inout. Inout supports any lvalue.
784 /// TODO: This could be a flag on parameters in Call.
787 Callconv(&'a (oxidized::ast_defs::ParamKind, &'a Expr<'a, Ex, Fb, En, Hi>)),
788 /// Include or require expression.
790 /// require('foo.php')
791 /// require_once('foo.php')
792 /// include('foo.php')
793 /// include_once('foo.php')
794 Import(&'a (oxidized::aast::ImportFlavor, &'a Expr<'a, Ex, Fb, En, Hi>)),
795 /// Collection literal.
797 /// TODO: T38184446 this is redundant with ValCollection/KeyValCollection.
803 Option<CollectionTarg<'a, Hi>>,
804 &'a [Afield<'a, Ex, Fb, En, Hi>],
807 /// Expression tree literal. Expression trees are not evaluated at
808 /// runtime, but desugared to an expression representing the code.
811 /// Foo`$x ==> $x * ${$value}` // splicing $value
812 ExpressionTree(&'a ExpressionTree<'a, Ex, Fb, En, Hi>),
813 /// Placeholder local variable.
816 Lplaceholder(&'a Pos<'a>),
817 /// Global function reference.
821 /// Instance method reference on a specific instance.
823 /// TODO: This is only created in naming, and ought to happen in
824 /// lowering or be removed. The emitter just sees a normal Call.
826 /// inst_meth($f, 'some_meth') // equivalent: $f->some_meth<>
827 MethodId(&'a (&'a Expr<'a, Ex, Fb, En, Hi>, &'a Pstring<'a>)),
828 /// Instance method reference that can be called with an instance.
830 /// meth_caller(FooClass::class, 'some_meth')
831 /// meth_caller('FooClass', 'some_meth')
833 /// These examples are equivalent to:
835 /// (FooClass $f, ...$args) ==> $f->some_meth(...$args)
836 MethodCaller(&'a (Sid<'a>, &'a Pstring<'a>)),
837 /// Static method reference.
839 /// class_meth('FooClass', 'some_static_meth')
840 /// // equivalent: FooClass::some_static_meth<>
841 SmethodId(&'a (&'a ClassId<'a, Ex, Fb, En, Hi>, &'a Pstring<'a>)),
844 /// Pair {$foo, $bar}
847 Option<&'a (&'a Targ<'a, Hi>, &'a Targ<'a, Hi>)>,
848 &'a Expr<'a, Ex, Fb, En, Hi>,
849 &'a Expr<'a, Ex, Fb, En, Hi>,
852 /// Expression tree splice expression. Only valid inside an
853 /// expression tree literal (backticks).
856 ETSplice(&'a Expr<'a, Ex, Fb, En, Hi>),
857 /// Enum atom used for enum classes.
861 /// Placeholder for expressions that aren't understood by parts of
867 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
868 for Expr_<'a, Ex, Fb, En, Hi>
886 pub enum ClassGetExpr<'a, Ex, Fb, En, Hi> {
887 CGstring(&'a Pstring<'a>),
888 CGexpr(&'a Expr<'a, Ex, Fb, En, Hi>),
890 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
891 for ClassGetExpr<'a, Ex, Fb, En, Hi>
909 pub enum Case<'a, Ex, Fb, En, Hi> {
910 Default(&'a (&'a Pos<'a>, &'a Block<'a, Ex, Fb, En, Hi>)),
911 Case(&'a (&'a Expr<'a, Ex, Fb, En, Hi>, &'a Block<'a, Ex, Fb, En, Hi>)),
913 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
914 for Case<'a, Ex, Fb, En, Hi>
931 pub struct Catch<'a, Ex, Fb, En, Hi>(
934 pub &'a Block<'a, Ex, Fb, En, Hi>,
936 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
937 for Catch<'a, Ex, Fb, En, Hi>
954 pub struct Field<'a, Ex, Fb, En, Hi>(
955 pub &'a Expr<'a, Ex, Fb, En, Hi>,
956 pub &'a Expr<'a, Ex, Fb, En, Hi>,
958 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
959 for Field<'a, Ex, Fb, En, Hi>
977 pub enum Afield<'a, Ex, Fb, En, Hi> {
978 AFvalue(&'a Expr<'a, Ex, Fb, En, Hi>),
979 AFkvalue(&'a (&'a Expr<'a, Ex, Fb, En, Hi>, &'a Expr<'a, Ex, Fb, En, Hi>)),
981 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
982 for Afield<'a, Ex, Fb, En, Hi>
1000 pub enum XhpAttribute<'a, Ex, Fb, En, Hi> {
1001 XhpSimple(&'a (&'a Pstring<'a>, &'a Expr<'a, Ex, Fb, En, Hi>)),
1002 XhpSpread(&'a Expr<'a, Ex, Fb, En, Hi>),
1004 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1005 for XhpAttribute<'a, Ex, Fb, En, Hi>
1009 pub use oxidized::aast::IsVariadic;
1024 pub struct FunParam<'a, Ex, Fb, En, Hi> {
1026 pub type_hint: &'a TypeHint<'a, Hi>,
1027 pub is_variadic: &'a oxidized::aast::IsVariadic,
1028 pub pos: &'a Pos<'a>,
1030 pub expr: Option<&'a Expr<'a, Ex, Fb, En, Hi>>,
1031 pub callconv: Option<oxidized::ast_defs::ParamKind>,
1032 pub user_attributes: &'a [&'a UserAttribute<'a, Ex, Fb, En, Hi>],
1033 pub visibility: Option<oxidized::aast::Visibility>,
1035 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1036 for FunParam<'a, Ex, Fb, En, Hi>
1040 /// Does this function/method take a variable number of arguments?
1055 pub enum FunVariadicity<'a, Ex, Fb, En, Hi> {
1056 /// Named variadic argument.
1058 /// function foo(int ...$args): void {}
1059 FVvariadicArg(&'a FunParam<'a, Ex, Fb, En, Hi>),
1060 /// Unnamed variaidic argument. Partial mode only.
1062 /// function foo(...): void {}
1063 FVellipsis(&'a Pos<'a>),
1064 /// Function is not variadic, takes an exact number of arguments.
1067 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1068 for FunVariadicity<'a, Ex, Fb, En, Hi>
1085 pub struct Fun_<'a, Ex, Fb, En, Hi> {
1086 pub span: &'a Pos<'a>,
1088 pub mode: oxidized::file_info::Mode,
1089 pub ret: &'a TypeHint<'a, Hi>,
1091 pub tparams: &'a [&'a Tparam<'a, Ex, Fb, En, Hi>],
1092 pub where_constraints: &'a [&'a WhereConstraintHint<'a>],
1093 pub variadic: FunVariadicity<'a, Ex, Fb, En, Hi>,
1094 pub params: &'a [&'a FunParam<'a, Ex, Fb, En, Hi>],
1095 pub ctxs: Option<&'a Contexts<'a>>,
1096 pub unsafe_ctxs: Option<&'a Contexts<'a>>,
1097 pub body: &'a FuncBody<'a, Ex, Fb, En, Hi>,
1098 pub fun_kind: oxidized::ast_defs::FunKind,
1099 pub user_attributes: &'a [&'a UserAttribute<'a, Ex, Fb, En, Hi>],
1100 pub file_attributes: &'a [&'a FileAttribute<'a, Ex, Fb, En, Hi>],
1101 /// true if this declaration has no body because it is an
1102 /// external function declaration (e.g. from an HHI file)
1104 pub namespace: &'a Nsenv<'a>,
1105 pub doc_comment: Option<&'a DocComment<'a>>,
1108 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1109 for Fun_<'a, Ex, Fb, En, Hi>
1113 /// Naming has two phases and the annotation helps to indicate the phase.
1114 /// In the first pass, it will perform naming on everything except for function
1115 /// and method bodies and collect information needed. Then, another round of
1116 /// naming is performed where function bodies are named. Thus, naming will
1117 /// have named and unnamed variants of the annotation.
1118 /// See BodyNamingAnnotation in nast.ml and the comment in naming.ml
1132 pub struct FuncBody<'a, Ex, Fb, En, Hi> {
1133 pub ast: &'a Block<'a, Ex, Fb, En, Hi>,
1136 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1137 for FuncBody<'a, Ex, Fb, En, Hi>
1141 /// A type annotation is two things:
1142 /// - the localized hint, or if the hint is missing, the inferred type
1143 /// - The typehint associated to this expression if it exists
1157 pub struct TypeHint<'a, Hi>(pub Hi, pub &'a TypeHint_<'a>);
1158 impl<'a, Hi: TrivialDrop> TrivialDrop for TypeHint<'a, Hi> {}
1160 /// Explicit type argument to function, constructor, or collection literal.
1161 /// 'hi = unit in NAST
1162 /// 'hi = Typing_defs.(locl ty) in TAST,
1163 /// and is used to record inferred type arguments, with wildcard hint.
1177 pub struct Targ<'a, Hi>(pub Hi, pub &'a Hint<'a>);
1178 impl<'a, Hi: TrivialDrop> TrivialDrop for Targ<'a, Hi> {}
1180 pub type TypeHint_<'a> = Option<&'a Hint<'a>>;
1195 pub struct UserAttribute<'a, Ex, Fb, En, Hi> {
1197 /// user attributes are restricted to scalar values
1198 pub params: &'a [&'a Expr<'a, Ex, Fb, En, Hi>],
1200 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1201 for UserAttribute<'a, Ex, Fb, En, Hi>
1218 pub struct FileAttribute<'a, Ex, Fb, En, Hi> {
1219 pub user_attributes: &'a [&'a UserAttribute<'a, Ex, Fb, En, Hi>],
1220 pub namespace: &'a Nsenv<'a>,
1222 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1223 for FileAttribute<'a, Ex, Fb, En, Hi>
1240 pub struct Tparam<'a, Ex, Fb, En, Hi> {
1241 pub variance: oxidized::ast_defs::Variance,
1243 pub parameters: &'a [&'a Tparam<'a, Ex, Fb, En, Hi>],
1244 pub constraints: &'a [(oxidized::ast_defs::ConstraintKind, &'a Hint<'a>)],
1245 pub reified: oxidized::aast::ReifyKind,
1246 pub user_attributes: &'a [&'a UserAttribute<'a, Ex, Fb, En, Hi>],
1248 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1249 for Tparam<'a, Ex, Fb, En, Hi>
1266 pub struct UseAsAlias<'a>(
1267 pub Option<Sid<'a>>,
1268 pub &'a Pstring<'a>,
1269 pub Option<Sid<'a>>,
1270 pub &'a [oxidized::aast::UseAsVisibility],
1272 impl<'a> TrivialDrop for UseAsAlias<'a> {}
1287 pub struct InsteadofAlias<'a>(pub Sid<'a>, pub &'a Pstring<'a>, pub &'a [Sid<'a>]);
1288 impl<'a> TrivialDrop for InsteadofAlias<'a> {}
1290 pub use oxidized::aast::IsExtends;
1292 pub use oxidized::aast::EmitId;
1307 pub struct Class_<'a, Ex, Fb, En, Hi> {
1308 pub span: &'a Pos<'a>,
1310 pub mode: oxidized::file_info::Mode,
1313 pub has_xhp_keyword: bool,
1314 pub kind: oxidized::ast_defs::ClassKind,
1316 /// The type parameters of a class A<T> (T is the parameter)
1317 pub tparams: &'a [&'a Tparam<'a, Ex, Fb, En, Hi>],
1318 pub extends: &'a [&'a ClassHint<'a>],
1319 pub uses: &'a [&'a TraitHint<'a>],
1320 pub use_as_alias: &'a [&'a UseAsAlias<'a>],
1321 pub insteadof_alias: &'a [&'a InsteadofAlias<'a>],
1322 pub xhp_attr_uses: &'a [&'a XhpAttrHint<'a>],
1323 pub xhp_category: Option<&'a (&'a Pos<'a>, &'a [&'a Pstring<'a>])>,
1324 pub reqs: &'a [(&'a ClassHint<'a>, &'a oxidized::aast::IsExtends)],
1325 pub implements: &'a [&'a ClassHint<'a>],
1326 pub implements_dynamic: bool,
1327 pub where_constraints: &'a [&'a WhereConstraintHint<'a>],
1328 pub consts: &'a [&'a ClassConst<'a, Ex, Fb, En, Hi>],
1329 pub typeconsts: &'a [&'a ClassTypeconst<'a, Ex, Fb, En, Hi>],
1330 pub vars: &'a [&'a ClassVar<'a, Ex, Fb, En, Hi>],
1331 pub methods: &'a [&'a Method_<'a, Ex, Fb, En, Hi>],
1332 pub attributes: &'a [ClassAttr<'a, Ex, Fb, En, Hi>],
1333 pub xhp_children: &'a [(&'a Pos<'a>, &'a XhpChild<'a>)],
1334 pub xhp_attrs: &'a [&'a XhpAttr<'a, Ex, Fb, En, Hi>],
1335 pub namespace: &'a Nsenv<'a>,
1336 pub user_attributes: &'a [&'a UserAttribute<'a, Ex, Fb, En, Hi>],
1337 pub file_attributes: &'a [&'a FileAttribute<'a, Ex, Fb, En, Hi>],
1338 pub enum_: Option<&'a Enum_<'a>>,
1339 pub doc_comment: Option<&'a DocComment<'a>>,
1340 pub emit_id: Option<&'a oxidized::aast::EmitId>,
1342 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1343 for Class_<'a, Ex, Fb, En, Hi>
1347 pub type ClassHint<'a> = Hint<'a>;
1349 pub type TraitHint<'a> = Hint<'a>;
1351 pub type XhpAttrHint<'a> = Hint<'a>;
1353 pub use oxidized::aast::XhpAttrTag;
1368 pub struct XhpAttr<'a, Ex, Fb, En, Hi>(
1369 pub &'a TypeHint<'a, Hi>,
1370 pub &'a ClassVar<'a, Ex, Fb, En, Hi>,
1371 pub Option<oxidized::aast::XhpAttrTag>,
1372 pub Option<&'a (&'a Pos<'a>, &'a [&'a Expr<'a, Ex, Fb, En, Hi>])>,
1374 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1375 for XhpAttr<'a, Ex, Fb, En, Hi>
1393 pub enum ClassAttr<'a, Ex, Fb, En, Hi> {
1394 CAName(&'a Sid<'a>),
1395 CAField(&'a CaField<'a, Ex, Fb, En, Hi>),
1397 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1398 for ClassAttr<'a, Ex, Fb, En, Hi>
1415 pub struct CaField<'a, Ex, Fb, En, Hi> {
1416 pub type_: CaType<'a>,
1418 pub value: Option<&'a Expr<'a, Ex, Fb, En, Hi>>,
1421 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1422 for CaField<'a, Ex, Fb, En, Hi>
1440 pub enum CaType<'a> {
1441 CAHint(&'a Hint<'a>),
1442 CAEnum(&'a [&'a str]),
1444 impl<'a> TrivialDrop for CaType<'a> {}
1459 pub struct ClassConst<'a, Ex, Fb, En, Hi> {
1460 pub type_: Option<&'a Hint<'a>>,
1462 /// expr = None indicates an abstract const
1463 pub expr: Option<&'a Expr<'a, Ex, Fb, En, Hi>>,
1464 pub doc_comment: Option<&'a DocComment<'a>>,
1466 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1467 for ClassConst<'a, Ex, Fb, En, Hi>
1485 pub enum TypeconstAbstractKind<'a> {
1486 TCAbstract(Option<&'a Hint<'a>>),
1487 TCPartiallyAbstract,
1490 impl<'a> TrivialDrop for TypeconstAbstractKind<'a> {}
1492 /// This represents a type const definition. If a type const is abstract then
1493 /// then the type hint acts as a constraint. Any concrete definition of the
1494 /// type const must satisfy the constraint.
1496 /// If the type const is not abstract then a type must be specified.
1510 pub struct ClassTypeconst<'a, Ex, Fb, En, Hi> {
1511 pub abstract_: TypeconstAbstractKind<'a>,
1513 pub constraint: Option<&'a Hint<'a>>,
1514 pub type_: Option<&'a Hint<'a>>,
1515 pub user_attributes: &'a [&'a UserAttribute<'a, Ex, Fb, En, Hi>],
1516 pub span: &'a Pos<'a>,
1517 pub doc_comment: Option<&'a DocComment<'a>>,
1520 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1521 for ClassTypeconst<'a, Ex, Fb, En, Hi>
1525 pub use oxidized::aast::XhpAttrInfo;
1540 pub struct ClassVar<'a, Ex, Fb, En, Hi> {
1542 pub xhp_attr: Option<&'a oxidized::aast::XhpAttrInfo>,
1543 pub abstract_: bool,
1544 pub visibility: oxidized::aast::Visibility,
1545 pub type_: &'a TypeHint<'a, Hi>,
1547 pub expr: Option<&'a Expr<'a, Ex, Fb, En, Hi>>,
1548 pub user_attributes: &'a [&'a UserAttribute<'a, Ex, Fb, En, Hi>],
1549 pub doc_comment: Option<&'a DocComment<'a>>,
1550 pub is_promoted_variadic: bool,
1551 pub is_static: bool,
1552 pub span: &'a Pos<'a>,
1554 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1555 for ClassVar<'a, Ex, Fb, En, Hi>
1572 pub struct Method_<'a, Ex, Fb, En, Hi> {
1573 pub span: &'a Pos<'a>,
1576 pub abstract_: bool,
1578 pub visibility: oxidized::aast::Visibility,
1580 pub tparams: &'a [&'a Tparam<'a, Ex, Fb, En, Hi>],
1581 pub where_constraints: &'a [&'a WhereConstraintHint<'a>],
1582 pub variadic: FunVariadicity<'a, Ex, Fb, En, Hi>,
1583 pub params: &'a [&'a FunParam<'a, Ex, Fb, En, Hi>],
1584 pub ctxs: Option<&'a Contexts<'a>>,
1585 pub unsafe_ctxs: Option<&'a Contexts<'a>>,
1586 pub body: &'a FuncBody<'a, Ex, Fb, En, Hi>,
1587 pub fun_kind: oxidized::ast_defs::FunKind,
1588 pub user_attributes: &'a [&'a UserAttribute<'a, Ex, Fb, En, Hi>],
1589 pub ret: &'a TypeHint<'a, Hi>,
1590 /// true if this declaration has no body because it is an external method
1591 /// declaration (e.g. from an HHI file)
1593 pub doc_comment: Option<&'a DocComment<'a>>,
1595 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1596 for Method_<'a, Ex, Fb, En, Hi>
1600 pub type Nsenv<'a> = namespace_env::Env<'a>;
1615 pub struct Typedef<'a, Ex, Fb, En, Hi> {
1618 pub tparams: &'a [&'a Tparam<'a, Ex, Fb, En, Hi>],
1619 pub constraint: Option<&'a Hint<'a>>,
1620 pub kind: &'a Hint<'a>,
1621 pub user_attributes: &'a [&'a UserAttribute<'a, Ex, Fb, En, Hi>],
1622 pub mode: oxidized::file_info::Mode,
1623 pub vis: oxidized::aast::TypedefVisibility,
1624 pub namespace: &'a Nsenv<'a>,
1625 pub span: &'a Pos<'a>,
1626 pub emit_id: Option<&'a oxidized::aast::EmitId>,
1628 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1629 for Typedef<'a, Ex, Fb, En, Hi>
1646 pub struct Gconst<'a, Ex, Fb, En, Hi> {
1648 pub mode: oxidized::file_info::Mode,
1650 pub type_: Option<&'a Hint<'a>>,
1651 pub value: &'a Expr<'a, Ex, Fb, En, Hi>,
1652 pub namespace: &'a Nsenv<'a>,
1653 pub span: &'a Pos<'a>,
1654 pub emit_id: Option<&'a oxidized::aast::EmitId>,
1656 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1657 for Gconst<'a, Ex, Fb, En, Hi>
1674 pub struct RecordDef<'a, Ex, Fb, En, Hi> {
1677 pub extends: Option<&'a RecordHint<'a>>,
1678 pub abstract_: bool,
1679 pub fields: &'a [(Sid<'a>, &'a Hint<'a>, Option<&'a Expr<'a, Ex, Fb, En, Hi>>)],
1680 pub user_attributes: &'a [&'a UserAttribute<'a, Ex, Fb, En, Hi>],
1681 pub namespace: &'a Nsenv<'a>,
1682 pub span: &'a Pos<'a>,
1683 pub doc_comment: Option<&'a DocComment<'a>>,
1684 pub emit_id: Option<&'a oxidized::aast::EmitId>,
1686 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1687 for RecordDef<'a, Ex, Fb, En, Hi>
1691 pub type RecordHint<'a> = Hint<'a>;
1693 pub type FunDef<'a, Ex, Fb, En, Hi> = Fun_<'a, Ex, Fb, En, Hi>;
1709 pub enum Def<'a, Ex, Fb, En, Hi> {
1710 Fun(&'a FunDef<'a, Ex, Fb, En, Hi>),
1711 Class(&'a Class_<'a, Ex, Fb, En, Hi>),
1712 RecordDef(&'a RecordDef<'a, Ex, Fb, En, Hi>),
1713 Stmt(&'a Stmt<'a, Ex, Fb, En, Hi>),
1714 Typedef(&'a Typedef<'a, Ex, Fb, En, Hi>),
1715 Constant(&'a Gconst<'a, Ex, Fb, En, Hi>),
1716 Namespace(&'a (Sid<'a>, &'a Program<'a, Ex, Fb, En, Hi>)),
1717 NamespaceUse(&'a [(oxidized::aast::NsKind, Sid<'a>, Sid<'a>)]),
1718 SetNamespaceEnv(&'a Nsenv<'a>),
1719 FileAttributes(&'a FileAttribute<'a, Ex, Fb, En, Hi>),
1721 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1722 for Def<'a, Ex, Fb, En, Hi>
1726 pub use oxidized::aast::NsKind;
1728 pub use oxidized::aast::BreakContinueLevel;