diff options
| author | Marc Vertes <mvertes@free.fr> | 2026-01-27 16:37:02 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2026-01-27 16:37:02 +0100 |
| commit | 60f6ebc8d8369721e105d826145af2b8856ac67e (patch) | |
| tree | 002073b75edc68aba95399db89f50b24ebb6935f /vm | |
| parent | aa5861917ac2543f85bf4cfefbb69cf501d4de41 (diff) | |
fix: improve multiple define
The VM Vassign instruction now takes an argument to indicates the
number of assignations to perform on the stack.
Definitions with a function returning multiple values now work.
There is still some simplifications, and also to apply the same
strategy to var declarations with assign.
Diffstat (limited to 'vm')
| -rw-r--r-- | vm/vm.go | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -311,8 +311,13 @@ func (m *Machine) Run() (err error) { mem[sp-3].SetMapIndex(mem[sp-2].Value, mem[sp-1].Value) mem = mem[:sp-2] case Vassign: - mem[sp-2].Set(mem[sp-1].Value) - mem = mem[:sp-2] + n := c.Arg[0] + for i := 0; i < n; i++ { + mem[sp-n-i-1].Set(mem[sp-n+i].Value) + } + mem = mem[:sp-n-1] + // mem[sp-2].Set(mem[sp-1].Value) + // mem = mem[:sp-2] } ip++ } |
