aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2020-12-29 03:08:23 -0800
committerMatthew Dempsky <mdempsky@google.com>2020-12-29 11:54:34 +0000
commit9ea272e5ec5dd5eadd59d54c08377d5d9527a51b (patch)
tree6ab3da803e9512450333a86738a5b98246bb70b9 /src/cmd/compile/internal/typecheck
parente40cb4d4ae357d80d5e2b66e765c937317fad07f (diff)
downloadgo-9ea272e5ec5dd5eadd59d54c08377d5d9527a51b.tar.gz
go-9ea272e5ec5dd5eadd59d54c08377d5d9527a51b.zip
[dev.regabi] cmd/compile: simplify ir.Func somewhat
Two simplifications: 1. Statements (including ODCLFUNC) don't have types, and the Func.Nname already has a type. There's no need for a second one. However, there is a lot of code that expects to be able to call Func.Type, so leave a forwarding method, like with Sym and Linksym. 2. Inline and remove ir.NewFuncNameAt. It doesn't really save any code, and it's only used a handful of places. Passes toolstash -cmp. Change-Id: I51acaa341897dae0fcdf2fa576a10174a2ae4d1e Reviewed-on: https://go-review.googlesource.com/c/go/+/280648 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')
-rw-r--r--src/cmd/compile/internal/typecheck/dcl.go3
-rw-r--r--src/cmd/compile/internal/typecheck/export.go8
-rw-r--r--src/cmd/compile/internal/typecheck/func.go1
-rw-r--r--src/cmd/compile/internal/typecheck/iimport.go11
4 files changed, 10 insertions, 13 deletions
diff --git a/src/cmd/compile/internal/typecheck/dcl.go b/src/cmd/compile/internal/typecheck/dcl.go
index 83f926e135..c4f32ff59d 100644
--- a/src/cmd/compile/internal/typecheck/dcl.go
+++ b/src/cmd/compile/internal/typecheck/dcl.go
@@ -23,7 +23,8 @@ func DeclFunc(sym *types.Sym, tfn ir.Ntype) *ir.Func {
}
fn := ir.NewFunc(base.Pos)
- fn.Nname = ir.NewFuncNameAt(base.Pos, sym, fn)
+ fn.Nname = ir.NewNameAt(base.Pos, sym)
+ fn.Nname.Func = fn
fn.Nname.Defn = fn
fn.Nname.Ntype = tfn
ir.MarkFunc(fn.Nname)
diff --git a/src/cmd/compile/internal/typecheck/export.go b/src/cmd/compile/internal/typecheck/export.go
index 03deff8174..c525391401 100644
--- a/src/cmd/compile/internal/typecheck/export.go
+++ b/src/cmd/compile/internal/typecheck/export.go
@@ -31,12 +31,8 @@ func importconst(ipkg *types.Pkg, pos src.XPos, s *types.Sym, t *types.Type, val
// ipkg is the package being imported
func importfunc(ipkg *types.Pkg, pos src.XPos, s *types.Sym, t *types.Type) *ir.Name {
n := importobj(ipkg, pos, s, ir.ONAME, ir.PFUNC, t)
-
- fn := ir.NewFunc(pos)
- fn.SetType(t)
- n.SetFunc(fn)
- fn.Nname = n
-
+ n.Func = ir.NewFunc(pos)
+ n.Func.Nname = n
return n
}
diff --git a/src/cmd/compile/internal/typecheck/func.go b/src/cmd/compile/internal/typecheck/func.go
index 9bb9245d4a..060024951e 100644
--- a/src/cmd/compile/internal/typecheck/func.go
+++ b/src/cmd/compile/internal/typecheck/func.go
@@ -409,7 +409,6 @@ func tcFunc(n *ir.Func) {
if t == nil {
return
}
- n.SetType(t)
rcvr := t.Recv()
if rcvr != nil && n.Shortname != nil {
m := addmethod(n, n.Shortname, t, true, n.Pragma&ir.Nointerface != 0)
diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go
index 86277e69bd..00ecd9b819 100644
--- a/src/cmd/compile/internal/typecheck/iimport.go
+++ b/src/cmd/compile/internal/typecheck/iimport.go
@@ -331,12 +331,13 @@ func (r *importReader) doDecl(sym *types.Sym) *ir.Name {
recv := r.param()
mtyp := r.signature(recv)
- fn := ir.NewFunc(mpos)
- fn.SetType(mtyp)
- m := ir.NewFuncNameAt(mpos, ir.MethodSym(recv.Type, msym), fn)
- m.SetType(mtyp)
- m.Class_ = ir.PFUNC
// methodSym already marked m.Sym as a function.
+ m := ir.NewNameAt(mpos, ir.MethodSym(recv.Type, msym))
+ m.Class_ = ir.PFUNC
+ m.SetType(mtyp)
+
+ m.Func = ir.NewFunc(mpos)
+ m.Func.Nname = m
f := types.NewField(mpos, msym, mtyp)
f.Nname = m