mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.regabi] cmd/compile: rename ir.Find to ir.Any and update uses
ir.Find is called "any" in C#, Dart, Haskell, Python, R, Ruby, and Rust, and "any_of" in C++, "anyMatch" in Java, "some" in JavaScript, "exists in OCaml, and "existsb" in Coq. (Thanks to Matthew Dempsky for the research.) This CL changes Find to Any to use the mostly standard name. It also updates wrapper helpers to use the any terminology: hasCall -> anyCall hasCallOrChan -> anyCallOrChan hasSideEffects -> anySideEffects Unchanged are "hasNamedResults", "hasUniquePos", and "hasDefaultCase", which are all about a single node, not any node in the IR tree. I also renamed hasFall to endsInFallthrough, since its semantics are neither that of "any" nor that of the remaining "has" functions. So the new terminology helps separate different kinds of predicates nicely. Change-Id: I9bb3c9ebf060a30447224be09a5c34ad5244ea0d Reviewed-on: https://go-review.googlesource.com/c/go/+/278912 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
aeedc9f804
commit
0b9cb63b8d
7 changed files with 37 additions and 37 deletions
|
|
@ -302,7 +302,7 @@ func walkExprSwitch(sw *ir.SwitchStmt) {
|
|||
// Process body.
|
||||
body.Append(npos(ncase.Pos(), nodSym(ir.OLABEL, nil, label)))
|
||||
body.Append(ncase.Body().Slice()...)
|
||||
if fall, pos := hasFall(ncase.Body().Slice()); !fall {
|
||||
if fall, pos := endsInFallthrough(ncase.Body().Slice()); !fall {
|
||||
br := ir.Nod(ir.OBREAK, nil, nil)
|
||||
br.SetPos(pos)
|
||||
body.Append(br)
|
||||
|
|
@ -481,8 +481,8 @@ func allCaseExprsAreSideEffectFree(sw *ir.SwitchStmt) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// hasFall reports whether stmts ends with a "fallthrough" statement.
|
||||
func hasFall(stmts []ir.Node) (bool, src.XPos) {
|
||||
// endsInFallthrough reports whether stmts ends with a "fallthrough" statement.
|
||||
func endsInFallthrough(stmts []ir.Node) (bool, src.XPos) {
|
||||
// Search backwards for the index of the fallthrough
|
||||
// statement. Do not assume it'll be in the last
|
||||
// position, since in some cases (e.g. when the statement
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue