mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: make generated function code more consistent
There are a bunch of places where we generate functions: equality and hash functions; method expression and promoted method wrappers; and print/delete wrappers for defer/go statements. This CL brings them in sync by: 1) Always using dclfunc and funcbody. Most were already using this, but makepartialcall needed some changes. 2) Removing duplicate types.Markdcl/types.Popdcl calls. These are already handled by dclfunc and funcbody. 3) Using structargs (already used by genwrapper) to construct new param/result lists from existing types. 4) Always accessing the parameter ONAME nodes through Field.Nname instead of poking into the ODCLFIELD. Also, since creating a slice of the entire parameter list is common, extract this out into a paramNnames helper function. 5) Add a Type.IsVariadic method to simplify identifying variadic function types. Passes toolstash-check -gcflags=-dwarf=false. DWARF output changes because using structargs in makepartialcall changes the generated parameter names. Change-Id: I6661d3699afdbe7852ad60db5a4ec6eeb2b696e4 Reviewed-on: https://go-review.googlesource.com/108216 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
60e3ebb9cb
commit
25824c96dc
6 changed files with 76 additions and 115 deletions
|
|
@ -3861,12 +3861,9 @@ func wrapCall(n *Node, init *Nodes) *Node {
|
|||
}
|
||||
|
||||
t := nod(OTFUNC, nil, nil)
|
||||
var args []*Node
|
||||
for i, arg := range n.List.Slice() {
|
||||
buf := fmt.Sprintf("a%d", i)
|
||||
a := namedfield(buf, arg.Type)
|
||||
t.List.Append(a)
|
||||
args = append(args, a.Left)
|
||||
s := lookupN("a", i)
|
||||
t.List.Append(symfield(s, arg.Type))
|
||||
}
|
||||
|
||||
wrapCall_prgen++
|
||||
|
|
@ -3874,7 +3871,7 @@ func wrapCall(n *Node, init *Nodes) *Node {
|
|||
fn := dclfunc(sym, t)
|
||||
|
||||
a := nod(n.Op, nil, nil)
|
||||
a.List.Set(args)
|
||||
a.List.Set(paramNnames(t.Type))
|
||||
a = typecheck(a, Etop)
|
||||
fn.Nbody.Set1(a)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue