tint/ast: Clean up StorageClass enum

Remove unused enum entries.
Add a ParseStorageClass() function. Have the WGSL parser use this.

First step to standardizing the way we parse enum-backed token sets.

Change-Id: I31c02816493beeabda740ff43946edce097f5fd1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97148
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2022-07-26 22:51:36 +00:00
committed by Dawn LUCI CQ
parent ce8876074f
commit 48085845bd
24 changed files with 150 additions and 132 deletions

View File

@@ -15,6 +15,7 @@
#ifndef SRC_TINT_UTILS_STRING_H_
#define SRC_TINT_UTILS_STRING_H_
#include <sstream>
#include <string>
namespace tint::utils {
@@ -34,6 +35,15 @@ inline std::string ReplaceAll(std::string str,
return str;
}
/// @param value the value to be printed as a string
/// @returns value printed as a string via the std::ostream `<<` operator
template <typename T>
std::string ToString(const T& value) {
std::stringstream s;
s << value;
return s.str();
}
} // namespace tint::utils
#endif // SRC_TINT_UTILS_STRING_H_

View File

@@ -32,5 +32,10 @@ TEST(StringTest, ReplaceAll) {
ASSERT_EQ("aabxybbxybcc", ReplaceAll("aabbcc", "b", "bxyb"));
}
TEST(StringTest, ToString) {
ASSERT_EQ("123", ToString(123));
ASSERT_EQ("hello", ToString("hello"));
}
} // namespace
} // namespace tint::utils