opcodePick treats the top item on the data stack as an integer and duplicates the item on the stack that number of items back to the top. Stack transformation: [xn ... x2 x1 x0 n] -> [xn ... x2 x1 x0 xn] Example with n=1: [x2 x1 x0 1] -> [x2 x1 x0 x1] Example with n=2: [x2 x1 x0 2] -> [x2 x1 x0 x2]
(op *opcode, data []byte, vm *Engine)
| 1331 | // Example with n=1: [x2 x1 x0 1] -> [x2 x1 x0 x1] |
| 1332 | // Example with n=2: [x2 x1 x0 2] -> [x2 x1 x0 x2] |
| 1333 | func opcodePick(op *opcode, data []byte, vm *Engine) error { |
| 1334 | val, err := vm.dstack.PopInt() |
| 1335 | if err != nil { |
| 1336 | return err |
| 1337 | } |
| 1338 | |
| 1339 | return vm.dstack.PickN(val.Int32()) |
| 1340 | } |
| 1341 | |
| 1342 | // opcodeRoll treats the top item on the data stack as an integer and moves |
| 1343 | // the item on the stack that number of items back to the top. |