blob: 5737d8d05a7add66478747b6f871f4e5001d7805 [file] [log] [blame]
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate builtin_type.cc
To update the generated file, run:
./tools/run gen
See:
* tools/src/cmd/gen for structures used by this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
*/ -}}
#include "src/tint/sem/builtin_type.h"
#include <sstream>
namespace tint::sem {
BuiltinType ParseBuiltinType(const std::string& name) {
{{- range Sem.Builtins }}
if (name == "{{.Name}}") {
return BuiltinType::k{{Title .Name}};
}
{{- end }}
return BuiltinType::kNone;
}
const char* str(BuiltinType i) {
switch (i) {
case BuiltinType::kNone:
return "<none>";
{{- range Sem.Builtins }}
case BuiltinType::k{{Title .Name}}:
return "{{.Name}}";
{{- end }}
}
return "<unknown>";
}
std::ostream& operator<<(std::ostream& out, BuiltinType i) {
out << str(i);
return out;
}
} // namespace tint::sem