RevertCommand reverts all the instructions since the last call to BeginCommand. Any postbacks issued since the last call to BeginCommand will be called with the error err and a nil decoder.
(err error)
| 301 | // BeginCommand. Any postbacks issued since the last call to BeginCommand will |
| 302 | // be called with the error err and a nil decoder. |
| 303 | func (b *Builder) RevertCommand(err error) { |
| 304 | if !b.inCmd { |
| 305 | panic("RevertCommand called without a call to BeginCommand") |
| 306 | } |
| 307 | b.pendingLabel = 0 |
| 308 | b.pendingThreadID = b.currentThreadID |
| 309 | b.inCmd = false |
| 310 | // TODO: Revert calls to: AllocateMemory, Buffer, String, ReserveMemory, MapMemory, UnmapMemory, Write. |
| 311 | b.temp.reset() |
| 312 | b.stack = b.stack[:0] |
| 313 | if len(b.instructions) > 0 { |
| 314 | for i := len(b.instructions) - 1; i >= b.cmdStart; i-- { |
| 315 | switch b.instructions[i].(type) { |
| 316 | case asm.Post: |
| 317 | idx := len(b.decoders) - 1 |
| 318 | b.decoders[idx].decode(nil, err) |
| 319 | b.decoders = b.decoders[:idx] |
| 320 | } |
| 321 | } |
| 322 | b.instructions = b.instructions[:b.cmdStart] |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | // Buffer returns a pointer to a block of memory in holding the count number of |
| 327 | // previously pushed values. |