mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
compiler: support sequence points in debug info
Sequence points is a way to map a specific instruction offset from a compiled contract to a text span in a source file. This commit implements mapping only for `return` statements. Further improvements are straight-forward.
This commit is contained in:
parent
24fef35ead
commit
5d3da26e1e
3 changed files with 52 additions and 1 deletions
|
@ -76,6 +76,19 @@ type DebugParam struct {
|
|||
Type string
|
||||
}
|
||||
|
||||
func (c *codegen) saveSequencePoint(n ast.Node) {
|
||||
fset := c.buildInfo.program.Fset
|
||||
start := fset.Position(n.Pos())
|
||||
end := fset.Position(n.End())
|
||||
c.sequencePoints[c.scope.name] = append(c.sequencePoints[c.scope.name], DebugSeqPoint{
|
||||
Opcode: c.prog.Len(),
|
||||
StartLine: start.Line,
|
||||
StartCol: start.Offset,
|
||||
EndLine: end.Line,
|
||||
EndCol: end.Offset,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *codegen) emitDebugInfo() *DebugInfo {
|
||||
d := &DebugInfo{
|
||||
EntryPoint: mainIdent,
|
||||
|
@ -108,6 +121,7 @@ func (c *codegen) methodInfoFromScope(name string, scope *funcScope) *MethodDebu
|
|||
Range: scope.rng,
|
||||
Parameters: params,
|
||||
ReturnType: c.scReturnTypeFromScope(scope),
|
||||
SeqPoints: c.sequencePoints[name],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue