mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.regabi] cmd/compile: change ir.DoChildren to use bool result type
After using the IR visitor code for a bit, it seems clear that a simple boolean result type is adequate for tree traversals. This CL updates ir.DoChildren to use the same calling convention as ir.Any, and updates mknode.go to generate code accordingly. There were only two places where the error-based DoChildren API was used within the compiler: 1. Within typechecking, marking statements that contain "break". This code never returns errors anyway, so it's trivially updated to return false instead. 2. Within inlining, the "hairy visitor" actually does make use of returning errors. However, it threads through a reference to the hairyVisitor anyway, where it would be trivial to store any needed information instead. For the purpose of this CL, we provide "errChildren" and "errList" helper functions that provide the previous error-based semantics on top of the new bool-based API. Passes toolstash -cmp. Change-Id: I4bac9a697b4dbfb5f66eeac37d4a2ced2073d7d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/280675 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
499851bac8
commit
f9b67f76a5
9 changed files with 481 additions and 613 deletions
|
|
@ -115,9 +115,9 @@ func NewFunc(pos src.XPos) *Func {
|
|||
|
||||
func (f *Func) isStmt() {}
|
||||
|
||||
func (n *Func) copy() Node { panic(n.no("copy")) }
|
||||
func (n *Func) doChildren(do func(Node) error) error { return doNodes(n.Body, do) }
|
||||
func (n *Func) editChildren(edit func(Node) Node) { editNodes(n.Body, edit) }
|
||||
func (n *Func) copy() Node { panic(n.no("copy")) }
|
||||
func (n *Func) doChildren(do func(Node) bool) bool { return doNodes(n.Body, do) }
|
||||
func (n *Func) editChildren(edit func(Node) Node) { editNodes(n.Body, edit) }
|
||||
|
||||
func (f *Func) Type() *types.Type { return f.Nname.Type() }
|
||||
func (f *Func) Sym() *types.Sym { return f.Nname.Sym() }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue