compiler: save sequence points for init function

This commit is contained in:
Evgenii Stratonikov 2020-08-10 17:42:53 +03:00
parent 40fa7c0f6e
commit 128626de5c

View file

@ -85,14 +85,15 @@ type DebugParam struct {
}
func (c *codegen) saveSequencePoint(n ast.Node) {
if c.scope == nil {
// do not save globals for now
return
name := "init"
if c.scope != nil {
name = c.scope.name
}
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{
c.sequencePoints[name] = append(c.sequencePoints[name], DebugSeqPoint{
Opcode: c.prog.Len(),
Document: c.docIndex[start.Filename],
StartLine: start.Line,
@ -122,6 +123,7 @@ func (c *codegen) emitDebugInfo(contract []byte) *DebugInfo {
End: uint16(c.initEndOffset),
},
ReturnType: "Void",
SeqPoints: c.sequencePoints["init"],
})
}
for name, scope := range c.funcs {