1
0
mirror of https://github.com/golang/go synced 2024-11-11 18:51:37 -07:00

[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 <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
Matthew Dempsky 2020-12-23 00:36:34 -08:00
parent 37f138df6b
commit 63c96c2ee7
2 changed files with 6 additions and 6 deletions

View File

@ -13,7 +13,6 @@ import (
)
func TestBuiltin(t *testing.T) {
t.Skip("mkbuiltin needs fixing")
testenv.MustHaveGoRun(t)
t.Parallel()

View File

@ -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))
}
}
}