blob: 124fc8c7cc2cf779b13ce616bcb2678667c844e5 [file] [log] [blame]
// Copyright 2022 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/resolver/type_alias.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/resolver/type_alias.h"
namespace tint::resolver {
/// ParseTypeAlias parses a TypeAlias from a string.
/// @param str the string to parse
/// @returns the parsed enum, or TypeAlias::kUndefined if the string could not be parsed.
TypeAlias ParseTypeAlias(std::string_view str) {
if (str == "vec2f") {
return TypeAlias::kVec2F;
}
if (str == "vec2h") {
return TypeAlias::kVec2H;
}
if (str == "vec2i") {
return TypeAlias::kVec2I;
}
if (str == "vec2u") {
return TypeAlias::kVec2U;
}
if (str == "vec3f") {
return TypeAlias::kVec3F;
}
if (str == "vec3h") {
return TypeAlias::kVec3H;
}
if (str == "vec3i") {
return TypeAlias::kVec3I;
}
if (str == "vec3u") {
return TypeAlias::kVec3U;
}
if (str == "vec4f") {
return TypeAlias::kVec4F;
}
if (str == "vec4h") {
return TypeAlias::kVec4H;
}
if (str == "vec4i") {
return TypeAlias::kVec4I;
}
if (str == "vec4u") {
return TypeAlias::kVec4U;
}
return TypeAlias::kUndefined;
}
std::ostream& operator<<(std::ostream& out, TypeAlias value) {
switch (value) {
case TypeAlias::kUndefined:
return out << "undefined";
case TypeAlias::kVec2F:
return out << "vec2f";
case TypeAlias::kVec2H:
return out << "vec2h";
case TypeAlias::kVec2I:
return out << "vec2i";
case TypeAlias::kVec2U:
return out << "vec2u";
case TypeAlias::kVec3F:
return out << "vec3f";
case TypeAlias::kVec3H:
return out << "vec3h";
case TypeAlias::kVec3I:
return out << "vec3i";
case TypeAlias::kVec3U:
return out << "vec3u";
case TypeAlias::kVec4F:
return out << "vec4f";
case TypeAlias::kVec4H:
return out << "vec4h";
case TypeAlias::kVec4I:
return out << "vec4i";
case TypeAlias::kVec4U:
return out << "vec4u";
}
return out << "<unknown>";
}
} // namespace tint::resolver