vm: clear state in Load()

Make VM usable after the first run.
This commit is contained in:
Roman Khimov 2019-10-29 12:53:09 +03:00
parent 0ea7568caa
commit ae7687422c

View file

@ -196,10 +196,11 @@ func (v *VM) LoadFile(path string) error {
// Load initializes the VM with the program given. // Load initializes the VM with the program given.
func (v *VM) Load(prog []byte) { func (v *VM) Load(prog []byte) {
// clear all stacks, it could be a reload. // Clear all stacks and state, it could be a reload.
v.istack.Clear() v.istack.Clear()
v.estack.Clear() v.estack.Clear()
v.astack.Clear() v.astack.Clear()
v.state = noneState
v.LoadScript(prog) v.LoadScript(prog)
} }