* Instantiate an opcode from a Number. * @param {Number} num * @returns {Opcode}
(num)
| 515 | */ |
| 516 | |
| 517 | static fromInt(num) { |
| 518 | assert(Number.isSafeInteger(num)); |
| 519 | |
| 520 | if (num === 0) |
| 521 | return this.fromOp(opcodes.OP_0); |
| 522 | |
| 523 | if (num === -1) |
| 524 | return this.fromOp(opcodes.OP_1NEGATE); |
| 525 | |
| 526 | if (num >= 1 && num <= 16) |
| 527 | return this.fromOp(num + 0x50); |
| 528 | |
| 529 | return this.fromNum(ScriptNum.fromNumber(num)); |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * Instantiate an opcode from a Number. |