mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[mtl] move keywords into a separate file
This commit is contained in:
committed by
Dzmitry Malyshau
parent
0f7b6e3e76
commit
fa36ef194c
100
src/back/msl/keywords.rs
Normal file
100
src/back/msl/keywords.rs
Normal file
@@ -0,0 +1,100 @@
|
||||
//TODO: find a complete list
|
||||
pub const RESERVED: &[&str] = &[
|
||||
// control flow
|
||||
"break",
|
||||
"if",
|
||||
"else",
|
||||
"continue",
|
||||
"goto",
|
||||
"do",
|
||||
"while",
|
||||
"for",
|
||||
"switch",
|
||||
"case",
|
||||
// types and values
|
||||
"void",
|
||||
"unsigned",
|
||||
"signed",
|
||||
"bool",
|
||||
"char",
|
||||
"int",
|
||||
"long",
|
||||
"float",
|
||||
"double",
|
||||
"char8_t",
|
||||
"wchar_t",
|
||||
"true",
|
||||
"false",
|
||||
"nullptr",
|
||||
"union",
|
||||
"class",
|
||||
"struct",
|
||||
"enum",
|
||||
// other
|
||||
"main",
|
||||
"decltype",
|
||||
"sizeof",
|
||||
"typeof",
|
||||
"typedef",
|
||||
"explicit",
|
||||
"export",
|
||||
"friend",
|
||||
"namespace",
|
||||
"operator",
|
||||
"public",
|
||||
"template",
|
||||
"typename",
|
||||
"typeid",
|
||||
"co_await",
|
||||
"co_return",
|
||||
"co_yield",
|
||||
"module",
|
||||
"import",
|
||||
"ray_data",
|
||||
"vec_step",
|
||||
"visible",
|
||||
"as_type",
|
||||
// qualifiers
|
||||
"mutable",
|
||||
"static",
|
||||
"volatile",
|
||||
"restrict",
|
||||
"const",
|
||||
"non-temporal",
|
||||
"dereferenceable",
|
||||
"invariant",
|
||||
// exceptions
|
||||
"throw",
|
||||
"try",
|
||||
"catch",
|
||||
// operators
|
||||
"const_cast",
|
||||
"dynamic_cast",
|
||||
"reinterpret_cast",
|
||||
"static_cast",
|
||||
"new",
|
||||
"delete",
|
||||
"and",
|
||||
"and_eq",
|
||||
"bitand",
|
||||
"bitor",
|
||||
"compl",
|
||||
"not",
|
||||
"not_eq",
|
||||
"or",
|
||||
"or_eq",
|
||||
"xor",
|
||||
"xor_eq",
|
||||
"compl",
|
||||
// Metal-specific
|
||||
"constant",
|
||||
"device",
|
||||
"threadgroup",
|
||||
"threadgroup_imageblock",
|
||||
"compute",
|
||||
"vertex",
|
||||
"fragment",
|
||||
"read_only",
|
||||
"write_only",
|
||||
"read_write",
|
||||
];
|
||||
@@ -25,106 +25,7 @@ use std::{
|
||||
string::FromUtf8Error,
|
||||
};
|
||||
|
||||
//TODO: find a complete list
|
||||
const RESERVED_WORDS: &[&str] = &[
|
||||
// control flow
|
||||
"break",
|
||||
"if",
|
||||
"else",
|
||||
"continue",
|
||||
"goto",
|
||||
"do",
|
||||
"while",
|
||||
"for",
|
||||
"switch",
|
||||
"case",
|
||||
// types and values
|
||||
"void",
|
||||
"unsigned",
|
||||
"signed",
|
||||
"bool",
|
||||
"char",
|
||||
"int",
|
||||
"long",
|
||||
"float",
|
||||
"double",
|
||||
"char8_t",
|
||||
"wchar_t",
|
||||
"true",
|
||||
"false",
|
||||
"nullptr",
|
||||
"union",
|
||||
"class",
|
||||
"struct",
|
||||
"enum",
|
||||
// other
|
||||
"main",
|
||||
"decltype",
|
||||
"sizeof",
|
||||
"typeof",
|
||||
"typedef",
|
||||
"explicit",
|
||||
"export",
|
||||
"friend",
|
||||
"namespace",
|
||||
"operator",
|
||||
"public",
|
||||
"template",
|
||||
"typename",
|
||||
"typeid",
|
||||
"co_await",
|
||||
"co_return",
|
||||
"co_yield",
|
||||
"module",
|
||||
"import",
|
||||
"ray_data",
|
||||
"vec_step",
|
||||
"visible",
|
||||
"as_type",
|
||||
// qualifiers
|
||||
"mutable",
|
||||
"static",
|
||||
"volatile",
|
||||
"restrict",
|
||||
"const",
|
||||
"non-temporal",
|
||||
"dereferenceable",
|
||||
"invariant",
|
||||
// exceptions
|
||||
"throw",
|
||||
"try",
|
||||
"catch",
|
||||
// operators
|
||||
"const_cast",
|
||||
"dynamic_cast",
|
||||
"reinterpret_cast",
|
||||
"static_cast",
|
||||
"new",
|
||||
"delete",
|
||||
"and",
|
||||
"and_eq",
|
||||
"bitand",
|
||||
"bitor",
|
||||
"compl",
|
||||
"not",
|
||||
"not_eq",
|
||||
"or",
|
||||
"or_eq",
|
||||
"xor",
|
||||
"xor_eq",
|
||||
"compl",
|
||||
// Metal-specific
|
||||
"constant",
|
||||
"device",
|
||||
"threadgroup",
|
||||
"threadgroup_imageblock",
|
||||
"compute",
|
||||
"vertex",
|
||||
"fragment",
|
||||
"read_only",
|
||||
"write_only",
|
||||
"read_write",
|
||||
];
|
||||
mod keywords;
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct BindTarget {
|
||||
@@ -856,7 +757,7 @@ impl<W: Write> Writer<W> {
|
||||
|
||||
pub fn write(&mut self, module: &crate::Module, options: &Options) -> Result<(), Error> {
|
||||
self.names.clear();
|
||||
Namer::process(module, RESERVED_WORDS, &mut self.names);
|
||||
Namer::process(module, keywords::RESERVED, &mut self.names);
|
||||
|
||||
writeln!(self.out, "#include <metal_stdlib>")?;
|
||||
writeln!(self.out, "#include <simd/simd.h>")?;
|
||||
|
||||
Reference in New Issue
Block a user