diff options
| author | Marc Vertes <mvertes@free.fr> | 2026-01-23 11:16:12 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2026-01-23 11:16:12 +0100 |
| commit | 2837dabf7818666a9366d659d2da3b9055140740 (patch) | |
| tree | 3d4fce18fe750044b519e571845d4b476f958656 /parser/tokens.go | |
| parent | abd8581bac36018be2f090e05fdd00ea74f6ca4b (diff) | |
feat: make Next iterator instruction faster and more efficient
Branching control is delegated directly to the Next instruction,
which now takes the location of loop exit as first argument.
It avoids the use of JumpFalse, plus the stack storage for the
condition.
Diffstat (limited to 'parser/tokens.go')
| -rw-r--r-- | parser/tokens.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/parser/tokens.go b/parser/tokens.go index a0a93fa..7a241f3 100644 --- a/parser/tokens.go +++ b/parser/tokens.go @@ -79,6 +79,8 @@ func newCall(pos int, arg ...any) Token { return newToken(lang.Cal func newGoto(label string, pos int) Token { return newToken(lang.Goto, label, pos) } func newLabel(label string, pos int) Token { return newToken(lang.Label, label, pos) } func newJumpFalse(label string, pos int) Token { return newToken(lang.JumpFalse, label, pos) } +func newNext(label string, pos int) Token { return newToken(lang.Next, label, pos) } +func newStop(pos int) Token { return newToken(lang.Stop, "", pos) } func newGrow(size, pos int) Token { return newToken(lang.Grow, "", pos, size) } func newSemicolon(pos int) Token { return newToken(lang.Semicolon, "", pos) } func newEqualSet(pos int) Token { return newToken(lang.EqualSet, "", pos) } |
