mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/typecheck: add selector helpers
This CL refactors common patterns for constructing field and method selector expressions. Notably, XDotField and XDotMethod are now the only two functions where a SelecterExpr with OXDOT is constructed. Change-Id: I4c087225d8b295c4a6a92281ffcbcabafe2dc94d Reviewed-on: https://go-review.googlesource.com/c/go/+/520979 Auto-Submit: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
3761e3fbfd
commit
9ac6b00e79
8 changed files with 79 additions and 54 deletions
|
|
@ -203,8 +203,7 @@ func hashFunc(t *types.Type) *ir.Func {
|
|||
if !compare.IsRegularMemory(f.Type) {
|
||||
hashel := hashfor(f.Type)
|
||||
call := ir.NewCallExpr(base.Pos, ir.OCALL, hashel, nil)
|
||||
nx := ir.NewSelectorExpr(base.Pos, ir.OXDOT, np, f.Sym) // TODO: fields from other packages?
|
||||
na := typecheck.NodAddr(nx)
|
||||
na := typecheck.NodAddr(typecheck.DotField(base.Pos, np, i))
|
||||
call.Args.Append(na)
|
||||
call.Args.Append(nh)
|
||||
fn.Body.Append(ir.NewAssignStmt(base.Pos, nh, call))
|
||||
|
|
@ -218,8 +217,7 @@ func hashFunc(t *types.Type) *ir.Func {
|
|||
// h = hashel(&p.first, size, h)
|
||||
hashel := hashmem(f.Type)
|
||||
call := ir.NewCallExpr(base.Pos, ir.OCALL, hashel, nil)
|
||||
nx := ir.NewSelectorExpr(base.Pos, ir.OXDOT, np, f.Sym) // TODO: fields from other packages?
|
||||
na := typecheck.NodAddr(nx)
|
||||
na := typecheck.NodAddr(typecheck.DotField(base.Pos, np, i))
|
||||
call.Args.Append(na)
|
||||
call.Args.Append(nh)
|
||||
call.Args.Append(ir.NewInt(base.Pos, size))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue