cmd/internal/obj: add Func type to replace "curfn any"

This adds a modicum of type safety to these APIs, which are otherwise
quite confusing to follow.

Change-Id: I268a9a1a99a47dcfef6dc1e9e5be13673af3fb85
Reviewed-on: https://go-review.googlesource.com/c/go/+/523396
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Matthew Dempsky 2023-08-28 05:43:51 -07:00 committed by Gopher Robot
parent 98c26afa8c
commit ad74bc4a92
4 changed files with 18 additions and 15 deletions

View file

@ -1001,6 +1001,11 @@ type RegSpill struct {
Spill, Unspill As
}
// A Func represents a Go function. If non-nil, it must be a *ir.Func.
type Func interface {
Pos() src.XPos
}
// Link holds the context for writing object code from a compiler
// to be linker input or for reading that input into the linker.
type Link struct {
@ -1030,7 +1035,7 @@ type Link struct {
Imports []goobj.ImportedPkg
DiagFunc func(string, ...interface{})
DiagFlush func()
DebugInfo func(fn *LSym, info *LSym, curfn interface{}) ([]dwarf.Scope, dwarf.InlCalls, src.XPos) // if non-nil, curfn is a *ir.Func
DebugInfo func(fn *LSym, info *LSym, curfn Func) ([]dwarf.Scope, dwarf.InlCalls)
GenAbstractFunc func(fn *LSym)
Errors int