ssa: debug info of function/closure

This commit is contained in:
Li Jie
2024-09-18 20:31:45 +08:00
parent 27f892a14b
commit 90a83c8f11
3 changed files with 21 additions and 64 deletions

View File

@@ -735,7 +735,7 @@ func (p *context) compileInstr(b llssa.Builder, instr ssa.Instruction) {
return
}
pos := p.goProg.Fset.Position(getPos(v))
pos := p.goProg.Fset.Position(v.Pos())
value := p.compileValue(b, v.X)
fn := v.Parent()
dbgVar := p.getLocalVariable(b, fn, variable)
@@ -754,40 +754,6 @@ type poser interface {
Pos() token.Pos
}
func getPos(v poser) token.Pos {
pos := v.Pos()
if pos.IsValid() {
return pos
}
panic(fmt.Errorf("getPos: invalid position - %T", v))
// switch v := v.(type) {
// case *ssa.MakeInterface:
// return getPos(v.X)
// case *ssa.MakeClosure:
// return v.Fn.(*ssa.Function).Pos()
// case *ssa.Return:
// syntax := v.Parent().Syntax()
// if syntax != nil {
// return syntax.End()
// }
// return token.NoPos
// case *ssa.FieldAddr:
// return getPos(v.X)
// case *ssa.IndexAddr:
// return getPos(v.X)
// case *ssa.Slice:
// return getPos(v.X)
// case *ssa.Store:
// return getPos(v.Addr)
// case *ssa.Extract:
// return getPos(v.Tuple)
// default:
// fmt.Printf("getPos: unknown instr - %T\n", v)
// return token.NoPos
// }
}
func (p *context) getLocalVariable(b llssa.Builder, fn *ssa.Function, v *types.Var) llssa.DIVar {
pos := p.fset.Position(v.Pos())
t := b.Prog.Type(v.Type(), llssa.InGo)