DSLContext
_Context of DSL code
One of the core contracts of the project. It contains opcodes and aliases for commands.
During creating Context contract executes the initOpcodes
function that provides
basic working opcodes_
branchingOpcodes
address branchingOpcodes
comparisonOpcodes
address comparisonOpcodes
complexOpcodes
address complexOpcodes
logicalOpcodes
address logicalOpcodes
otherOpcodes
address otherOpcodes
opCodeByName
mapping(string => bytes1) opCodeByName
selectorByOpcode
mapping(bytes1 => bytes4) selectorByOpcode
numOfArgsByOpcode
mapping(string => uint8) numOfArgsByOpcode
isCommand
mapping(string => bool) isCommand
opcodeLibNameByOpcode
mapping(bytes1 => enum IDSLContext.OpcodeLibNames) opcodeLibNameByOpcode
asmSelectors
mapping(string => bytes4) asmSelectors
opsPriors
mapping(string => uint256) opsPriors
operators
string[] operators
branchSelectors
mapping(string => mapping(bytes1 => bytes4)) branchSelectors
branchCodes
mapping(string => mapping(string => bytes1)) branchCodes
aliases
mapping(string => string) aliases
nonZeroAddress
modifier nonZeroAddress(address _addr)
constructor
constructor(address _comparisonOpcodes, address _branchingOpcodes, address _logicalOpcodes, address _otherOpcodes, address _complexOpcodes) public
initOpcodes
function initOpcodes() internal
Creates a list of opcodes and its aliases with information about each of them: - name - selectors of opcode functions, - used library for each of opcode for Executor contract - asm selector of function that uses in Parser contract Function contains simple opcodes as arithmetic, comparison and bitwise. In additional to that it contains complex opcodes that can load data (variables with different types) from memory and helpers like transfer tokens or native coins to the address or opcodes branching and internal DSL functions.
operatorsLen
function operatorsLen() external view returns (uint256)
Returns the amount of stored operators
_addOpcode
function _addOpcode(string _name, bytes1 _opcode, bytes4 _opSelector, bytes4 _asmSelector, enum IDSLContext.OpcodeLibNames _libName, uint8 _numOfArgs, bool _isCommand) internal
Adds the opcode for the DSL command
Parameters
Name | Type | Description |
---|---|---|
_name | string | is the name of the command |
_opcode | bytes1 | is the opcode of the command |
_opSelector | bytes4 | is the selector of the function for this opcode from onle of library in contracts/libs/opcodes/* |
_asmSelector | bytes4 | is the selector of the function from the Parser for that opcode |
_libName | enum IDSLContext.OpcodeLibNames | is the name of library that is used fot the opcode |
_numOfArgs | uint8 | The number of arguments for this opcode |
_isCommand | bool |
_addOpcodeForOperator
function _addOpcodeForOperator(string _name, bytes1 _opcode, bytes4 _opSelector, bytes4 _asmSelector, enum IDSLContext.OpcodeLibNames _libName, uint256 _priority) internal
Adds the opcode for the operator
Parameters
Name | Type | Description |
---|---|---|
_name | string | is the name of the operator |
_opcode | bytes1 | is the opcode of the operator |
_opSelector | bytes4 | is the selector of the function for this operator from onle of library in contracts/libs/opcodes/* |
_asmSelector | bytes4 | is the selector of the function from the Parser for this operator |
_libName | enum IDSLContext.OpcodeLibNames | is the name of library that is used fot the operator |
_priority | uint256 | is the priority for the opcode |
_addOpcodeBranch
function _addOpcodeBranch(string _baseOpName, string _branchName, bytes1 _branchCode, bytes4 _selector) internal
As branched (complex) DSL commands have their own name, types and values the _addOpcodeBranch provides adding opcodes using additional internal branch opcodes.
Parameters
Name | Type | Description |
---|---|---|
_baseOpName | string | is the name of the command |
_branchName | string | is the type for the value |
_branchCode | bytes1 | is the code for the certain name and its type |
_selector | bytes4 | is the selector of the function from the Parser for this command |
_addOperator
function _addOperator(string _op, uint256 _priority) internal
Adds the operator by its priority Note: bigger number => bigger priority
Parameters
Name | Type | Description |
---|---|---|
_op | string | is the name of the operator |
_priority | uint256 | is the priority of the operator |
_addAlias
function _addAlias(string _baseCmd, string _alias) internal
Adds an alias to the already existing DSL command
Parameters
Name | Type | Description |
---|---|---|
_baseCmd | string | is the name of the command |
_alias | string | is the alias command name for the base command |