tint: Rename kNotAnExtenxion to kNoExtension

This patch rename `ast::Enable::ExtensionKind::kNotAnExtenxion`
to `ast::Enable::ExtensionKind::kNoExtension`.

Change-Id: I28087d548cc8edf249545d51414a1becfa5a3b65
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90162
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
This commit is contained in:
Zhaoming Jiang 2022-05-13 08:54:47 +00:00 committed by Dawn LUCI CQ
parent ab9757036b
commit ed6ff9c948
7 changed files with 23 additions and 21 deletions

View File

@ -34,7 +34,7 @@ Enable::ExtensionKind Enable::NameToKind(const std::string& name) {
return Enable::ExtensionKind::kInternalExtensionForTesting;
}
return Enable::ExtensionKind::kNotAnExtension;
return Enable::ExtensionKind::kNoExtension;
}
std::string Enable::KindToName(ExtensionKind kind) {
@ -47,8 +47,8 @@ std::string Enable::KindToName(ExtensionKind kind) {
// The reserved internal extension for testing
case ExtensionKind::kInternalExtensionForTesting:
return "InternalExtensionForTesting";
case ExtensionKind::kNotAnExtension:
// Return an empty string for kNotAnExtension
case ExtensionKind::kNoExtension:
// Return an empty string for kNoExtension
return {};
// No default case, as this switch must cover all ExtensionKind values.
}

View File

@ -32,6 +32,10 @@ class Enable : public Castable<Enable, Node> {
public:
/// The enum class identifing each supported WGSL extension
enum class ExtensionKind {
/// An internal reserved extension for test, named
/// "InternalExtensionForTesting".
kInternalExtensionForTesting,
/// An extension for the experimental feature
/// "chromium_experimental_dp4a".
/// See crbug.com/tint/1497 for more details
@ -39,28 +43,26 @@ class Enable : public Castable<Enable, Node> {
/// A Chromium-specific extension for disabling uniformity analysis.
kChromiumDisableUniformityAnalysis,
/// An internal reserved extension for test, named
/// "InternalExtensionForTesting"
kInternalExtensionForTesting = -2,
kNotAnExtension = -1,
/// Reserved for representing "No extension required" or "Not a valid extension".
kNoExtension,
};
/// Convert a string of extension name into one of ExtensionKind enum value,
/// the result will be ExtensionKind::kNotAnExtension if the name is not a
/// known extension name. A extension node of kind kNotAnExtension must not
/// the result will be ExtensionKind::kNoExtension if the name is not a
/// known extension name. A extension node of kind kNoExtension must not
/// exist in the AST tree, and using a unknown extension name in WGSL code
/// should result in a shader-creation error.
/// @param name string of the extension name
/// @return the ExtensionKind enum value for the extension of given name, or
/// kNotAnExtension if no known extension has the given name
/// kNoExtension if no known extension has the given name
static ExtensionKind NameToKind(const std::string& name);
/// Convert the ExtensionKind enum value to corresponding extension name
/// string. If the given enum value is kNotAnExtension or don't have a known
/// string. If the given enum value is kNoExtension or don't have a known
/// name, return an empty string instead.
/// @param kind the ExtensionKind enum value
/// @return string of the extension name corresponding to the given kind, or
/// an empty string if the given enum value is kNotAnExtension or don't have a
/// an empty string if the given enum value is kNoExtension or don't have a
/// known corresponding name
static std::string KindToName(ExtensionKind kind);

View File

@ -39,20 +39,20 @@ TEST_F(AstExtensionTest, Creation_InvalidName) {
EXPECT_EQ(ext->source.range.begin.column, 2u);
EXPECT_EQ(ext->source.range.end.line, 20u);
EXPECT_EQ(ext->source.range.end.column, 5u);
EXPECT_EQ(ext->kind, ast::Enable::ExtensionKind::kNotAnExtension);
EXPECT_EQ(ext->kind, ast::Enable::ExtensionKind::kNoExtension);
}
TEST_F(AstExtensionTest, NameToKind_InvalidName) {
EXPECT_EQ(ast::Enable::NameToKind(std::string()), ast::Enable::ExtensionKind::kNotAnExtension);
EXPECT_EQ(ast::Enable::NameToKind(std::string()), ast::Enable::ExtensionKind::kNoExtension);
EXPECT_EQ(ast::Enable::NameToKind("__ImpossibleExtensionName"),
ast::Enable::ExtensionKind::kNotAnExtension);
EXPECT_EQ(ast::Enable::NameToKind("123"), ast::Enable::ExtensionKind::kNotAnExtension);
ast::Enable::ExtensionKind::kNoExtension);
EXPECT_EQ(ast::Enable::NameToKind("123"), ast::Enable::ExtensionKind::kNoExtension);
}
TEST_F(AstExtensionTest, KindToName) {
EXPECT_EQ(ast::Enable::KindToName(ast::Enable::ExtensionKind::kInternalExtensionForTesting),
"InternalExtensionForTesting");
EXPECT_EQ(ast::Enable::KindToName(ast::Enable::ExtensionKind::kNotAnExtension), std::string());
EXPECT_EQ(ast::Enable::KindToName(ast::Enable::ExtensionKind::kNoExtension), std::string());
}
} // namespace

View File

@ -358,7 +358,7 @@ Maybe<bool> ParserImpl::enable_directive() {
return Failure::kErrored;
}
if (ast::Enable::NameToKind(name.value) != ast::Enable::ExtensionKind::kNotAnExtension) {
if (ast::Enable::NameToKind(name.value) != ast::Enable::ExtensionKind::kNoExtension) {
const ast::Enable* extension = create<ast::Enable>(name.source, name.value);
builder_.AST().AddEnable(extension);
} else {

View File

@ -1525,7 +1525,7 @@ bool Validator::RequiredExtensionForBuiltinFunction(const sem::Call* call,
}
const auto extension = builtin->RequiredExtension();
if (extension == ast::Enable::ExtensionKind::kNotAnExtension) {
if (extension == ast::Enable::ExtensionKind::kNoExtension) {
return true;
}

View File

@ -157,7 +157,7 @@ ast::Enable::ExtensionKind Builtin::RequiredExtension() const {
if (IsDP4a()) {
return ast::Enable::ExtensionKind::kChromiumExperimentalDP4a;
}
return ast::Enable::ExtensionKind::kNotAnExtension;
return ast::Enable::ExtensionKind::kNoExtension;
}
} // namespace tint::sem

View File

@ -144,7 +144,7 @@ class Builtin final : public Castable<Builtin, CallTarget> {
bool HasSideEffects() const;
/// @returns the required extension of this builtin function. Returns
/// ast::Enable::ExtensionKind::kNotAnExtension if no extension is required.
/// ast::Enable::ExtensionKind::kNoExtension if no extension is required.
ast::Enable::ExtensionKind RequiredExtension() const;
private: