mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: add Node.IsMethod helper
Changes generated with eg:
func before(n *gc.Node) bool { return n.Type.Recv() != nil }
func after(n *gc.Node) bool { return n.IsMethod() }
func before(n *gc.Node) bool { return n.Type.Recv() == nil }
func after(n *gc.Node) bool { return !n.IsMethod() }
Change-Id: I28e544490d17bbdc06ab11ed32464af5802ab206
Reviewed-on: https://go-review.googlesource.com/28968
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
3bf141955b
commit
2e4dc86bfb
5 changed files with 12 additions and 6 deletions
|
|
@ -1038,6 +1038,12 @@ func Is64(t *Type) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// IsMethod reports whether n is a method.
|
||||
// n must be a function or a method.
|
||||
func (n *Node) IsMethod() bool {
|
||||
return n.Type.Recv() != nil
|
||||
}
|
||||
|
||||
// SliceBounds returns n's slice bounds: low, high, and max in expr[low:high:max].
|
||||
// n must be a slice expression. max is nil if n is a simple slice expression.
|
||||
func (n *Node) SliceBounds() (low, high, max *Node) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue