• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Tint Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SRC_AST_POINTER_H_
16 #define SRC_AST_POINTER_H_
17 
18 #include <string>
19 
20 #include "src/ast/access.h"
21 #include "src/ast/storage_class.h"
22 #include "src/ast/type.h"
23 
24 namespace tint {
25 namespace ast {
26 
27 /// A pointer type.
28 class Pointer : public Castable<Pointer, Type> {
29  public:
30   /// Constructor
31   /// @param pid the identifier of the program that owns this node
32   /// @param src the source of this node
33   /// @param subtype the pointee type
34   /// @param storage_class the storage class of the pointer
35   /// @param access the access control of the pointer
36   Pointer(ProgramID pid,
37           const Source& src,
38           const Type* const subtype,
39           ast::StorageClass storage_class,
40           ast::Access access);
41   /// Move constructor
42   Pointer(Pointer&&);
43   ~Pointer() override;
44 
45   /// @param symbols the program's symbol table
46   /// @returns the name for this type that closely resembles how it would be
47   /// declared in WGSL.
48   std::string FriendlyName(const SymbolTable& symbols) const override;
49 
50   /// Clones this type and all transitive types using the `CloneContext` `ctx`.
51   /// @param ctx the clone context
52   /// @return the newly cloned type
53   const Pointer* Clone(CloneContext* ctx) const override;
54 
55   /// The pointee type
56   const Type* const type;
57 
58   /// The storage class of the pointer
59   ast::StorageClass const storage_class;
60 
61   /// The access control of the pointer
62   ast::Access const access;
63 };
64 
65 }  // namespace ast
66 }  // namespace tint
67 
68 #endif  // SRC_AST_POINTER_H_
69