From 852924e89f2e7d53475d370899c05718367540a9 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Tue, 3 Nov 2020 16:06:40 -0600 Subject: [PATCH] Update schema for 4.82 Should be backwards compatible --- codegen/inferred_relationships.hack | 5 +- codegen/node_from_json.hack | 3 +- codegen/schema.json | 12 +- codegen/syntax/EnumAtomExpression.hack | 153 ++++++++++++++++++ codegen/syntax/VectorTypeSpecifier.hack | 6 +- codegen/token_from_data.hack | 3 +- codegen/tokens/HashToken.hack | 20 +++ codegen/version.hack | 8 +- .../is_compatible_schema_version.hack | 6 +- 9 files changed, 202 insertions(+), 14 deletions(-) create mode 100644 codegen/syntax/EnumAtomExpression.hack create mode 100644 codegen/tokens/HashToken.hack diff --git a/codegen/inferred_relationships.hack b/codegen/inferred_relationships.hack index 5152ded89..43f756457 100644 --- a/codegen/inferred_relationships.hack +++ b/codegen/inferred_relationships.hack @@ -1,7 +1,7 @@ /** * This file is generated. Do not modify it manually! * - * @generated SignedSource<<5282f75e48f65d8be4d609d99d2c5b8c>> + * @generated SignedSource<<198d9068133ef2e781ad183c58353e2d>> */ namespace Facebook\HHAST\__Private; @@ -1714,6 +1714,7 @@ const dict> INFERRED_RELATIONSHIPS = dict[ 'list>', 'list|list_item>', 'list|list_item|list_item>', + 'list|list_item>', 'list|list_item>', 'list|list_item>', 'list>', @@ -3625,6 +3626,7 @@ const dict> INFERRED_RELATIONSHIPS = dict[ 'list|list_item|list_item>', 'list|list_item>', 'list|list_item|list_item>', + 'list|list_item>', 'list|list_item|list_item>', 'list>', 'list|list_item>', @@ -3674,6 +3676,7 @@ const dict> INFERRED_RELATIONSHIPS = dict[ 'shape_type_specifier', 'simple_type_specifier', 'tuple_type_specifier', + 'type_constant', 'vector_type_specifier', ], 'where_clause.where_clause_constraints' => keyset[ diff --git a/codegen/node_from_json.hack b/codegen/node_from_json.hack index fca9afeac..cd055f51c 100644 --- a/codegen/node_from_json.hack +++ b/codegen/node_from_json.hack @@ -1,7 +1,7 @@ /** * This file is generated. Do not modify it manually! * - * @generated SignedSource<<226e3cf5c27b24aa5d0412f84933db9d>> + * @generated SignedSource<<362d5127a139ca80857f15705c91f5ca>> */ namespace Facebook\HHAST\__Private; use namespace Facebook\HHAST; @@ -86,6 +86,7 @@ function node_from_json_unwrapped( HHAST\EmbeddedMemberSelectionExpression::class, 'embedded_subscript_expression' => HHAST\EmbeddedSubscriptExpression::class, 'end_of_file' => HHAST\EndOfFile::class, + 'enum_atom' => HHAST\EnumAtomExpression::class, 'enum_class_declaration' => HHAST\EnumClassDeclaration::class, 'enum_class_enumerator' => HHAST\EnumClassEnumerator::class, 'enum_declaration' => HHAST\EnumDeclaration::class, diff --git a/codegen/schema.json b/codegen/schema.json index ba2730b9b..49ecd3d44 100644 --- a/codegen/schema.json +++ b/codegen/schema.json @@ -1,6 +1,6 @@ { "description" : "@generated JSON schema of the Hack Full Fidelity Parser AST", - "version" : "2020-10-15-0001", + "version" : "2020-10-29-0001", "trivia" : [ { "trivia_kind_name" : "WhiteSpace", "trivia_type_name" : "whitespace" }, @@ -383,6 +383,8 @@ "token_text" : "`" }, { "token_kind" : "XHP", "token_text" : "xhp" }, + { "token_kind" : "Hash", + "token_text" : "#" }, { "token_kind" : "ErrorToken", "token_text" : null }, @@ -2090,6 +2092,14 @@ { "field_name" : "item" }, { "field_name" : "separator" } ] }, + { "kind_name" : "EnumAtomExpression", + "type_name" : "enum_atom_expression", + "description" : "enum_atom", + "prefix" : "enum_atom", + "fields" : [ + { "field_name" : "hash" }, + { "field_name" : "expression" } + ] }, { "kind_name" : "PocketAtomExpression", "type_name" : "pocket_atom_expression", "description" : "pocket_atom", diff --git a/codegen/syntax/EnumAtomExpression.hack b/codegen/syntax/EnumAtomExpression.hack new file mode 100644 index 000000000..e7552e831 --- /dev/null +++ b/codegen/syntax/EnumAtomExpression.hack @@ -0,0 +1,153 @@ +/** + * This file is generated. Do not modify it manually! + * + * @generated SignedSource<<67e3dba3bbbb8c97fafadb0c7b35af92>> + */ +namespace Facebook\HHAST; +use namespace Facebook\TypeAssert; +use namespace HH\Lib\Dict; + +<<__ConsistentConstruct>> +final class EnumAtomExpression + extends Node + implements ILambdaBody, IExpression { + + const string SYNTAX_KIND = 'enum_atom_expression'; + + private ?Node $_hash; + private ?Node $_expression; + + public function __construct( + ?Node $hash, + ?Node $expression, + ?__Private\SourceRef $source_ref = null, + ) { + $this->_hash = $hash; + $this->_expression = $expression; + parent::__construct($source_ref); + } + + <<__Override>> + public static function fromJSON( + dict $json, + string $file, + int $initial_offset, + string $source, + string $_type_hint, + ): this { + $offset = $initial_offset; + $hash = Node::fromJSON( + /* HH_FIXME[4110] */ $json['enum_atom_hash'] ?? dict['kind' => 'missing'], + $file, + $offset, + $source, + 'Node', + ); + $offset += $hash?->getWidth() ?? 0; + $expression = Node::fromJSON( + /* HH_FIXME[4110] */ $json['enum_atom_expression'] ?? dict['kind' => 'missing'], + $file, + $offset, + $source, + 'Node', + ); + $offset += $expression?->getWidth() ?? 0; + $source_ref = shape( + 'file' => $file, + 'source' => $source, + 'offset' => $initial_offset, + 'width' => $offset - $initial_offset, + ); + return new static( + /* HH_IGNORE_ERROR[4110] */ $hash, + /* HH_IGNORE_ERROR[4110] */ $expression, + $source_ref, + ); + } + + <<__Override>> + public function getChildren(): dict { + return dict[ + 'hash' => $this->_hash, + 'expression' => $this->_expression, + ] + |> Dict\filter_nulls($$); + } + + <<__Override>> + public function rewriteChildren( + (function(Node, vec): Tret) $rewriter, + vec $parents = vec[], + ): this { + $parents[] = $this; + $hash = $this->_hash === null ? null : $rewriter($this->_hash, $parents); + $expression = $this->_expression === null + ? null + : $rewriter($this->_expression, $parents); + if ($hash === $this->_hash && $expression === $this->_expression) { + return $this; + } + return new static( + /* HH_FIXME[4110] use `as` */ $hash, + /* HH_FIXME[4110] use `as` */ $expression, + ); + } + + public function getHashUNTYPED(): ?Node { + return $this->_hash; + } + + public function withHash(?Node $value): this { + if ($value === $this->_hash) { + return $this; + } + return new static($value, $this->_expression); + } + + public function hasHash(): bool { + return $this->_hash !== null; + } + + /** + * @return unknown + */ + public function getHash(): ?Node { + return $this->_hash; + } + + /** + * @return unknown + */ + public function getHashx(): Node { + return TypeAssert\not_null($this->getHash()); + } + + public function getExpressionUNTYPED(): ?Node { + return $this->_expression; + } + + public function withExpression(?Node $value): this { + if ($value === $this->_expression) { + return $this; + } + return new static($this->_hash, $value); + } + + public function hasExpression(): bool { + return $this->_expression !== null; + } + + /** + * @return unknown + */ + public function getExpression(): ?Node { + return $this->_expression; + } + + /** + * @return unknown + */ + public function getExpressionx(): Node { + return TypeAssert\not_null($this->getExpression()); + } +} diff --git a/codegen/syntax/VectorTypeSpecifier.hack b/codegen/syntax/VectorTypeSpecifier.hack index 53b7b56db..0cfbef3a2 100644 --- a/codegen/syntax/VectorTypeSpecifier.hack +++ b/codegen/syntax/VectorTypeSpecifier.hack @@ -1,7 +1,7 @@ /** * This file is generated. Do not modify it manually! * - * @generated SignedSource<<832b8f863b0c10ea5d6e495cc6c04d25>> + * @generated SignedSource<<594ef0716f6cde73ff47fdd83a79366e>> */ namespace Facebook\HHAST; use namespace Facebook\TypeAssert; @@ -241,7 +241,7 @@ final class VectorTypeSpecifier extends Node implements ITypeSpecifier { * @return ClassnameTypeSpecifier | DarrayTypeSpecifier | * DictionaryTypeSpecifier | GenericTypeSpecifier | LikeTypeSpecifier | * NullableTypeSpecifier | ShapeTypeSpecifier | SimpleTypeSpecifier | - * TupleTypeSpecifier | VectorTypeSpecifier + * TupleTypeSpecifier | TypeConstant | VectorTypeSpecifier */ public function getType(): ITypeSpecifier { return TypeAssert\instance_of(ITypeSpecifier::class, $this->_type); @@ -251,7 +251,7 @@ final class VectorTypeSpecifier extends Node implements ITypeSpecifier { * @return ClassnameTypeSpecifier | DarrayTypeSpecifier | * DictionaryTypeSpecifier | GenericTypeSpecifier | LikeTypeSpecifier | * NullableTypeSpecifier | ShapeTypeSpecifier | SimpleTypeSpecifier | - * TupleTypeSpecifier | VectorTypeSpecifier + * TupleTypeSpecifier | TypeConstant | VectorTypeSpecifier */ public function getTypex(): ITypeSpecifier { return $this->getType(); diff --git a/codegen/token_from_data.hack b/codegen/token_from_data.hack index b0fce9d6a..35243bce2 100644 --- a/codegen/token_from_data.hack +++ b/codegen/token_from_data.hack @@ -1,7 +1,7 @@ /** * This file is generated. Do not modify it manually! * - * @generated SignedSource<<2a3d54962108983a525569eaf3d76d3c>> + * @generated SignedSource<<6a301547c5e0f63f2fbdae567c256bb9>> */ namespace Facebook\HHAST\__Private; use namespace Facebook\HHAST; @@ -209,6 +209,7 @@ class TokenClassMap { '>=' => HHAST\GreaterThanEqualToken::class, '>>' => HHAST\GreaterThanGreaterThanToken::class, '>>=' => HHAST\GreaterThanGreaterThanEqualToken::class, + '#' => HHAST\HashToken::class, '{' => HHAST\LeftBraceToken::class, '[' => HHAST\LeftBracketToken::class, '(' => HHAST\LeftParenToken::class, diff --git a/codegen/tokens/HashToken.hack b/codegen/tokens/HashToken.hack new file mode 100644 index 000000000..09d1662e6 --- /dev/null +++ b/codegen/tokens/HashToken.hack @@ -0,0 +1,20 @@ +/** + * This file is generated. Do not modify it manually! + * + * @generated SignedSource<> + */ +namespace Facebook\HHAST; + +final class HashToken extends TokenWithFixedText { + + const string KIND = '#'; + const string TEXT = '#'; + + public function __construct( + ?NodeList $leading, + ?NodeList $trailing, + ?__Private\SourceRef $source_ref = null, + ) { + parent::__construct($leading, $trailing, $source_ref); + } +} diff --git a/codegen/version.hack b/codegen/version.hack index f15d4d3bb..6a26855c3 100644 --- a/codegen/version.hack +++ b/codegen/version.hack @@ -1,12 +1,12 @@ /** * This file is generated. Do not modify it manually! * - * @generated SignedSource<<1c606820a1ea581040b5500eb85e8304>> + * @generated SignedSource<<1005817d9ee6ed4eb52f686556f16344>> */ namespace Facebook\HHAST; -const string SCHEMA_VERSION = '2020-10-15-0001'; +const string SCHEMA_VERSION = '2020-10-29-0001'; -const int HHVM_VERSION_ID = 408000; +const int HHVM_VERSION_ID = 408200; -const string HHVM_VERSION = '4.80.0-dev'; +const string HHVM_VERSION = '4.82.0'; diff --git a/src/__Private/is_compatible_schema_version.hack b/src/__Private/is_compatible_schema_version.hack index 3c92d0f7d..e5734183b 100644 --- a/src/__Private/is_compatible_schema_version.hack +++ b/src/__Private/is_compatible_schema_version.hack @@ -21,7 +21,7 @@ use const Facebook\HHAST\SCHEMA_VERSION; */ function is_compatible_schema_version(string $other_version): bool { invariant( - SCHEMA_VERSION === '2020-10-15-0001', + SCHEMA_VERSION === '2020-10-29-0001', '%s needs updating', __FILE__, ); @@ -32,10 +32,10 @@ function is_compatible_schema_version(string $other_version): bool { // Return true if $other_version is a subset of SCHEMA_VERSION switch ($other_version) { - /* // preceding versions: - case 'version-number': // missing ... + case '2020-10-15-0001': return true; + /* // succeeding versions: case 'version-number': // missing ... return true;