LibExtern
Functions
encodeExternDispatch
Converts an opcode and operand pair into a single 32-byte word. The encoding scheme is:
- bits [0,16): the operand
- bits [16,32): the opcode IMPORTANT: The encoding process does not check that either the opcode or operand fit within 16 bits. This is the responsibility of the caller.
function encodeExternDispatch(uint256 opcode, Operand operand) internal pure returns (ExternDispatch);
decodeExternDispatch
Inverse of encodeExternDispatch
.
function decodeExternDispatch(ExternDispatch dispatch) internal pure returns (uint256, Operand);
encodeExternCall
Encodes an extern address and dispatch pair into a single 32-byte word. This is the full data required to actually call an extern contract. The encoding scheme is:
- bits [0,160): the address of the extern contract
- bits [160,176): the dispatch operand
- bits [176,192): the dispatch opcode
Note that the high bits are implied by a correctly encoded
ExternDispatch
. UseencodeExternDispatch
to ensure this. IMPORTANT: The encoding process does not check that any of the values fit within their respective bit ranges. This is the responsibility of the caller.
function encodeExternCall(IInterpreterExternV3 extern, ExternDispatch dispatch)
internal
pure
returns (EncodedExternDispatch);
decodeExternCall
Inverse of encodeExternCall
.
function decodeExternCall(EncodedExternDispatch dispatch)
internal
pure
returns (IInterpreterExternV3, ExternDispatch);