From: Matthew Dempsky Date: Wed, 23 Dec 2020 08:36:34 +0000 (-0800) Subject: [dev.regabi] cmd/compile: update mkbuiltin.go and re-enable TestBuiltin X-Git-Tag: go1.17beta1~1539^2~239 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=63c96c2ee7444b83224b9c5aadd8ad5b757c1e03;p=gostls13.git [dev.regabi] cmd/compile: update mkbuiltin.go and re-enable TestBuiltin Update's mkbuiltin.go to match builtin.go after the recent rf rewrites. Change-Id: I80cf5d7c27b36fe28553406819cb4263de84e5ed Reviewed-on: https://go-review.googlesource.com/c/go/+/279952 Trust: Matthew Dempsky Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Cuong Manh Le --- diff --git a/src/cmd/compile/internal/typecheck/builtin_test.go b/src/cmd/compile/internal/typecheck/builtin_test.go index cc8d49730a..fb9d3e393f 100644 --- a/src/cmd/compile/internal/typecheck/builtin_test.go +++ b/src/cmd/compile/internal/typecheck/builtin_test.go @@ -13,7 +13,6 @@ import ( ) func TestBuiltin(t *testing.T) { - t.Skip("mkbuiltin needs fixing") testenv.MustHaveGoRun(t) t.Parallel() diff --git a/src/cmd/compile/internal/typecheck/mkbuiltin.go b/src/cmd/compile/internal/typecheck/mkbuiltin.go index 2a208d960f..27dbf1f10e 100644 --- a/src/cmd/compile/internal/typecheck/mkbuiltin.go +++ b/src/cmd/compile/internal/typecheck/mkbuiltin.go @@ -36,6 +36,7 @@ func main() { fmt.Fprintln(&b, "package typecheck") fmt.Fprintln(&b) fmt.Fprintln(&b, `import (`) + fmt.Fprintln(&b, ` "cmd/compile/internal/base"`) fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) fmt.Fprintln(&b, `)`) @@ -169,7 +170,7 @@ func (i *typeInterner) mktype(t ast.Expr) string { } return fmt.Sprintf("types.NewChan(%s, %s)", i.subtype(t.Value), dir) case *ast.FuncType: - return fmt.Sprintf("functype(nil, %s, %s)", i.fields(t.Params, false), i.fields(t.Results, false)) + return fmt.Sprintf("NewFuncType(nil, %s, %s)", i.fields(t.Params, false), i.fields(t.Results, false)) case *ast.InterfaceType: if len(t.Methods.List) != 0 { log.Fatal("non-empty interfaces unsupported") @@ -180,7 +181,7 @@ func (i *typeInterner) mktype(t ast.Expr) string { case *ast.StarExpr: return fmt.Sprintf("types.NewPtr(%s)", i.subtype(t.X)) case *ast.StructType: - return fmt.Sprintf("tostruct(%s)", i.fields(t.Fields, true)) + return fmt.Sprintf("NewStructType(%s)", i.fields(t.Fields, true)) default: log.Fatalf("unhandled type: %#v", t) @@ -196,13 +197,13 @@ func (i *typeInterner) fields(fl *ast.FieldList, keepNames bool) string { for _, f := range fl.List { typ := i.subtype(f.Type) if len(f.Names) == 0 { - res = append(res, fmt.Sprintf("anonfield(%s)", typ)) + res = append(res, fmt.Sprintf("ir.NewField(base.Pos, nil, nil, %s)", typ)) } else { for _, name := range f.Names { if keepNames { - res = append(res, fmt.Sprintf("namedfield(%q, %s)", name.Name, typ)) + res = append(res, fmt.Sprintf("ir.NewField(base.Pos, Lookup(%q), nil, %s)", name.Name, typ)) } else { - res = append(res, fmt.Sprintf("anonfield(%s)", typ)) + res = append(res, fmt.Sprintf("ir.NewField(base.Pos, nil, nil, %s)", typ)) } } }