"cmd/internal/src"
)
-func Info(fnsym *obj.LSym, infosym *obj.LSym, curfn interface{}) (scopes []dwarf.Scope, inlcalls dwarf.InlCalls, startPos src.XPos) {
+func Info(fnsym *obj.LSym, infosym *obj.LSym, curfn obj.Func) (scopes []dwarf.Scope, inlcalls dwarf.InlCalls) {
fn := curfn.(*ir.Func)
if fn.Nname != nil {
if base.Flag.GenDwarfInl > 0 {
inlcalls = assembleInlines(fnsym, dwarfVars)
}
- return scopes, inlcalls, fn.Pos()
+ return scopes, inlcalls
}
func declPos(decl *ir.Name) src.XPos {
// populateDWARF fills in the DWARF Debugging Information Entries for
// TEXT symbol 's'. The various DWARF symbols must already have been
// initialized in InitTextSym.
-func (ctxt *Link) populateDWARF(curfn interface{}, s *LSym) {
+func (ctxt *Link) populateDWARF(curfn Func, s *LSym) {
myimportpath := ctxt.Pkgpath
if myimportpath == "" {
return
var scopes []dwarf.Scope
var inlcalls dwarf.InlCalls
if ctxt.DebugInfo != nil {
- // Don't need startPos because s.Func().StartLine is populated,
- // as s is in this package.
- scopes, inlcalls, _ = ctxt.DebugInfo(s, info, curfn)
+ scopes, inlcalls = ctxt.DebugInfo(s, info, curfn)
}
var err error
dwctxt := dwCtxt{ctxt}
dwarf.PutGlobal(dwCtxt{ctxt}, dieSym, typeSym, varSym, varname)
}
-func (ctxt *Link) DwarfAbstractFunc(curfn interface{}, s *LSym) {
+func (ctxt *Link) DwarfAbstractFunc(curfn Func, s *LSym) {
absfn := ctxt.DwFixups.AbsFuncDwarfSym(s)
if absfn.Size != 0 {
ctxt.Diag("internal error: DwarfAbstractFunc double process %v", s)
if s.Func() == nil {
s.NewFuncInfo()
}
- scopes, _, startPos := ctxt.DebugInfo(s, absfn, curfn)
- _, startLine := ctxt.getFileSymbolAndLine(startPos)
+ scopes, _ := ctxt.DebugInfo(s, absfn, curfn)
+ _, startLine := ctxt.getFileSymbolAndLine(curfn.Pos())
dwctxt := dwCtxt{ctxt}
fnstate := dwarf.FnState{
Name: s.Name,
}
type fnState struct {
- // precursor function (really *gc.Node)
- precursor interface{}
+ // precursor function
+ precursor Func
// abstract function symbol
absfn *LSym
}
}
}
-func (ft *DwarfFixupTable) GetPrecursorFunc(s *LSym) interface{} {
+func (ft *DwarfFixupTable) GetPrecursorFunc(s *LSym) Func {
if fnstate, found := ft.precursor[s]; found {
return fnstate.precursor
}
return nil
}
-func (ft *DwarfFixupTable) SetPrecursorFunc(s *LSym, fn interface{}) {
+func (ft *DwarfFixupTable) SetPrecursorFunc(s *LSym, fn Func) {
if _, found := ft.precursor[s]; found {
ft.ctxt.Diag("internal error: DwarfFixupTable.SetPrecursorFunc double call on %v", s)
}
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 {
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