naga/keywords/
wgsl.rs

1/*!
2Keywords for [WGSL][wgsl] (WebGPU Shading Language).
3
4[wgsl]: https://gpuweb.github.io/gpuweb/wgsl.html
5*/
6
7use crate::proc::KeywordSet;
8use crate::racy_lock::RacyLock;
9
10// https://gpuweb.github.io/gpuweb/wgsl/#keyword-summary
11// last sync: https://github.com/gpuweb/gpuweb/blob/39f2321f547c8f0b7f473cf1d47fba30b1691303/wgsl/index.bs
12pub const RESERVED: &[&str] = &[
13    // Type-defining Keywords
14    "array",
15    "atomic",
16    "bool",
17    "f32",
18    "f16",
19    "i32",
20    "i64",
21    "mat2x2",
22    "mat2x3",
23    "mat2x4",
24    "mat3x2",
25    "mat3x3",
26    "mat3x4",
27    "mat4x2",
28    "mat4x3",
29    "mat4x4",
30    "ptr",
31    "sampler",
32    "sampler_comparison",
33    "texture_1d",
34    "texture_2d",
35    "texture_2d_array",
36    "texture_3d",
37    "texture_cube",
38    "texture_cube_array",
39    "texture_multisampled_2d",
40    "texture_storage_1d",
41    "texture_storage_2d",
42    "texture_storage_2d_array",
43    "texture_storage_3d",
44    "texture_depth_2d",
45    "texture_depth_2d_array",
46    "texture_depth_cube",
47    "texture_depth_cube_array",
48    "texture_depth_multisampled_2d",
49    "u32",
50    "u64",
51    "vec2",
52    "vec3",
53    "vec4",
54    // Other Keywords
55    "alias",
56    "bitcast",
57    "break",
58    "case",
59    "const",
60    "continue",
61    "continuing",
62    "default",
63    "discard",
64    "else",
65    "enable",
66    "false",
67    "fn",
68    "for",
69    "if",
70    "let",
71    "loop",
72    "override",
73    "return",
74    "static_assert",
75    "struct",
76    "switch",
77    "true",
78    "type",
79    "var",
80    "while",
81    // Reserved Words
82    "CompileShader",
83    "ComputeShader",
84    "DomainShader",
85    "GeometryShader",
86    "Hullshader",
87    "NULL",
88    "Self",
89    "abstract",
90    "active",
91    "alignas",
92    "alignof",
93    "as",
94    "asm",
95    "asm_fragment",
96    "async",
97    "attribute",
98    "auto",
99    "await",
100    "become",
101    "binding_array",
102    "cast",
103    "catch",
104    "class",
105    "co_await",
106    "co_return",
107    "co_yield",
108    "coherent",
109    "column_major",
110    "common",
111    "compile",
112    "compile_fragment",
113    "concept",
114    "const_cast",
115    "consteval",
116    "constexpr",
117    "constinit",
118    "crate",
119    "debugger",
120    "decltype",
121    "delete",
122    "demote",
123    "demote_to_helper",
124    "do",
125    "dynamic_cast",
126    "enum",
127    "explicit",
128    "export",
129    "extends",
130    "extern",
131    "external",
132    "fallthrough",
133    "filter",
134    "final",
135    "finally",
136    "friend",
137    "from",
138    "fxgroup",
139    "get",
140    "goto",
141    "groupshared",
142    "handle",
143    "highp",
144    "impl",
145    "implements",
146    "import",
147    "inline",
148    "inout",
149    "instanceof",
150    "interface",
151    "layout",
152    "lowp",
153    "macro",
154    "macro_rules",
155    "match",
156    "mediump",
157    "meta",
158    "mod",
159    "module",
160    "move",
161    "mut",
162    "mutable",
163    "namespace",
164    "new",
165    "nil",
166    "noexcept",
167    "noinline",
168    "nointerpolation",
169    "noperspective",
170    "null",
171    "nullptr",
172    "of",
173    "operator",
174    "package",
175    "packoffset",
176    "partition",
177    "pass",
178    "patch",
179    "pixelfragment",
180    "precise",
181    "precision",
182    "premerge",
183    "priv",
184    "protected",
185    "pub",
186    "public",
187    "readonly",
188    "ref",
189    "regardless",
190    "register",
191    "reinterpret_cast",
192    "requires",
193    "resource",
194    "restrict",
195    "self",
196    "set",
197    "shared",
198    "signed",
199    "sizeof",
200    "smooth",
201    "snorm",
202    "static",
203    "static_assert",
204    "static_cast",
205    "std",
206    "subroutine",
207    "super",
208    "target",
209    "template",
210    "this",
211    "thread_local",
212    "throw",
213    "trait",
214    "try",
215    "typedef",
216    "typeid",
217    "typename",
218    "typeof",
219    "union",
220    "unless",
221    "unorm",
222    "unsafe",
223    "unsized",
224    "use",
225    "using",
226    "varying",
227    "virtual",
228    "volatile",
229    "wgsl",
230    "where",
231    "with",
232    "writeonly",
233    "yield",
234];
235
236/// The above set of reserved keywords, turned into a cached HashSet. This saves
237/// significant time during [`Namer::reset`](crate::proc::Namer::reset).
238///
239/// See <https://github.com/gfx-rs/wgpu/pull/7338> for benchmarks.
240pub static RESERVED_SET: RacyLock<KeywordSet> = RacyLock::new(|| KeywordSet::from_iter(RESERVED));