bind expression (:=) instead of let
This commit is contained in:
17
vm/vm.go
17
vm/vm.go
@@ -181,6 +181,11 @@ func (vm *VM) Run() error {
|
||||
vm.globals[globalIndex] = ref
|
||||
}
|
||||
|
||||
err := vm.push(Null)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
case code.OpAssignGlobal:
|
||||
globalIndex := code.ReadUint16(ins[ip+1:])
|
||||
vm.currentFrame().ip += 2
|
||||
@@ -284,7 +289,17 @@ func (vm *VM) Run() error {
|
||||
|
||||
frame := vm.currentFrame()
|
||||
|
||||
vm.stack[frame.basePointer+int(localIndex)] = vm.pop()
|
||||
ref := vm.pop()
|
||||
if immutable, ok := ref.(object.Immutable); ok {
|
||||
vm.stack[frame.basePointer+int(localIndex)] = immutable.Clone()
|
||||
} else {
|
||||
vm.stack[frame.basePointer+int(localIndex)] = ref
|
||||
}
|
||||
|
||||
err := vm.push(Null)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
case code.OpGetLocal:
|
||||
localIndex := code.ReadUint8(ins[ip+1:])
|
||||
|
||||
Reference in New Issue
Block a user