reader/wgsl: Migrate to AST types

Bug: tint:724
Change-Id: I484813dd139122244cd09829ab5b035cec9981e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49960
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h
index 9304350..513da69 100644
--- a/src/reader/wgsl/parser_impl.h
+++ b/src/reader/wgsl/parser_impl.h
@@ -211,12 +211,12 @@
     /// @param type_in parsed type
     /// @param name_in parsed identifier
     /// @param source_in source to the identifier
-    TypedIdentifier(typ::Type type_in, std::string name_in, Source source_in);
+    TypedIdentifier(ast::Type* type_in, std::string name_in, Source source_in);
     /// Destructor
     ~TypedIdentifier();
 
     /// Parsed type.
-    typ::Type type;
+    ast::Type* type;
     /// Parsed identifier.
     std::string name;
     /// Source to the identifier.
@@ -239,7 +239,7 @@
     FunctionHeader(Source src,
                    std::string n,
                    ast::VariableList p,
-                   typ::Type ret_ty,
+                   ast::Type* ret_ty,
                    ast::DecorationList ret_decos);
     /// Destructor
     ~FunctionHeader();
@@ -255,7 +255,7 @@
     /// Function parameters
     ast::VariableList params;
     /// Function return type
-    typ::Type return_type;
+    ast::Type* return_type;
     /// Function return type decorations
     ast::DecorationList return_type_decorations;
   };
@@ -275,7 +275,7 @@
     VarDeclInfo(Source source_in,
                 std::string name_in,
                 ast::StorageClass storage_class_in,
-                typ::Type type_in);
+                ast::Type* type_in);
     /// Destructor
     ~VarDeclInfo();
 
@@ -286,7 +286,7 @@
     /// Variable storage class
     ast::StorageClass storage_class;
     /// Variable type
-    typ::Type type;
+    ast::Type* type = nullptr;
   };
 
   /// Creates a new parser using the given file
@@ -365,12 +365,12 @@
   /// TODO(crbug.com/tint/724): Remove
   /// @param name the constructed name
   /// @param type the constructed type
-  void register_constructed(const std::string& name, sem::Type* type);
+  void register_constructed(const std::string& name, const ast::Type* type);
   /// Retrieves a constructed type
   /// TODO(crbug.com/tint/724): Remove
   /// @param name The name to lookup
   /// @returns the constructed type for `name` or `nullptr` if not found
-  sem::Type* get_constructed(const std::string& name);
+  const ast::Type* get_constructed(const std::string& name);
 
   /// Parses the `translation_unit` grammar element
   void translation_unit();
@@ -400,15 +400,15 @@
   Maybe<ast::StorageClass> variable_storage_decoration();
   /// Parses a `type_alias` grammar element
   /// @returns the type alias or nullptr on error
-  Maybe<typ::Alias> type_alias();
+  Maybe<ast::Alias*> type_alias();
   /// Parses a `type_decl` grammar element
   /// @returns the parsed Type or nullptr if none matched.
-  Maybe<typ::Type> type_decl();
+  Maybe<ast::Type*> type_decl();
   /// Parses a `type_decl` grammar element with the given pre-parsed
   /// decorations.
   /// @param decos the list of decorations for the type.
   /// @returns the parsed Type or nullptr if none matched.
-  Maybe<typ::Type> type_decl(ast::DecorationList& decos);
+  Maybe<ast::Type*> type_decl(ast::DecorationList& decos);
   /// Parses a `storage_class` grammar element, erroring on parse failure.
   /// @param use a description of what was being parsed if an error was raised.
   /// @returns the storage class or StorageClass::kNone if none matched
@@ -417,7 +417,7 @@
   /// `struct_decoration_decl*` provided as `decos`.
   /// @returns the struct type or nullptr on error
   /// @param decos the list of decorations for the struct declaration.
-  Maybe<typ::Struct> struct_decl(ast::DecorationList& decos);
+  Maybe<ast::Struct*> struct_decl(ast::DecorationList& decos);
   /// Parses a `struct_body_decl` grammar element, erroring on parse failure.
   /// @returns the struct members
   Expect<ast::StructMemberList> expect_struct_body_decl();
@@ -434,10 +434,10 @@
   Maybe<ast::Function*> function_decl(ast::DecorationList& decos);
   /// Parses a `texture_sampler_types` grammar element
   /// @returns the parsed Type or nullptr if none matched.
-  Maybe<typ::Type> texture_sampler_types();
+  Maybe<ast::Type*> texture_sampler_types();
   /// Parses a `sampler_type` grammar element
   /// @returns the parsed Type or nullptr if none matched.
-  Maybe<typ::Type> sampler_type();
+  Maybe<ast::Type*> sampler_type();
   /// Parses a `multisampled_texture_type` grammar element
   /// @returns returns the multisample texture dimension or kNone if none
   /// matched.
@@ -451,17 +451,17 @@
   Maybe<ast::TextureDimension> storage_texture_type();
   /// Parses a `depth_texture_type` grammar element
   /// @returns the parsed Type or nullptr if none matched.
-  Maybe<typ::Type> depth_texture_type();
+  Maybe<ast::Type*> depth_texture_type();
   /// Parses a 'texture_external_type' grammar element
   /// @returns the parsed Type or nullptr if none matched
-  Maybe<typ::Type> external_texture_type();
+  Maybe<ast::Type*> external_texture_type();
   /// Parses a `image_storage_type` grammar element
   /// @param use a description of what was being parsed if an error was raised
   /// @returns returns the image format or kNone if none matched.
   Expect<ast::ImageFormat> expect_image_storage_type(const std::string& use);
   /// Parses a `function_type_decl` grammar element
   /// @returns the parsed type or nullptr otherwise
-  Maybe<typ::Type> function_type_decl();
+  Maybe<ast::Type*> function_type_decl();
   /// Parses a `function_header` grammar element
   /// @returns the parsed function header
   Maybe<FunctionHeader> function_header();
@@ -827,12 +827,12 @@
   /// Used to ensure that all decorations are consumed.
   bool expect_decorations_consumed(const ast::DecorationList& list);
 
-  Expect<typ::Type> expect_type_decl_pointer(Token t);
-  Expect<typ::Type> expect_type_decl_vector(Token t);
-  Expect<typ::Type> expect_type_decl_array(Token t, ast::DecorationList decos);
-  Expect<typ::Type> expect_type_decl_matrix(Token t);
+  Expect<ast::Type*> expect_type_decl_pointer(Token t);
+  Expect<ast::Type*> expect_type_decl_vector(Token t);
+  Expect<ast::Type*> expect_type_decl_array(Token t, ast::DecorationList decos);
+  Expect<ast::Type*> expect_type_decl_matrix(Token t);
 
-  Expect<typ::Type> expect_type(const std::string& use);
+  Expect<ast::Type*> expect_type(const std::string& use);
 
   Maybe<ast::Statement*> non_block_statement();
   Maybe<ast::Statement*> for_header_initializer();
@@ -858,7 +858,7 @@
   uint32_t sync_depth_ = 0;
   std::vector<Token::Type> sync_tokens_;
   int silence_errors_ = 0;
-  std::unordered_map<std::string, sem::Type*> registered_constructs_;
+  std::unordered_map<std::string, const ast::Type*> registered_constructs_;
   ProgramBuilder builder_;
   size_t max_errors_ = 25;
 };