Merge oxidize scripts
[hiphop-php.git] / hphp / hack / src / oxidized_by_ref / gen / aast.rs
blob0b3681626979d4fd0856f25aa45bc668678f61db
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<<2c3ee08ffff7a51d30136326a6f6b047>>
7 //
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;
15 use serde::Serialize;
17 #[allow(unused_imports)]
18 use crate::*;
20 pub use aast_defs::*;
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>];
31 #[derive(
32     Clone,
33     Debug,
34     Eq,
35     FromOcamlRepIn,
36     Hash,
37     NoPosHash,
38     Ord,
39     PartialEq,
40     PartialOrd,
41     Serialize,
42     ToOcamlRep
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>
50 #[derive(
51     Clone,
52     Copy,
53     Debug,
54     Eq,
55     FromOcamlRepIn,
56     Hash,
57     NoPosHash,
58     Ord,
59     PartialEq,
60     PartialOrd,
61     Serialize,
62     ToOcamlRep
64 pub enum Stmt_<'a, Ex, Fb, En, Hi> {
65     /// Marker for a switch statement that falls through.
66     ///
67     /// // FALLTHROUGH
68     Fallthrough,
69     /// Standalone expression.
70     ///
71     /// 1 + 2;
72     Expr(&'a Expr<'a, Ex, Fb, En, Hi>),
73     /// Break inside a loop or switch statement.
74     ///
75     /// break;
76     Break,
77     /// Continue inside a loop or switch statement.
78     ///
79     /// continue;
80     Continue,
81     /// Throw an exception.
82     ///
83     /// throw $foo;
84     Throw(&'a Expr<'a, Ex, Fb, En, Hi>),
85     /// Return, with an optional value.
86     ///
87     /// return;
88     /// return $foo;
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
92     /// as a generator.
93     ///
94     /// yield break;
95     YieldBreak,
96     /// Concurrent block. All the await expressions are awaited at the
97     /// same time, similar to genva().
98     ///
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; }
103     ///
104     /// concurrent {
105     /// $foo = await f();
106     /// $bar = await g();
107     /// await h();
108     /// }
109     Awaitall(
110         &'a (
111             &'a [(Option<&'a Lid<'a>>, &'a Expr<'a, Ex, Fb, En, Hi>)],
112             &'a Block<'a, Ex, Fb, En, Hi>,
113         ),
114     ),
115     /// If statement.
116     ///
117     /// if ($foo) { ... } else { ... }
118     If(
119         &'a (
120             &'a Expr<'a, Ex, Fb, En, Hi>,
121             &'a Block<'a, Ex, Fb, En, Hi>,
122             &'a Block<'a, Ex, Fb, En, Hi>,
123         ),
124     ),
125     /// Do-while loop.
126     ///
127     /// do {
128     /// bar();
129     /// } while($foo)
130     Do(&'a (&'a Block<'a, Ex, Fb, En, Hi>, &'a Expr<'a, Ex, Fb, En, Hi>)),
131     /// While loop.
132     ///
133     /// while ($foo) {
134     /// bar();
135     /// }
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.
138     ///
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
144     /// optional.
145     ///
146     /// for ($i = 0; $i < 100; $i++) { ... }
147     /// for ($x = 0, $y = 0; ; $x++, $y++) { ... }
148     For(
149         &'a (
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>,
154         ),
155     ),
156     /// Switch statement.
157     ///
158     /// switch ($foo) {
159     /// case X:
160     /// bar();
161     /// break;
162     /// default:
163     /// baz();
164     /// break;
165     /// }
166     Switch(&'a (&'a Expr<'a, Ex, Fb, En, Hi>, &'a [Case<'a, Ex, Fb, En, Hi>])),
167     /// For-each loop.
168     ///
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<_>
173     Foreach(
174         &'a (
175             &'a Expr<'a, Ex, Fb, En, Hi>,
176             AsExpr<'a, Ex, Fb, En, Hi>,
177             &'a Block<'a, Ex, Fb, En, Hi>,
178         ),
179     ),
180     /// Try statement, with catch blocks and a finally block.
181     ///
182     /// try {
183     /// foo();
184     /// } catch (SomeException $e) {
185     /// bar();
186     /// } finally {
187     /// baz();
188     /// }
189     Try(
190         &'a (
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>,
194         ),
195     ),
196     /// No-op, the empty statement.
197     ///
198     /// if ($foo) {} // the else is Noop here
199     Noop,
200     /// Block, a list of statements in curly braces.
201     ///
202     /// { $foo = 42; }
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.
206     ///
207     /// <?hh
208     Markup(&'a Pstring<'a>),
209     /// Used in IFC to track type inference environments. Not user
210     /// denotable.
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;
220 #[derive(
221     Clone,
222     Debug,
223     Eq,
224     FromOcamlRepIn,
225     Hash,
226     NoPosHash,
227     Ord,
228     PartialEq,
229     PartialOrd,
230     Serialize,
231     ToOcamlRep
233 pub struct UsingStmt<'a, Ex, Fb, En, Hi> {
234     pub is_block_scoped: bool,
235     pub has_await: 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>
244 #[derive(
245     Clone,
246     Copy,
247     Debug,
248     Eq,
249     FromOcamlRepIn,
250     Hash,
251     NoPosHash,
252     Ord,
253     PartialEq,
254     PartialOrd,
255     Serialize,
256     ToOcamlRep
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>)),
262     AwaitAsKv(
263         &'a (
264             &'a Pos<'a>,
265             &'a Expr<'a, Ex, Fb, En, Hi>,
266             &'a Expr<'a, Ex, Fb, En, Hi>,
267         ),
268     ),
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>];
277 #[derive(
278     Clone,
279     Debug,
280     Eq,
281     FromOcamlRepIn,
282     Hash,
283     NoPosHash,
284     Ord,
285     PartialEq,
286     PartialOrd,
287     Serialize,
288     ToOcamlRep
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.
297 #[derive(
298     Clone,
299     Copy,
300     Debug,
301     Eq,
302     FromOcamlRepIn,
303     Hash,
304     NoPosHash,
305     Ord,
306     PartialEq,
307     PartialOrd,
308     Serialize,
309     ToOcamlRep
311 pub enum ClassId_<'a, Ex, Fb, En, Hi> {
312     /// The class ID of the parent of the lexically scoped class.
313     ///
314     /// In a trait, it is the parent class ID of the using class.
315     ///
316     /// parent::some_meth()
317     /// parent::$prop = 1;
318     /// new parent();
319     CIparent,
320     /// The class ID of the lexically scoped class.
321     ///
322     /// In a trait, it is the class ID of the using class.
323     ///
324     /// self::some_meth()
325     /// self::$prop = 1;
326     /// new self();
327     CIself,
328     /// The class ID of the late static bound class.
329     ///
330     /// https://www.php.net/manual/en/language.oop5.late-static-bindings.php
331     ///
332     /// In a trait, it is the late static bound class ID of the using class.
333     ///
334     /// static::some_meth()
335     /// static::$prop = 1;
336     /// new static();
337     CIstatic,
338     /// Dynamic class name.
339     ///
340     /// TODO: Syntactically this can only be an Lvar/This/Lplacehodller.
341     /// We should use lid rather than expr.
342     ///
343     /// // Assume $d has type dynamic.
344     /// $d::some_meth();
345     /// $d::$prop = 1;
346     /// new $d();
347     CIexpr(&'a Expr<'a, Ex, Fb, En, Hi>),
348     /// Explicit class name. This is the common case.
349     ///
350     /// Foop::some_meth()
351     /// Foo::$prop = 1;
352     /// new Foo();
353     CI(&'a Sid<'a>),
355 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
356     for ClassId_<'a, Ex, Fb, En, Hi>
360 #[derive(
361     Clone,
362     Debug,
363     Eq,
364     FromOcamlRepIn,
365     Hash,
366     NoPosHash,
367     Ord,
368     PartialEq,
369     PartialOrd,
370     Serialize,
371     ToOcamlRep
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>
379 #[derive(
380     Clone,
381     Copy,
382     Debug,
383     Eq,
384     FromOcamlRepIn,
385     Hash,
386     NoPosHash,
387     Ord,
388     PartialEq,
389     PartialOrd,
390     Serialize,
391     ToOcamlRep
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> {}
399 #[derive(
400     Clone,
401     Copy,
402     Debug,
403     Eq,
404     FromOcamlRepIn,
405     Hash,
406     NoPosHash,
407     Ord,
408     PartialEq,
409     PartialOrd,
410     Serialize,
411     ToOcamlRep
413 pub enum FunctionPtrId<'a, Ex, Fb, En, Hi> {
414     FPId(&'a Sid<'a>),
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>
422 #[derive(
423     Clone,
424     Debug,
425     Eq,
426     FromOcamlRepIn,
427     Hash,
428     NoPosHash,
429     Ord,
430     PartialEq,
431     PartialOrd,
432     Serialize,
433     ToOcamlRep
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>
445 #[derive(
446     Clone,
447     Copy,
448     Debug,
449     Eq,
450     FromOcamlRepIn,
451     Hash,
452     NoPosHash,
453     Ord,
454     PartialEq,
455     PartialOrd,
456     Serialize,
457     ToOcamlRep
459 pub enum Expr_<'a, Ex, Fb, En, Hi> {
460     /// darray literal.
461     ///
462     /// darray['x' => 0, 'y' => 1]
463     /// darray<string, int>['x' => 0, 'y' => 1]
464     Darray(
465         &'a (
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>)],
468         ),
469     ),
470     /// varray literal.
471     ///
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>])),
475     /// Shape literal.
476     ///
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.
480     ///
481     /// Vector {1, 2}
482     /// ImmVector {}
483     /// Set<string> {'foo', 'bar'}
484     /// vec[1, 2]
485     /// keyset[]
486     ValCollection(
487         &'a (
488             oxidized::aast::VcKind,
489             Option<&'a Targ<'a, Hi>>,
490             &'a [&'a Expr<'a, Ex, Fb, En, Hi>],
491         ),
492     ),
493     /// Collection literal for key-value structures.
494     ///
495     /// dict['x' => 1, 'y' => 2]
496     /// Map<int, string> {}
497     /// ImmMap {}
498     KeyValCollection(
499         &'a (
500             oxidized::aast::KvcKind,
501             Option<&'a (&'a Targ<'a, Hi>, &'a Targ<'a, Hi>)>,
502             &'a [&'a Field<'a, Ex, Fb, En, Hi>],
503         ),
504     ),
505     /// Null literal.
506     ///
507     /// null
508     Null,
509     /// The local variable representing the current class instance.
510     ///
511     /// $this
512     This,
513     /// Boolean literal.
514     ///
515     /// true
516     True,
517     /// Boolean literal.
518     ///
519     /// false
520     False,
521     /// The empty expression.
522     ///
523     /// list(, $y) = vec[1, 2] // Omitted is the first expression inside list()
524     Omitted,
525     /// An identifier. Used for method names and global constants.
526     ///
527     /// SOME_CONST
528     /// $x->foo() // id: "foo"
529     Id(&'a Sid<'a>),
530     /// Local variable.
531     ///
532     /// $foo
533     Lvar(&'a Lid<'a>),
534     /// The extra variable in a pipe expression.
535     ///
536     /// $$
537     Dollardollar(&'a Lid<'a>),
538     /// Clone expression.
539     ///
540     /// clone $foo
541     Clone(&'a Expr<'a, Ex, Fb, En, Hi>),
542     /// Array indexing.
543     ///
544     /// $foo[]
545     /// $foo[$bar]
546     ArrayGet(
547         &'a (
548             &'a Expr<'a, Ex, Fb, En, Hi>,
549             Option<&'a Expr<'a, Ex, Fb, En, Hi>>,
550         ),
551     ),
552     /// Instance property or method access.  is_prop_call is always
553     /// false, except when inside a call is accessing a property.
554     ///
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
559     ObjGet(
560         &'a (
561             &'a Expr<'a, Ex, Fb, En, Hi>,
562             &'a Expr<'a, Ex, Fb, En, Hi>,
563             oxidized::aast::OgNullFlavor,
564             bool,
565         ),
566     ),
567     /// Static property access.
568     ///
569     /// Foo::$bar
570     /// $some_classname::$bar
571     /// Foo::${$bar} // only in partial mode
572     ClassGet(
573         &'a (
574             &'a ClassId<'a, Ex, Fb, En, Hi>,
575             ClassGetExpr<'a, Ex, Fb, En, Hi>,
576             bool,
577         ),
578     ),
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
581     /// method call.
582     ///
583     /// This is not ambiguous, because constants are not allowed to
584     /// contain functions.
585     ///
586     /// Foo::some_const // Class_const
587     /// Foo::someStaticMeth() // Call (Class_const)
588     ///
589     /// This syntax is used for both static and instance methods when
590     /// calling the implementation on the superclass.
591     ///
592     /// parent::someStaticMeth()
593     /// parent::someInstanceMeth()
594     ClassConst(&'a (&'a ClassId<'a, Ex, Fb, En, Hi>, &'a Pstring<'a>)),
595     /// Function or method call.
596     ///
597     /// foo()
598     /// $x()
599     /// foo<int>(1, 2, ...$rest)
600     /// $x->foo()
601     ///
602     /// async { return 1; }
603     /// // lowered to:
604     /// (async () ==> { return 1; })()
605     Call(
606         &'a (
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>>,
611         ),
612     ),
613     /// A reference to a function or method.
614     ///
615     /// foo_fun<>
616     /// FooCls::meth<int>
617     FunctionPointer(&'a (FunctionPtrId<'a, Ex, Fb, En, Hi>, &'a [&'a Targ<'a, Hi>])),
618     /// Integer literal.
619     ///
620     /// 42
621     /// 0123 // octal
622     /// 0xBEEF // hexadecimal
623     /// 0b11111111 // binary
624     Int(&'a str),
625     /// Float literal.
626     ///
627     /// 1.0
628     /// 1.2e3
629     /// 7E-10
630     Float(&'a str),
631     /// String literal.
632     ///
633     /// "foo"
634     /// 'foo'
635     ///
636     /// <<<DOC
637     /// foo
638     /// DOC
639     ///
640     /// <<<'DOC'
641     /// foo
642     /// DOC
643     String(&'a bstr::BStr),
644     /// Interpolated string literal.
645     ///
646     /// "hello $foo $bar"
647     ///
648     /// <<<DOC
649     /// hello $foo $bar
650     /// DOC
651     String2(&'a [&'a Expr<'a, Ex, Fb, En, Hi>]),
652     /// Prefixed string literal. Only used for regular expressions.
653     ///
654     /// re"foo"
655     PrefixedString(&'a (&'a str, &'a Expr<'a, Ex, Fb, En, Hi>)),
656     /// Yield expression. The enclosing function should have an Iterator
657     /// return type.
658     ///
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.
663     ///
664     /// await $foo
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.
668     ///
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.
671     ///
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.
679     ///
680     /// (int)$foo
681     /// (string)$foo
682     Cast(&'a (&'a Hint<'a>, &'a Expr<'a, Ex, Fb, En, Hi>)),
683     /// Unary operator.
684     ///
685     /// !$foo
686     /// -$foo
687     /// +$foo
688     Unop(&'a (oxidized::ast_defs::Uop, &'a Expr<'a, Ex, Fb, En, Hi>)),
689     /// Binary operator.
690     ///
691     /// $foo + $bar
692     Binop(
693         &'a (
694             ast_defs::Bop<'a>,
695             &'a Expr<'a, Ex, Fb, En, Hi>,
696             &'a Expr<'a, Ex, Fb, En, Hi>,
697         ),
698     ),
699     /// Pipe expression. The lid is the ID of the $$ that is implicitly
700     /// declared by this pipe.
701     ///
702     /// See also Dollardollar.
703     ///
704     /// $foo |> bar() // equivalent: bar($foo)
705     /// $foo |> bar(1, $$) // equivalent: bar(1, $foo)
706     Pipe(
707         &'a (
708             &'a Lid<'a>,
709             &'a Expr<'a, Ex, Fb, En, Hi>,
710             &'a Expr<'a, Ex, Fb, En, Hi>,
711         ),
712     ),
713     /// Ternary operator, or elvis operator.
714     ///
715     /// $foo ? $bar : $baz // ternary
716     /// $foo ?: $baz // elvis
717     Eif(
718         &'a (
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>,
722         ),
723     ),
724     /// Is operator.
725     ///
726     /// $foo is SomeType
727     Is(&'a (&'a Expr<'a, Ex, Fb, En, Hi>, &'a Hint<'a>)),
728     /// As operator.
729     ///
730     /// $foo as int
731     /// $foo ?as int
732     As(&'a (&'a Expr<'a, Ex, Fb, En, Hi>, &'a Hint<'a>, bool)),
733     /// Instantiation.
734     ///
735     /// new Foo(1, 2);
736     /// new Foo<int, T>();
737     /// new Foo('blah', ...$rest);
738     New(
739         &'a (
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>>,
744             Ex,
745         ),
746     ),
747     /// Record literal.
748     ///
749     /// MyRecord['x' => $foo, 'y' => $bar]
750     Record(
751         &'a (
752             Sid<'a>,
753             &'a [(&'a Expr<'a, Ex, Fb, En, Hi>, &'a Expr<'a, Ex, Fb, En, Hi>)],
754         ),
755     ),
756     /// PHP-style lambda. Does not capture variables unless explicitly
757     /// specified.
758     ///
759     /// Mnemonic: 'expanded lambda', since we can desugar Lfun to Efun.
760     ///
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.
767     ///
768     /// $x ==> $x
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.
773     ///
774     /// <foo x="hello" y={$foo}>hello {$bar}</foo>
775     Xml(
776         &'a (
777             Sid<'a>,
778             &'a [XhpAttribute<'a, Ex, Fb, En, Hi>],
779             &'a [&'a Expr<'a, Ex, Fb, En, Hi>],
780         ),
781     ),
782     /// Explicit calling convention, used for inout. Inout supports any lvalue.
783     ///
784     /// TODO: This could be a flag on parameters in Call.
785     ///
786     /// foo(inout $x[0])
787     Callconv(&'a (oxidized::ast_defs::ParamKind, &'a Expr<'a, Ex, Fb, En, Hi>)),
788     /// Include or require expression.
789     ///
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.
796     ///
797     /// TODO: T38184446 this is redundant with ValCollection/KeyValCollection.
798     ///
799     /// Vector {}
800     Collection(
801         &'a (
802             Sid<'a>,
803             Option<CollectionTarg<'a, Hi>>,
804             &'a [Afield<'a, Ex, Fb, En, Hi>],
805         ),
806     ),
807     /// Expression tree literal. Expression trees are not evaluated at
808     /// runtime, but desugared to an expression representing the code.
809     ///
810     /// Foo`1 + bar()`
811     /// Foo`$x ==> $x * ${$value}` // splicing $value
812     ExpressionTree(&'a ExpressionTree<'a, Ex, Fb, En, Hi>),
813     /// Placeholder local variable.
814     ///
815     /// $_
816     Lplaceholder(&'a Pos<'a>),
817     /// Global function reference.
818     ///
819     /// fun('foo')
820     FunId(&'a Sid<'a>),
821     /// Instance method reference on a specific instance.
822     ///
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.
825     ///
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.
829     ///
830     /// meth_caller(FooClass::class, 'some_meth')
831     /// meth_caller('FooClass', 'some_meth')
832     ///
833     /// These examples are equivalent to:
834     ///
835     /// (FooClass $f, ...$args) ==> $f->some_meth(...$args)
836     MethodCaller(&'a (Sid<'a>, &'a Pstring<'a>)),
837     /// Static method reference.
838     ///
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>)),
842     /// Pair literal.
843     ///
844     /// Pair {$foo, $bar}
845     Pair(
846         &'a (
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>,
850         ),
851     ),
852     /// Expression tree splice expression. Only valid inside an
853     /// expression tree literal (backticks).
854     ///
855     /// ${$foo}
856     ETSplice(&'a Expr<'a, Ex, Fb, En, Hi>),
857     /// Enum atom used for enum classes.
858     ///
859     /// #field_name
860     EnumAtom(&'a str),
861     /// Placeholder for expressions that aren't understood by parts of
862     /// the toolchain.
863     ///
864     /// TODO: Remove.
865     Any,
867 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
868     for Expr_<'a, Ex, Fb, En, Hi>
872 #[derive(
873     Clone,
874     Copy,
875     Debug,
876     Eq,
877     FromOcamlRepIn,
878     Hash,
879     NoPosHash,
880     Ord,
881     PartialEq,
882     PartialOrd,
883     Serialize,
884     ToOcamlRep
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>
895 #[derive(
896     Clone,
897     Copy,
898     Debug,
899     Eq,
900     FromOcamlRepIn,
901     Hash,
902     NoPosHash,
903     Ord,
904     PartialEq,
905     PartialOrd,
906     Serialize,
907     ToOcamlRep
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>
918 #[derive(
919     Clone,
920     Debug,
921     Eq,
922     FromOcamlRepIn,
923     Hash,
924     NoPosHash,
925     Ord,
926     PartialEq,
927     PartialOrd,
928     Serialize,
929     ToOcamlRep
931 pub struct Catch<'a, Ex, Fb, En, Hi>(
932     pub Sid<'a>,
933     pub &'a Lid<'a>,
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>
941 #[derive(
942     Clone,
943     Debug,
944     Eq,
945     FromOcamlRepIn,
946     Hash,
947     NoPosHash,
948     Ord,
949     PartialEq,
950     PartialOrd,
951     Serialize,
952     ToOcamlRep
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>
963 #[derive(
964     Clone,
965     Copy,
966     Debug,
967     Eq,
968     FromOcamlRepIn,
969     Hash,
970     NoPosHash,
971     Ord,
972     PartialEq,
973     PartialOrd,
974     Serialize,
975     ToOcamlRep
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>
986 #[derive(
987     Clone,
988     Copy,
989     Debug,
990     Eq,
991     FromOcamlRepIn,
992     Hash,
993     NoPosHash,
994     Ord,
995     PartialEq,
996     PartialOrd,
997     Serialize,
998     ToOcamlRep
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;
1011 #[derive(
1012     Clone,
1013     Debug,
1014     Eq,
1015     FromOcamlRepIn,
1016     Hash,
1017     NoPosHash,
1018     Ord,
1019     PartialEq,
1020     PartialOrd,
1021     Serialize,
1022     ToOcamlRep
1024 pub struct FunParam<'a, Ex, Fb, En, Hi> {
1025     pub annotation: Ex,
1026     pub type_hint: &'a TypeHint<'a, Hi>,
1027     pub is_variadic: &'a oxidized::aast::IsVariadic,
1028     pub pos: &'a Pos<'a>,
1029     pub name: &'a str,
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?
1041 #[derive(
1042     Clone,
1043     Copy,
1044     Debug,
1045     Eq,
1046     FromOcamlRepIn,
1047     Hash,
1048     NoPosHash,
1049     Ord,
1050     PartialEq,
1051     PartialOrd,
1052     Serialize,
1053     ToOcamlRep
1055 pub enum FunVariadicity<'a, Ex, Fb, En, Hi> {
1056     /// Named variadic argument.
1057     ///
1058     /// function foo(int ...$args): void {}
1059     FVvariadicArg(&'a FunParam<'a, Ex, Fb, En, Hi>),
1060     /// Unnamed variaidic argument. Partial mode only.
1061     ///
1062     /// function foo(...): void {}
1063     FVellipsis(&'a Pos<'a>),
1064     /// Function is not variadic, takes an exact number of arguments.
1065     FVnonVariadic,
1067 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1068     for FunVariadicity<'a, Ex, Fb, En, Hi>
1072 #[derive(
1073     Clone,
1074     Debug,
1075     Eq,
1076     FromOcamlRepIn,
1077     Hash,
1078     NoPosHash,
1079     Ord,
1080     PartialEq,
1081     PartialOrd,
1082     Serialize,
1083     ToOcamlRep
1085 pub struct Fun_<'a, Ex, Fb, En, Hi> {
1086     pub span: &'a Pos<'a>,
1087     pub annotation: En,
1088     pub mode: oxidized::file_info::Mode,
1089     pub ret: &'a TypeHint<'a, Hi>,
1090     pub name: Sid<'a>,
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)
1103     pub external: bool,
1104     pub namespace: &'a Nsenv<'a>,
1105     pub doc_comment: Option<&'a DocComment<'a>>,
1106     pub static_: bool,
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
1119 #[derive(
1120     Clone,
1121     Debug,
1122     Eq,
1123     FromOcamlRepIn,
1124     Hash,
1125     NoPosHash,
1126     Ord,
1127     PartialEq,
1128     PartialOrd,
1129     Serialize,
1130     ToOcamlRep
1132 pub struct FuncBody<'a, Ex, Fb, En, Hi> {
1133     pub ast: &'a Block<'a, Ex, Fb, En, Hi>,
1134     pub annotation: Fb,
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
1144 #[derive(
1145     Clone,
1146     Debug,
1147     Eq,
1148     FromOcamlRepIn,
1149     Hash,
1150     NoPosHash,
1151     Ord,
1152     PartialEq,
1153     PartialOrd,
1154     Serialize,
1155     ToOcamlRep
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.
1164 #[derive(
1165     Clone,
1166     Debug,
1167     Eq,
1168     FromOcamlRepIn,
1169     Hash,
1170     NoPosHash,
1171     Ord,
1172     PartialEq,
1173     PartialOrd,
1174     Serialize,
1175     ToOcamlRep
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>>;
1182 #[derive(
1183     Clone,
1184     Debug,
1185     Eq,
1186     FromOcamlRepIn,
1187     Hash,
1188     NoPosHash,
1189     Ord,
1190     PartialEq,
1191     PartialOrd,
1192     Serialize,
1193     ToOcamlRep
1195 pub struct UserAttribute<'a, Ex, Fb, En, Hi> {
1196     pub name: Sid<'a>,
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>
1205 #[derive(
1206     Clone,
1207     Debug,
1208     Eq,
1209     FromOcamlRepIn,
1210     Hash,
1211     NoPosHash,
1212     Ord,
1213     PartialEq,
1214     PartialOrd,
1215     Serialize,
1216     ToOcamlRep
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>
1227 #[derive(
1228     Clone,
1229     Debug,
1230     Eq,
1231     FromOcamlRepIn,
1232     Hash,
1233     NoPosHash,
1234     Ord,
1235     PartialEq,
1236     PartialOrd,
1237     Serialize,
1238     ToOcamlRep
1240 pub struct Tparam<'a, Ex, Fb, En, Hi> {
1241     pub variance: oxidized::ast_defs::Variance,
1242     pub name: Sid<'a>,
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>
1253 #[derive(
1254     Clone,
1255     Debug,
1256     Eq,
1257     FromOcamlRepIn,
1258     Hash,
1259     NoPosHash,
1260     Ord,
1261     PartialEq,
1262     PartialOrd,
1263     Serialize,
1264     ToOcamlRep
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> {}
1274 #[derive(
1275     Clone,
1276     Debug,
1277     Eq,
1278     FromOcamlRepIn,
1279     Hash,
1280     NoPosHash,
1281     Ord,
1282     PartialEq,
1283     PartialOrd,
1284     Serialize,
1285     ToOcamlRep
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;
1294 #[derive(
1295     Clone,
1296     Debug,
1297     Eq,
1298     FromOcamlRepIn,
1299     Hash,
1300     NoPosHash,
1301     Ord,
1302     PartialEq,
1303     PartialOrd,
1304     Serialize,
1305     ToOcamlRep
1307 pub struct Class_<'a, Ex, Fb, En, Hi> {
1308     pub span: &'a Pos<'a>,
1309     pub annotation: En,
1310     pub mode: oxidized::file_info::Mode,
1311     pub final_: bool,
1312     pub is_xhp: bool,
1313     pub has_xhp_keyword: bool,
1314     pub kind: oxidized::ast_defs::ClassKind,
1315     pub name: Sid<'a>,
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;
1355 #[derive(
1356     Clone,
1357     Debug,
1358     Eq,
1359     FromOcamlRepIn,
1360     Hash,
1361     NoPosHash,
1362     Ord,
1363     PartialEq,
1364     PartialOrd,
1365     Serialize,
1366     ToOcamlRep
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>
1379 #[derive(
1380     Clone,
1381     Copy,
1382     Debug,
1383     Eq,
1384     FromOcamlRepIn,
1385     Hash,
1386     NoPosHash,
1387     Ord,
1388     PartialEq,
1389     PartialOrd,
1390     Serialize,
1391     ToOcamlRep
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>
1402 #[derive(
1403     Clone,
1404     Debug,
1405     Eq,
1406     FromOcamlRepIn,
1407     Hash,
1408     NoPosHash,
1409     Ord,
1410     PartialEq,
1411     PartialOrd,
1412     Serialize,
1413     ToOcamlRep
1415 pub struct CaField<'a, Ex, Fb, En, Hi> {
1416     pub type_: CaType<'a>,
1417     pub id: Sid<'a>,
1418     pub value: Option<&'a Expr<'a, Ex, Fb, En, Hi>>,
1419     pub required: bool,
1421 impl<'a, Ex: TrivialDrop, Fb: TrivialDrop, En: TrivialDrop, Hi: TrivialDrop> TrivialDrop
1422     for CaField<'a, Ex, Fb, En, Hi>
1426 #[derive(
1427     Clone,
1428     Copy,
1429     Debug,
1430     Eq,
1431     FromOcamlRepIn,
1432     Hash,
1433     NoPosHash,
1434     Ord,
1435     PartialEq,
1436     PartialOrd,
1437     Serialize,
1438     ToOcamlRep
1440 pub enum CaType<'a> {
1441     CAHint(&'a Hint<'a>),
1442     CAEnum(&'a [&'a str]),
1444 impl<'a> TrivialDrop for CaType<'a> {}
1446 #[derive(
1447     Clone,
1448     Debug,
1449     Eq,
1450     FromOcamlRepIn,
1451     Hash,
1452     NoPosHash,
1453     Ord,
1454     PartialEq,
1455     PartialOrd,
1456     Serialize,
1457     ToOcamlRep
1459 pub struct ClassConst<'a, Ex, Fb, En, Hi> {
1460     pub type_: Option<&'a Hint<'a>>,
1461     pub id: Sid<'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>
1471 #[derive(
1472     Clone,
1473     Copy,
1474     Debug,
1475     Eq,
1476     FromOcamlRepIn,
1477     Hash,
1478     NoPosHash,
1479     Ord,
1480     PartialEq,
1481     PartialOrd,
1482     Serialize,
1483     ToOcamlRep
1485 pub enum TypeconstAbstractKind<'a> {
1486     TCAbstract(Option<&'a Hint<'a>>),
1487     TCPartiallyAbstract,
1488     TCConcrete,
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.
1497 #[derive(
1498     Clone,
1499     Debug,
1500     Eq,
1501     FromOcamlRepIn,
1502     Hash,
1503     NoPosHash,
1504     Ord,
1505     PartialEq,
1506     PartialOrd,
1507     Serialize,
1508     ToOcamlRep
1510 pub struct ClassTypeconst<'a, Ex, Fb, En, Hi> {
1511     pub abstract_: TypeconstAbstractKind<'a>,
1512     pub name: Sid<'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>>,
1518     pub is_ctx: bool,
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;
1527 #[derive(
1528     Clone,
1529     Debug,
1530     Eq,
1531     FromOcamlRepIn,
1532     Hash,
1533     NoPosHash,
1534     Ord,
1535     PartialEq,
1536     PartialOrd,
1537     Serialize,
1538     ToOcamlRep
1540 pub struct ClassVar<'a, Ex, Fb, En, Hi> {
1541     pub final_: bool,
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>,
1546     pub id: Sid<'a>,
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>
1559 #[derive(
1560     Clone,
1561     Debug,
1562     Eq,
1563     FromOcamlRepIn,
1564     Hash,
1565     NoPosHash,
1566     Ord,
1567     PartialEq,
1568     PartialOrd,
1569     Serialize,
1570     ToOcamlRep
1572 pub struct Method_<'a, Ex, Fb, En, Hi> {
1573     pub span: &'a Pos<'a>,
1574     pub annotation: En,
1575     pub final_: bool,
1576     pub abstract_: bool,
1577     pub static_: bool,
1578     pub visibility: oxidized::aast::Visibility,
1579     pub name: Sid<'a>,
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)
1592     pub external: bool,
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>;
1602 #[derive(
1603     Clone,
1604     Debug,
1605     Eq,
1606     FromOcamlRepIn,
1607     Hash,
1608     NoPosHash,
1609     Ord,
1610     PartialEq,
1611     PartialOrd,
1612     Serialize,
1613     ToOcamlRep
1615 pub struct Typedef<'a, Ex, Fb, En, Hi> {
1616     pub annotation: En,
1617     pub name: Sid<'a>,
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>
1633 #[derive(
1634     Clone,
1635     Debug,
1636     Eq,
1637     FromOcamlRepIn,
1638     Hash,
1639     NoPosHash,
1640     Ord,
1641     PartialEq,
1642     PartialOrd,
1643     Serialize,
1644     ToOcamlRep
1646 pub struct Gconst<'a, Ex, Fb, En, Hi> {
1647     pub annotation: En,
1648     pub mode: oxidized::file_info::Mode,
1649     pub name: Sid<'a>,
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>
1661 #[derive(
1662     Clone,
1663     Debug,
1664     Eq,
1665     FromOcamlRepIn,
1666     Hash,
1667     NoPosHash,
1668     Ord,
1669     PartialEq,
1670     PartialOrd,
1671     Serialize,
1672     ToOcamlRep
1674 pub struct RecordDef<'a, Ex, Fb, En, Hi> {
1675     pub annotation: En,
1676     pub name: Sid<'a>,
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>;
1695 #[derive(
1696     Clone,
1697     Copy,
1698     Debug,
1699     Eq,
1700     FromOcamlRepIn,
1701     Hash,
1702     NoPosHash,
1703     Ord,
1704     PartialEq,
1705     PartialOrd,
1706     Serialize,
1707     ToOcamlRep
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;