codegen/syntax/DoStatement.hack (353 lines of code) (raw):

/** * This file is generated. Do not modify it manually! * * @generated SignedSource<<24321f71e828648d2d96dce6c09f971a>> */ 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 DoStatement extends Node implements IControlFlowStatement, ILoopStatement, IStatement { const string SYNTAX_KIND = 'do_statement'; private DoToken $_keyword; private IStatement $_body; private WhileToken $_while_keyword; private LeftParenToken $_left_paren; private IExpression $_condition; private RightParenToken $_right_paren; private SemicolonToken $_semicolon; public function __construct( DoToken $keyword, IStatement $body, WhileToken $while_keyword, LeftParenToken $left_paren, IExpression $condition, RightParenToken $right_paren, SemicolonToken $semicolon, ?__Private\SourceRef $source_ref = null, ) { $this->_keyword = $keyword; $this->_body = $body; $this->_while_keyword = $while_keyword; $this->_left_paren = $left_paren; $this->_condition = $condition; $this->_right_paren = $right_paren; $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['do_keyword']) as dict<_, _>, $file, $offset, $source, 'DoToken', ); $keyword = $keyword as nonnull; $offset += $keyword->getWidth(); $body = Node::fromJSON( ($json['do_body']) as dict<_, _>, $file, $offset, $source, 'IStatement', ); $body = $body as nonnull; $offset += $body->getWidth(); $while_keyword = Node::fromJSON( ($json['do_while_keyword']) as dict<_, _>, $file, $offset, $source, 'WhileToken', ); $while_keyword = $while_keyword as nonnull; $offset += $while_keyword->getWidth(); $left_paren = Node::fromJSON( ($json['do_left_paren']) as dict<_, _>, $file, $offset, $source, 'LeftParenToken', ); $left_paren = $left_paren as nonnull; $offset += $left_paren->getWidth(); $condition = Node::fromJSON( ($json['do_condition']) as dict<_, _>, $file, $offset, $source, 'IExpression', ); $condition = $condition as nonnull; $offset += $condition->getWidth(); $right_paren = Node::fromJSON( ($json['do_right_paren']) as dict<_, _>, $file, $offset, $source, 'RightParenToken', ); $right_paren = $right_paren as nonnull; $offset += $right_paren->getWidth(); $semicolon = Node::fromJSON( ($json['do_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] */ $body, /* HH_IGNORE_ERROR[4110] */ $while_keyword, /* HH_IGNORE_ERROR[4110] */ $left_paren, /* HH_IGNORE_ERROR[4110] */ $condition, /* HH_IGNORE_ERROR[4110] */ $right_paren, /* HH_IGNORE_ERROR[4110] */ $semicolon, $source_ref, ); } <<__Override>> public function getChildren(): dict<string, Node> { return dict[ 'keyword' => $this->_keyword, 'body' => $this->_body, 'while_keyword' => $this->_while_keyword, 'left_paren' => $this->_left_paren, 'condition' => $this->_condition, 'right_paren' => $this->_right_paren, '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); $body = $rewriter($this->_body, $parents); $while_keyword = $rewriter($this->_while_keyword, $parents); $left_paren = $rewriter($this->_left_paren, $parents); $condition = $rewriter($this->_condition, $parents); $right_paren = $rewriter($this->_right_paren, $parents); $semicolon = $rewriter($this->_semicolon, $parents); if ( $keyword === $this->_keyword && $body === $this->_body && $while_keyword === $this->_while_keyword && $left_paren === $this->_left_paren && $condition === $this->_condition && $right_paren === $this->_right_paren && $semicolon === $this->_semicolon ) { return $this; } return new static( $keyword as DoToken, $body as IStatement, $while_keyword as WhileToken, $left_paren as LeftParenToken, $condition as IExpression, $right_paren as RightParenToken, $semicolon as SemicolonToken, ); } public function getKeywordUNTYPED(): ?Node { return $this->_keyword; } public function withKeyword(DoToken $value): this { if ($value === $this->_keyword) { return $this; } return new static( $value, $this->_body, $this->_while_keyword, $this->_left_paren, $this->_condition, $this->_right_paren, $this->_semicolon, ); } public function hasKeyword(): bool { return true; } /** * @return DoToken */ public function getKeyword(): DoToken { return TypeAssert\instance_of(DoToken::class, $this->_keyword); } /** * @return DoToken */ public function getKeywordx(): DoToken { return $this->getKeyword(); } public function getBodyUNTYPED(): ?Node { return $this->_body; } public function withBody(IStatement $value): this { if ($value === $this->_body) { return $this; } return new static( $this->_keyword, $value, $this->_while_keyword, $this->_left_paren, $this->_condition, $this->_right_paren, $this->_semicolon, ); } public function hasBody(): bool { return true; } /** * @return CompoundStatement | ExpressionStatement */ public function getBody(): IStatement { return TypeAssert\instance_of(IStatement::class, $this->_body); } /** * @return CompoundStatement | ExpressionStatement */ public function getBodyx(): IStatement { return $this->getBody(); } public function getWhileKeywordUNTYPED(): ?Node { return $this->_while_keyword; } public function withWhileKeyword(WhileToken $value): this { if ($value === $this->_while_keyword) { return $this; } return new static( $this->_keyword, $this->_body, $value, $this->_left_paren, $this->_condition, $this->_right_paren, $this->_semicolon, ); } public function hasWhileKeyword(): bool { return true; } /** * @return WhileToken */ public function getWhileKeyword(): WhileToken { return TypeAssert\instance_of(WhileToken::class, $this->_while_keyword); } /** * @return WhileToken */ public function getWhileKeywordx(): WhileToken { return $this->getWhileKeyword(); } public function getLeftParenUNTYPED(): ?Node { return $this->_left_paren; } public function withLeftParen(LeftParenToken $value): this { if ($value === $this->_left_paren) { return $this; } return new static( $this->_keyword, $this->_body, $this->_while_keyword, $value, $this->_condition, $this->_right_paren, $this->_semicolon, ); } public function hasLeftParen(): bool { return true; } /** * @return LeftParenToken */ public function getLeftParen(): LeftParenToken { return TypeAssert\instance_of(LeftParenToken::class, $this->_left_paren); } /** * @return LeftParenToken */ public function getLeftParenx(): LeftParenToken { return $this->getLeftParen(); } public function getConditionUNTYPED(): ?Node { return $this->_condition; } public function withCondition(IExpression $value): this { if ($value === $this->_condition) { return $this; } return new static( $this->_keyword, $this->_body, $this->_while_keyword, $this->_left_paren, $value, $this->_right_paren, $this->_semicolon, ); } public function hasCondition(): bool { return true; } /** * @return BinaryExpression | LiteralExpression | SubscriptExpression | * VariableExpression */ public function getCondition(): IExpression { return TypeAssert\instance_of(IExpression::class, $this->_condition); } /** * @return BinaryExpression | LiteralExpression | SubscriptExpression | * VariableExpression */ public function getConditionx(): IExpression { return $this->getCondition(); } public function getRightParenUNTYPED(): ?Node { return $this->_right_paren; } public function withRightParen(RightParenToken $value): this { if ($value === $this->_right_paren) { return $this; } return new static( $this->_keyword, $this->_body, $this->_while_keyword, $this->_left_paren, $this->_condition, $value, $this->_semicolon, ); } public function hasRightParen(): bool { return true; } /** * @return RightParenToken */ public function getRightParen(): RightParenToken { return TypeAssert\instance_of(RightParenToken::class, $this->_right_paren); } /** * @return RightParenToken */ public function getRightParenx(): RightParenToken { return $this->getRightParen(); } 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->_body, $this->_while_keyword, $this->_left_paren, $this->_condition, $this->_right_paren, $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(); } }