Skip to content

Commit 357531d

Browse files
committed
feat: allow reset var counter on vm
1 parent 0e87b1e commit 357531d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

engine/vm.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"io/fs"
88
"strings"
9+
"sync/atomic"
910
)
1011

1112
type bytecode []instruction
@@ -302,6 +303,10 @@ func (vm *VM) SetUserOutput(s *Stream) {
302303
vm.output = s
303304
}
304305

306+
func (vm *VM) ResetVariableCounter() {
307+
atomic.StoreInt64(&varCounter, 1) // Set the varCounter to 1 instead of 0 because NewVariable() will first increment this counter and a global root variable has already been set to 1. (See engine/env.go L3)
308+
}
309+
305310
// Predicate0 is a predicate of arity 0.
306311
type Predicate0 func(*VM, Cont, *Env) *Promise
307312

0 commit comments

Comments
 (0)