opcodeBoolOr treats the top two items on the data stack as integers. When either of them are not zero, they are replaced with a 1, otherwise a 0. Stack transformation (x1==0, x2==0): [... 0 0] -> [... 0] Stack transformation (x1!=0, x2==0): [... 5 0] -> [... 1] Stack transformation (x1==0, x2!=0):
(op *opcode, data []byte, vm *Engine)
| 1601 | // Stack transformation (x1==0, x2!=0): [... 0 7] -> [... 1] |
| 1602 | // Stack transformation (x1!=0, x2!=0): [... 4 8] -> [... 1] |
| 1603 | func opcodeBoolOr(op *opcode, data []byte, vm *Engine) error { |
| 1604 | v0, err := vm.dstack.PopInt() |
| 1605 | if err != nil { |
| 1606 | return err |
| 1607 | } |
| 1608 | |
| 1609 | v1, err := vm.dstack.PopInt() |
| 1610 | if err != nil { |
| 1611 | return err |
| 1612 | } |
| 1613 | |
| 1614 | if v0 != 0 || v1 != 0 { |
| 1615 | vm.dstack.PushInt(scriptNum(1)) |
| 1616 | } else { |
| 1617 | vm.dstack.PushInt(scriptNum(0)) |
| 1618 | } |
| 1619 | |
| 1620 | return nil |
| 1621 | } |
| 1622 | |
| 1623 | // opcodeNumEqual treats the top two items on the data stack as integers. When |
| 1624 | // they are equal, they are replaced with a 1, otherwise a 0. |