summaryrefslogtreecommitdiff
path: root/comp
diff options
context:
space:
mode:
Diffstat (limited to 'comp')
-rw-r--r--comp/compiler.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/comp/compiler.go b/comp/compiler.go
index 05a4b3f..ef379ea 100644
--- a/comp/compiler.go
+++ b/comp/compiler.go
@@ -408,8 +408,15 @@ func (c *Compiler) Generate(tokens parser.Tokens) (err error) {
}
case lang.Next:
+ var i int
+ if s, ok := c.Symbols[t.Str]; !ok {
+ t.Arg = []any{len(c.Code)} // current code location
+ fixList = append(fixList, t)
+ } else {
+ i = int(s.Value.Int()) - len(c.Code)
+ }
k := stack[len(stack)-2]
- c.emit(t, vm.Next, k.Index)
+ c.emit(t, vm.Next, i, k.Index)
case lang.Range:
// FIXME: handle all iterator types.