opcodeRoll treats the top item on the data stack as an integer and moves the item on the stack that number of items back to the top. Stack transformation: [xn ... x2 x1 x0 n] -> [... x2 x1 x0 xn] Example with n=1: [x2 x1 x0 1] -> [x2 x0 x1] Example with n=2: [x2 x1 x0 2] -> [x1 x0 x2]
(op *opcode, data []byte, vm *Engine)
| 1346 | // Example with n=1: [x2 x1 x0 1] -> [x2 x0 x1] |
| 1347 | // Example with n=2: [x2 x1 x0 2] -> [x1 x0 x2] |
| 1348 | func opcodeRoll(op *opcode, data []byte, vm *Engine) error { |
| 1349 | val, err := vm.dstack.PopInt() |
| 1350 | if err != nil { |
| 1351 | return err |
| 1352 | } |
| 1353 | |
| 1354 | return vm.dstack.RollN(val.Int32()) |
| 1355 | } |
| 1356 | |
| 1357 | // opcodeRot rotates the top 3 items on the data stack to the left. |
| 1358 | // |