OpcodeHelpers

Opcode helper functions that are used in other opcode libraries

Opcode libraries are: ComparisonOpcodes, BranchingOpcodes, LogicalOpcodes, and OtherOpcodes

putToStack

function putToStack(address _ctxProgram, uint256 _value) public

getNextBytes

function getNextBytes(address _ctxProgram, uint256 _size) public returns (bytes out)

Gets next {size} bytes from the program

Parameters

Name Type Description
_ctxProgram address Context contract address
_size uint256 Size of the chunk

Return Values

Name Type Description
out bytes Resulting chunk of type bytes

getNextBytes32

function getNextBytes32(address _ctxProgram, uint256 _size) public returns (bytes32 result)

Get next parameter from the program that is executing now

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
_size uint256 Size of the chunk

Return Values

Name Type Description
result bytes32 The bytes32-sized slice of the program

addItemToArray

function addItemToArray(address _ctxProgram, bytes32 _varValue, bytes32 _arrNameB32) public

add value in bytes32 to array

Parameters

Name Type Description
_ctxProgram address Context contract address
_varValue bytes32 added value
_arrNameB32 bytes32 name of array

readBytesSlice

function readBytesSlice(address _ctxProgram, uint256 _start, uint256 _end) public view returns (bytes32 result)

Reads the slice of bytes from the raw program Warning! The maximum slice size can only be 32 bytes!

Parameters

Name Type Description
_ctxProgram address Context contract address
_start uint256 Start position to read
_end uint256 End position to read

Return Values

Name Type Description
result bytes32 Bytes32 slice of the raw program

nextBranchSelector

function nextBranchSelector(address _ctxDSL, address _ctxProgram, string baseOpName) public returns (bytes4 result)

mustCall

function mustCall(address addr, bytes data) public returns (bytes)

Check .call() function and returns data

Parameters

Name Type Description
addr address Context contract address
data bytes Abi fubction with params

Return Values

Name Type Description
[0] bytes callData returns data from call

mustDelegateCall

function mustDelegateCall(address addr, bytes data) public returns (bytes)

Check .delegatecall() function and returns data

Parameters

Name Type Description
addr address Context contract address
data bytes Abi fubction with params

Return Values

Name Type Description
[0] bytes delegateCallData returns data from call

getAddress

function getAddress(address _ctxProgram) public returns (address result)

Reads a variable of type address

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address

Return Values

Name Type Description
result address The address value

getUint256

function getUint256(address _ctxProgram, address) public returns (uint256 result)

Reads a uint256 number from the program

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
address

Return Values

Name Type Description
result uint256 uint256 value from the program

getLocalVar

function getLocalVar(address _ctxProgram, string _funcSignature) public returns (bytes32 result)

Read local variable by delegatecalling a "read" function by its signature

Parameters

Name Type Description
_ctxProgram address ProgramContext contract address
_funcSignature string Signature of the "read" function

Return Values

Name Type Description
result bytes32 Local variable value