package code import ( "jinx/pkg/libs/rangemap" "jinx/pkg/libs/source" ) type DebugInfo struct { file string pcToLine rangemap.RangeMap[source.Loc] } func NewDebugInfo(file string) DebugInfo { return DebugInfo{ file: file, pcToLine: rangemap.New[source.Loc](), } } func (di *DebugInfo) File() string { return di.file } func (di *DebugInfo) PCToLoc(pc int) (source.Loc, bool) { loc := di.pcToLine.Get(pc) if loc == nil { return source.Loc{}, false } return *loc, true } func (di *DebugInfo) AppendLine(uptoPc, line int) { di.pcToLine.AppendToLast(uptoPc, source.Loc{Row: line, Col: 0}) } func (di *DebugInfo) FillInfo(from, to int, loc source.Loc) { di.pcToLine.Fill(from, to, loc) } func (di *DebugInfo) AppendOther(other DebugInfo) { di.pcToLine.AppendRanges(other.pcToLine) }