aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/mkbuiltin.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2020-12-23 00:50:18 -0800
committerMatthew Dempsky <mdempsky@google.com>2020-12-23 09:51:23 +0000
commit5898025026e3ec38451e86c7837f6faf3633cf27 (patch)
tree10bd4cdefce95d0ad6b260653d6b70f33226550d /src/cmd/compile/internal/typecheck/mkbuiltin.go
parent63c96c2ee7444b83224b9c5aadd8ad5b757c1e03 (diff)
downloadgo-5898025026e3ec38451e86c7837f6faf3633cf27.tar.gz
go-5898025026e3ec38451e86c7837f6faf3633cf27.zip
[dev.regabi] cmd/compile: update mkbuiltin.go to use new type constructors
We recently added new functions to types like NewSignature and NewField, so we can use these directly rather than depending on the typecheck and ir wrappers. Passes toolstash -cmp. Change-Id: I32676aa9a4ea71892216017756e72bcf90297219 Reviewed-on: https://go-review.googlesource.com/c/go/+/279953 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>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/mkbuiltin.go')
-rw-r--r--src/cmd/compile/internal/typecheck/mkbuiltin.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/cmd/compile/internal/typecheck/mkbuiltin.go b/src/cmd/compile/internal/typecheck/mkbuiltin.go
index 27dbf1f10e..07f4b767e8 100644
--- a/src/cmd/compile/internal/typecheck/mkbuiltin.go
+++ b/src/cmd/compile/internal/typecheck/mkbuiltin.go
@@ -36,9 +36,8 @@ 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, ` "cmd/internal/src"`)
fmt.Fprintln(&b, `)`)
mkbuiltin(&b, "runtime")
@@ -170,7 +169,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("NewFuncType(nil, %s, %s)", i.fields(t.Params, false), i.fields(t.Results, false))
+ return fmt.Sprintf("types.NewSignature(types.NoPkg, 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")
@@ -181,7 +180,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("NewStructType(%s)", i.fields(t.Fields, true))
+ return fmt.Sprintf("types.NewStruct(types.NoPkg, %s)", i.fields(t.Fields, true))
default:
log.Fatalf("unhandled type: %#v", t)
@@ -197,18 +196,18 @@ 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("ir.NewField(base.Pos, nil, nil, %s)", typ))
+ res = append(res, fmt.Sprintf("types.NewField(src.NoXPos, nil, %s)", typ))
} else {
for _, name := range f.Names {
if keepNames {
- res = append(res, fmt.Sprintf("ir.NewField(base.Pos, Lookup(%q), nil, %s)", name.Name, typ))
+ res = append(res, fmt.Sprintf("types.NewField(src.NoXPos, Lookup(%q), %s)", name.Name, typ))
} else {
- res = append(res, fmt.Sprintf("ir.NewField(base.Pos, nil, nil, %s)", typ))
+ res = append(res, fmt.Sprintf("types.NewField(src.NoXPos, nil, %s)", typ))
}
}
}
}
- return fmt.Sprintf("[]*ir.Field{%s}", strings.Join(res, ", "))
+ return fmt.Sprintf("[]*types.Field{%s}", strings.Join(res, ", "))
}
func intconst(e ast.Expr) int64 {