A command of the VM.
Definition at line 36 of file virtualmachine.hpp.
#include <virtualmachine.hpp>
Inner Type Index: | |
struct | DbgInformation |
union | OperationParam |
A union of different parameter types for the commands. More... | |
Public Type Index: | |
enum | Bits { CMD_MASK = 0x07 , FlagEOC = 0x08 , CMD_MASK_WITH_EOC = 0x0F , TYPE_MASK = 0xF0 } |
Some meanings and masks of field bits. More... | |
enum class | JumpType { Conditional , Unconditional } |
Denotes the two different jump types (used only as parameter, not stored.) More... | |
enum | ListingTypes { LiteralConstant = 0x00 , OptimizationConstant = 0x10 , UnaryOp = 0x20 , BinaryOp = 0x30 , Identifier = 0x40 , FunctionCall = 0x50 , AutoCast = 0x60 , NestedExpression = 0x70 } |
Denotes the type of parsing de-compilation information attached to the command. More... | |
enum | OpCodes { Constant = 0 , Function = 1 , Subroutine = 2 , JumpIfFalse = 4 , Jump = 5 } |
The opcode type of VM commands. More... | |
Public Field Index: | |
DbgInformation | DbgInfo |
Operation code of this command. Available only with debug-builds. | |
String | DecompileSymbol |
uinteger | ExpressionPositions |
OperationParam | Parameter |
The parameter of the operation. | |
Box | ResultType |
Public Method Index: | |
Command (CallbackDecl callback, bool isIdentifier, int qtyFunctionArgs, const Box &resultType, const String &functionOrOp, bool isOperator, integer idxOriginal, integer idxNormalized) | |
Command (const Box &value, bool isOptimization, integer idxOriginal, integer idxNormalized) | |
Command (integer idxOriginal, integer idxNormalized, JumpType jumpType) | |
ALIB_API | Command (Program *program, const Box &resultType, const String &functionOrOp, integer idxOriginal, integer idxNormalized) |
bool | HasArgs () const |
bool | IsConstant () const |
bool | IsIdentifier () const |
bool | IsJump () const |
constexpr OpCodes | OpCode () const |
int | QtyArgs () const |
void | SetEndOfConditionalFlag () |
Marks the command as the end of a conditional term. | |
constexpr ListingTypes | TerminalType () const |
Protected Field Index: | |
int16_t | bits |
Operation code of this command. | |
uint16_t | qtyArgs |
enum Bits |
Some meanings and masks of field bits.
Definition at line 40 of file virtualmachine.hpp.
|
strong |
Denotes the two different jump types (used only as parameter, not stored.)
Enumerator | |
---|---|
Conditional | Denotes JumpIfFalse. |
Unconditional | Denotes Jump. |
Definition at line 75 of file virtualmachine.hpp.
enum ListingTypes |
Denotes the type of parsing de-compilation information attached to the command.
Enumerator | |
---|---|
LiteralConstant | Command results from a literal constant. |
OptimizationConstant | Command results from a constant resulting from an optimization. |
UnaryOp | Command results from an unary operator. |
BinaryOp | Command results from a binary operator. |
Identifier | Command results from a function call with no parenthesis given. |
FunctionCall | Command results from a function call. |
AutoCast | Command results from an automatically inserted cast. |
NestedExpression | Command results from a nested expression. |
Definition at line 62 of file virtualmachine.hpp.
enum OpCodes |
The opcode type of VM commands.
Enumerator | |
---|---|
Constant | Pushes a constant to the stack. |
Function | Invokes a C++ callback function. |
Subroutine | Invokes another program. |
JumpIfFalse | Jumps if top of the stack indicates |
Jump | Jumps. |
Definition at line 50 of file virtualmachine.hpp.
|
protected |
Operation code of this command.
Definition at line 121 of file virtualmachine.hpp.
DbgInformation DbgInfo |
Operation code of this command. Available only with debug-builds.
Definition at line 152 of file virtualmachine.hpp.
String DecompileSymbol |
The operator symbol or function name used with de-compilation to recreate an expression string.
Definition at line 147 of file virtualmachine.hpp.
uinteger ExpressionPositions |
This encodes both, the position in the original and in the normalized expression string that resulted in this command. Used for generation of exception information and debug listings.
Definition at line 142 of file virtualmachine.hpp.
OperationParam Parameter |
The parameter of the operation.
Definition at line 133 of file virtualmachine.hpp.
|
protected |
The number of function args. If negative, this indicates that the function name was given as an 'identifier', what means that no brackets '()' had been added. This piece of information (namely having a signed integer here which allows differentiating between 0
and a negative number of arguments) is used when decompiling a program back to an expression string. Hence, this piece of it logically belongs to ListingTypes.
Definition at line 129 of file virtualmachine.hpp.
Box ResultType |
With every command, this box contains the result type. For constants, also the commands' value is contained.
Definition at line 137 of file virtualmachine.hpp.
|
inline |
Constructor creating a constant.
value | The constant to add. |
isOptimization | Denotes if the constant results from an optimization or from a literal of the expression string. |
idxOriginal | Expression string index that imposed command. |
idxNormalized | Normalized expression string index that imposed command. |
Definition at line 161 of file virtualmachine.hpp.
|
inline |
Constructor creating a native function call exposed from an identifier, function or operator.
callback | The callback function. |
isIdentifier | If no parentheses were given, this has to be true . Otherwise it is a function call. |
qtyFunctionArgs | The number of arguments that the callback function expects. |
resultType | The result type of the function. |
functionOrOp | The identifier, function or operator name/symbol. This is used for de-compilation of programs. |
isOperator | If true an unary operator was compiled, a binary operator otherwise. |
idxOriginal | Expression string index that imposed command. |
idxNormalized | Normalized expression string index that imposed command. |
Definition at line 185 of file virtualmachine.hpp.
Command | ( | Program * | program, |
const Box & | resultType, | ||
const String & | functionOrOp, | ||
integer | idxOriginal, | ||
integer | idxNormalized ) |
Constructor creating a subroutine call.
program | The program to call. |
resultType | The result type of the program. |
functionOrOp | The function or operator that created the nested call. |
idxOriginal | Expression string index that imposed command. |
idxNormalized | Normalized expression string index that imposed command. |
Definition at line 24 of file virtualmachine.cpp.
Constructor creating a jump. Note, the address is usually not known yet, hence not provided.
jumpType | The type of jump. |
idxOriginal | Expression string index that imposed command. |
idxNormalized | Normalized expression string index that imposed command. |
Definition at line 217 of file virtualmachine.hpp.
|
inline |
true
if the function has arguments, false
otherwise. Definition at line 248 of file virtualmachine.hpp.
|
inline |
Returns true
if the command represents a constant value, but is not the end of a conditional jump.
true
if the command represents a constant value, false
otherwise. Definition at line 237 of file virtualmachine.hpp.
|
inline |
true
if the function has arguments, false
otherwise. Definition at line 251 of file virtualmachine.hpp.
|
inline |
Returns true
if the command represents a conditional or unconditional jump.
true
if the command represents a jump, false
otherwise. Definition at line 242 of file virtualmachine.hpp.
|
inlineconstexpr |
Returns the opcode of this command.
Definition at line 228 of file virtualmachine.hpp.
|
inline |
Definition at line 254 of file virtualmachine.hpp.
|
inline |
Marks the command as the end of a conditional term.
Definition at line 245 of file virtualmachine.hpp.
|
inlineconstexpr |
Returns the decompile type of this command.
Definition at line 232 of file virtualmachine.hpp.