blob: efb788c26c6c7dd103f5083c8bdd3b757d7b6dee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
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)
}
|