mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: construct ir.FuncType within typecheck.DeclFunc
Currently all typecheck.DeclFunc callers already construct a fresh new ir.FuncType, which is the last type expression kind that we represent in IR. This CL pushes all of the ir.FuncType construction down into typecheck.DeclFunc. The next CL will simplify the internals so that we can get rid of ir.FuncType altogether. Change-Id: I221ed324f157eb38bb57c8886609f53cc4fd99fe Reviewed-on: https://go-review.googlesource.com/c/go/+/403848 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
cce0064399
commit
5073c1c740
6 changed files with 33 additions and 47 deletions
|
|
@ -133,11 +133,10 @@ func genhash(t *types.Type) *obj.LSym {
|
|||
ir.NewField(base.Pos, typecheck.Lookup("h"), types.Types[types.TUINTPTR]),
|
||||
}
|
||||
results := []*ir.Field{ir.NewField(base.Pos, nil, types.Types[types.TUINTPTR])}
|
||||
tfn := ir.NewFuncType(base.Pos, nil, args, results)
|
||||
|
||||
fn := typecheck.DeclFunc(sym, tfn)
|
||||
np := ir.AsNode(tfn.Type().Params().Field(0).Nname)
|
||||
nh := ir.AsNode(tfn.Type().Params().Field(1).Nname)
|
||||
fn := typecheck.DeclFunc(sym, nil, args, results)
|
||||
np := ir.AsNode(fn.Type().Params().Field(0).Nname)
|
||||
nh := ir.AsNode(fn.Type().Params().Field(1).Nname)
|
||||
|
||||
switch t.Kind() {
|
||||
case types.TARRAY:
|
||||
|
|
@ -358,14 +357,13 @@ func geneq(t *types.Type) *obj.LSym {
|
|||
typecheck.DeclContext = ir.PEXTERN
|
||||
|
||||
// func sym(p, q *T) bool
|
||||
tfn := ir.NewFuncType(base.Pos, nil,
|
||||
fn := typecheck.DeclFunc(sym, nil,
|
||||
[]*ir.Field{ir.NewField(base.Pos, typecheck.Lookup("p"), types.NewPtr(t)), ir.NewField(base.Pos, typecheck.Lookup("q"), types.NewPtr(t))},
|
||||
[]*ir.Field{ir.NewField(base.Pos, typecheck.Lookup("r"), types.Types[types.TBOOL])})
|
||||
|
||||
fn := typecheck.DeclFunc(sym, tfn)
|
||||
np := ir.AsNode(tfn.Type().Params().Field(0).Nname)
|
||||
nq := ir.AsNode(tfn.Type().Params().Field(1).Nname)
|
||||
nr := ir.AsNode(tfn.Type().Results().Field(0).Nname)
|
||||
[]*ir.Field{ir.NewField(base.Pos, typecheck.Lookup("r"), types.Types[types.TBOOL])},
|
||||
)
|
||||
np := ir.AsNode(fn.Type().Params().Field(0).Nname)
|
||||
nq := ir.AsNode(fn.Type().Params().Field(1).Nname)
|
||||
nr := ir.AsNode(fn.Type().Results().Field(0).Nname)
|
||||
|
||||
// Label to jump to if an equality test fails.
|
||||
neq := typecheck.AutoLabel(".neq")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue