Function toOPCode

Converts the byte to an opcode, or returns false if it's an unrecognized opcode.

bool toOPCode (
  in const(ubyte) value,
  out OP opcode
) pure nothrow @nogc @safe;

Parameters

NameDescription
value the byte containing the opcode
opcode will contain the opcode if it was recognized

Returns

true if the value is a recognized opcode

Example

OP op;
assert(0x00.toOPCode(op) && op == OP.FALSE);
assert(0x59.toOPCode(op) && op == OP.HASH);
assert(!255.toOPCode(op));
assert(1.toOPCode(op) && op == OP.PUSH_BYTES_1);
assert(32.toOPCode(op) && op == cast(OP)32);
assert(75.toOPCode(op) && op == OP.PUSH_BYTES_75);