diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2022-05-03 15:29:43 -0700 |
|---|---|---|
| committer | Matthew Dempsky <mdempsky@google.com> | 2022-05-05 18:49:17 +0000 |
| commit | 5073c1c7407ad5f23e54cc0a6410ffbde23758bb (patch) | |
| tree | 8571f2ea5e0535c731042d19132ea5a2eb73f17b /src/cmd/compile/internal/reflectdata/alg.go | |
| parent | cce00643992995ce3ca4eca301bac77a72e10d8e (diff) | |
| download | go-5073c1c7407ad5f23e54cc0a6410ffbde23758bb.tar.xz | |
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>
Diffstat (limited to 'src/cmd/compile/internal/reflectdata/alg.go')
| -rw-r--r-- | src/cmd/compile/internal/reflectdata/alg.go | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/cmd/compile/internal/reflectdata/alg.go b/src/cmd/compile/internal/reflectdata/alg.go index 0ed3eb2875..8f0c4e8bc3 100644 --- a/src/cmd/compile/internal/reflectdata/alg.go +++ b/src/cmd/compile/internal/reflectdata/alg.go @@ -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") |
