about summary refs log tree commit diff
path: root/pkg/lang/vm/text/compiler.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/lang/vm/text/compiler.go')
-rw-r--r--pkg/lang/vm/text/compiler.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/lang/vm/text/compiler.go b/pkg/lang/vm/text/compiler.go
index 2732aea..1480171 100644
--- a/pkg/lang/vm/text/compiler.go
+++ b/pkg/lang/vm/text/compiler.go
@@ -31,6 +31,7 @@ func NewCompiler(src io.Reader) *Compiler {
 
 func (cpl *Compiler) Compile() (code.Code, error) {
 	res := []byte{}
+	info := code.NewDebugInfo("unknown file")
 
 	for {
 		_, eof, err := cpl.src.Peek()
@@ -48,6 +49,11 @@ func (cpl *Compiler) Compile() (code.Code, error) {
 		}
 
 		cpl.codePos += len(line)
+
+		if line != nil {
+			info.AppendLine(cpl.codePos-1, cpl.src.Loc().Row-1)
+		}
+
 		res = append(res, line...)
 	}
 
@@ -55,7 +61,7 @@ func (cpl *Compiler) Compile() (code.Code, error) {
 		return code.Code{}, err
 	}
 
-	return code.New(res), nil
+	return code.New(res, info), nil
 }
 
 func (cpl *Compiler) compileLine() ([]byte, error) {