codegen/syntax/ReturnStatement.hack (156 lines of code) (raw):

/** * This file is generated. Do not modify it manually! * * @generated SignedSource<<64e40af6229db1b770b0e52ce6f2e184>> */ namespace Facebook\HHAST; use namespace Facebook\TypeAssert; use namespace HH\Lib\Dict; /* HHAST_IGNORE_ALL[5607] 5607 is ignored because of false positives when comparing a generic to a typed value */ /* HHAST_IGNORE_ALL[5624] HHAST_IGNORE_ALL[5639] 5624 and 5639 are ignored because they insist on using co(tra)variant generics. Could this break external consumers? */ <<__ConsistentConstruct>> final class ReturnStatement extends Node implements IStatement { const string SYNTAX_KIND = 'return_statement'; private ReturnToken $_keyword; private ?IExpression $_expression; private SemicolonToken $_semicolon; public function __construct( ReturnToken $keyword, ?IExpression $expression, SemicolonToken $semicolon, ?__Private\SourceRef $source_ref = null, ) { $this->_keyword = $keyword; $this->_expression = $expression; $this->_semicolon = $semicolon; parent::__construct($source_ref); } <<__Override>> public static function fromJSON( dict<arraykey, mixed> $json, string $file, int $initial_offset, string $source, string $_type_hint, ): this { $offset = $initial_offset; $keyword = Node::fromJSON( ($json['return_keyword']) as dict<_, _>, $file, $offset, $source, 'ReturnToken', ); $keyword = $keyword as nonnull; $offset += $keyword->getWidth(); $expression = Node::fromJSON( ($json['return_expression'] ?? dict['kind' => 'missing']) as dict<_, _>, $file, $offset, $source, 'IExpression', ); $offset += $expression?->getWidth() ?? 0; $semicolon = Node::fromJSON( ($json['return_semicolon']) as dict<_, _>, $file, $offset, $source, 'SemicolonToken', ); $semicolon = $semicolon as nonnull; $offset += $semicolon->getWidth(); $source_ref = shape( 'file' => $file, 'source' => $source, 'offset' => $initial_offset, 'width' => $offset - $initial_offset, ); return new static( /* HH_IGNORE_ERROR[4110] */ $keyword, /* HH_IGNORE_ERROR[4110] */ $expression, /* HH_IGNORE_ERROR[4110] */ $semicolon, $source_ref, ); } <<__Override>> public function getChildren(): dict<string, Node> { return dict[ 'keyword' => $this->_keyword, 'expression' => $this->_expression, 'semicolon' => $this->_semicolon, ] |> Dict\filter_nulls($$); } <<__Override>> public function rewriteChildren<Tret as ?Node>( (function(Node, vec<Node>): Tret) $rewriter, vec<Node> $parents = vec[], ): this { $parents[] = $this; $keyword = $rewriter($this->_keyword, $parents); $expression = $this->_expression === null ? null : $rewriter($this->_expression, $parents); $semicolon = $rewriter($this->_semicolon, $parents); if ( $keyword === $this->_keyword && $expression === $this->_expression && $semicolon === $this->_semicolon ) { return $this; } return new static( $keyword as ReturnToken, $expression as ?IExpression, $semicolon as SemicolonToken, ); } public function getKeywordUNTYPED(): ?Node { return $this->_keyword; } public function withKeyword(ReturnToken $value): this { if ($value === $this->_keyword) { return $this; } return new static($value, $this->_expression, $this->_semicolon); } public function hasKeyword(): bool { return true; } /** * @return ReturnToken */ public function getKeyword(): ReturnToken { return TypeAssert\instance_of(ReturnToken::class, $this->_keyword); } /** * @return ReturnToken */ public function getKeywordx(): ReturnToken { return $this->getKeyword(); } public function getExpressionUNTYPED(): ?Node { return $this->_expression; } public function withExpression(?IExpression $value): this { if ($value === $this->_expression) { return $this; } return new static($this->_keyword, $value, $this->_semicolon); } public function hasExpression(): bool { return $this->_expression !== null; } /** * @return AnonymousFunction | AsExpression | AwaitableCreationExpression | * BinaryExpression | CastExpression | CollectionLiteralExpression | * ConditionalExpression | DarrayIntrinsicExpression | * DictionaryIntrinsicExpression | FunctionCallExpression | * FunctionPointerExpression | IsExpression | IssetExpression | * KeysetIntrinsicExpression | LambdaExpression | LiteralExpression | * MemberSelectionExpression | null | NullableAsExpression | * ObjectCreationExpression | ParenthesizedExpression | * PostfixUnaryExpression | PrefixUnaryExpression | QualifiedName | * SafeMemberSelectionExpression | ScopeResolutionExpression | * ShapeExpression | SubscriptExpression | NameToken | TupleExpression | * VariableExpression | VarrayIntrinsicExpression | VectorIntrinsicExpression * | XHPExpression */ public function getExpression(): ?IExpression { return $this->_expression; } /** * @return AnonymousFunction | AsExpression | AwaitableCreationExpression | * BinaryExpression | CastExpression | CollectionLiteralExpression | * ConditionalExpression | DarrayIntrinsicExpression | * DictionaryIntrinsicExpression | FunctionCallExpression | * FunctionPointerExpression | IsExpression | IssetExpression | * KeysetIntrinsicExpression | LambdaExpression | LiteralExpression | * MemberSelectionExpression | NullableAsExpression | * ObjectCreationExpression | ParenthesizedExpression | * PostfixUnaryExpression | PrefixUnaryExpression | QualifiedName | * SafeMemberSelectionExpression | ScopeResolutionExpression | * ShapeExpression | SubscriptExpression | NameToken | TupleExpression | * VariableExpression | VarrayIntrinsicExpression | VectorIntrinsicExpression * | XHPExpression */ public function getExpressionx(): IExpression { return TypeAssert\not_null($this->getExpression()); } public function getSemicolonUNTYPED(): ?Node { return $this->_semicolon; } public function withSemicolon(SemicolonToken $value): this { if ($value === $this->_semicolon) { return $this; } return new static($this->_keyword, $this->_expression, $value); } public function hasSemicolon(): bool { return true; } /** * @return SemicolonToken */ public function getSemicolon(): SemicolonToken { return TypeAssert\instance_of(SemicolonToken::class, $this->_semicolon); } /** * @return SemicolonToken */ public function getSemicolonx(): SemicolonToken { return $this->getSemicolon(); } }