cmd/compile: simplify various signature type handling code

Make more use of RecvParams and RecvParamsResults helper methods.

Also, correct misuse of Go spec terminology ("return" is a statement;
"result" is the class of parameters that appear in a function type).

Change-Id: I94807a747c494c9daa5441da7d9e3aea77aae33b
Reviewed-on: https://go-review.googlesource.com/c/go/+/521395
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Matthew Dempsky 2023-08-20 15:37:34 -07:00 committed by Gopher Robot
parent 3d15bfaa3e
commit c6dd97e533
5 changed files with 53 additions and 90 deletions

View file

@ -1027,22 +1027,14 @@ func writeType(t *types.Type) *obj.LSym {
ot = dextratype(lsym, ot, t, 0)
case types.TFUNC:
for _, t1 := range t.Recvs() {
writeType(t1.Type)
}
isddd := false
for _, t1 := range t.Params() {
isddd = t1.IsDDD()
writeType(t1.Type)
}
for _, t1 := range t.Results() {
for _, t1 := range t.RecvParamsResults() {
writeType(t1.Type)
}
ot = dcommontype(lsym, t)
inCount := t.NumRecvs() + t.NumParams()
outCount := t.NumResults()
if isddd {
if t.IsVariadic() {
outCount |= 1 << 15
}
ot = objw.Uint16(lsym, ot, uint16(inCount))
@ -1055,13 +1047,7 @@ func writeType(t *types.Type) *obj.LSym {
ot = dextratype(lsym, ot, t, dataAdd)
// Array of rtype pointers follows funcType.
for _, t1 := range t.Recvs() {
ot = objw.SymPtr(lsym, ot, writeType(t1.Type), 0)
}
for _, t1 := range t.Params() {
ot = objw.SymPtr(lsym, ot, writeType(t1.Type), 0)
}
for _, t1 := range t.Results() {
for _, t1 := range t.RecvParamsResults() {
ot = objw.SymPtr(lsym, ot, writeType(t1.Type), 0)
}