diff options
| author | Mel <einebeere@gmail.com> | 2022-08-22 23:41:49 +0000 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-08-22 23:41:49 +0000 |
| commit | e22df631c4428f8dea4d5784a8a7840d2f84c6be (patch) | |
| tree | 084c233741374cdabde8d70b49988b3dca686719 /pkg/lang/vm/code/builder.go | |
| parent | 24183cd5363b96d83292df17d44fa79d8b47a89f (diff) | |
| download | jinx-e22df631c4428f8dea4d5784a8a7840d2f84c6be.tar.zst jinx-e22df631c4428f8dea4d5784a8a7840d2f84c6be.zip | |
Generate runtime debug info with source locations
Diffstat (limited to 'pkg/lang/vm/code/builder.go')
| -rw-r--r-- | pkg/lang/vm/code/builder.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/lang/vm/code/builder.go b/pkg/lang/vm/code/builder.go index f413ba1..618608a 100644 --- a/pkg/lang/vm/code/builder.go +++ b/pkg/lang/vm/code/builder.go @@ -2,6 +2,7 @@ package code import ( "encoding/binary" + "jinx/pkg/libs/source" "math" ) @@ -76,6 +77,7 @@ func (b *Builder) AppendBuilder(other Builder) error { } b.AppendRaw(other.code) + b.debugInfo.AppendOther(other.debugInfo) return nil } @@ -114,6 +116,10 @@ func (b *Builder) EndLine() { b.debugInfo.AppendLine(b.Len()-1, b.currentLine) } +func (b *Builder) AddDebugInfo(fromPc, toPc int, loc source.Loc) { + b.debugInfo.FillInfo(fromPc, toPc, loc) +} + func (b *Builder) SetInt(at int, x int64) { binary.LittleEndian.PutUint64(b.code[at:], uint64(x)) } |
