blob: 791248248ee6237375da3c60ba628aa94770c055 [file] [log] [blame] [edit]
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate function.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/builtin/function.h"
namespace tint::builtin {
Function ParseFunction(std::string_view name) {
{{- range Sem.Builtins }}
if (name == "{{.Name}}") {
return Function::k{{PascalCase .Name}};
}
{{- end }}
return Function::kNone;
}
const char* str(Function i) {
switch (i) {
case Function::kNone:
return "<none>";
{{- range Sem.Builtins }}
case Function::k{{PascalCase .Name}}:
return "{{.Name}}";
{{- end }}
}
return "<unknown>";
}
utils::StringStream& operator<<(utils::StringStream& out, Function i) {
out << str(i);
return out;
}
} // namespace tint::builtin