| {{- /* |
| -------------------------------------------------------------------------------- |
| 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(const std::string& 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 |