tint/type: Rename ShortName to type::Builtin

These will include the builtin language types.

Bug: tint:1810
Change-Id: I695a9ee833e1035eb1d17913d709038ae4c561d8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118502
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2023-02-07 13:35:58 +00:00
committed by Dawn LUCI CQ
parent a5ea0a1450
commit ad73301856
21 changed files with 353 additions and 318 deletions

View File

@@ -40,10 +40,13 @@ func Run(tmpl string, w io.Writer, funcs Functions) error {
template: template.New("<template>"),
}
globals := newMap()
// Add a bunch of generic useful functions
g.funcs = Functions{
"Contains": strings.Contains,
"Eval": g.eval,
"Globals": func() Map { return globals },
"HasPrefix": strings.HasPrefix,
"HasSuffix": strings.HasSuffix,
"Import": g.importTmpl,
@@ -128,9 +131,13 @@ func (g *generator) importTmpl(path string) (string, error) {
if err != nil {
return "", fmt.Errorf("failed to open '%v': %w", path, err)
}
if err := g.bindAndParse(g.template.New(""), string(data)); err != nil {
t := g.template.New("")
if err := g.bindAndParse(t, string(data)); err != nil {
return "", fmt.Errorf("failed to parse '%v': %w", path, err)
}
if err := t.Execute(ioutil.Discard, nil); err != nil {
return "", fmt.Errorf("failed to execute '%v': %w", path, err)
}
return "", nil
}