• 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_SEM_BOOL_TYPE_H_
16 #define SRC_SEM_BOOL_TYPE_H_
17 
18 #include <string>
19 
20 #include "src/sem/type.h"
21 
22 // X11 likes to #define Bool leading to confusing error messages.
23 // If its defined, undefine it.
24 #ifdef Bool
25 #undef Bool
26 #endif
27 
28 namespace tint {
29 namespace sem {
30 
31 /// A boolean type
32 class Bool : public Castable<Bool, Type> {
33  public:
34   /// Constructor
35   Bool();
36   /// Move constructor
37   Bool(Bool&&);
38   ~Bool() override;
39 
40   /// @returns the name for this type
41   std::string type_name() const override;
42 
43   /// @param symbols the program's symbol table
44   /// @returns the name for this type that closely resembles how it would be
45   /// declared in WGSL.
46   std::string FriendlyName(const SymbolTable& symbols) const override;
47 
48   /// @returns true if constructible as per
49   /// https://gpuweb.github.io/gpuweb/wgsl/#constructible-types
50   bool IsConstructible() const override;
51 
52   /// @returns the size in bytes of the type.
53   /// @note: booleans are not host-sharable, but still may exist in workgroup
54   /// storage.
55   uint32_t Size() const override;
56 
57   /// @returns the alignment in bytes of the type.
58   /// @note: booleans are not host-sharable, but still may exist in workgroup
59   /// storage.
60   uint32_t Align() const override;
61 };
62 
63 }  // namespace sem
64 }  // namespace tint
65 
66 #endif  // SRC_SEM_BOOL_TYPE_H_
67