ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
VirtualMachine::Command Class Reference

Description:

A command of the VM.

Definition at line 46 of file virtualmachine.hpp.

#include <virtualmachine.hpp>

Collaboration diagram for VirtualMachine::Command:
[legend]

Inner Type Index:

struct  DbgInformation
 
union  OperationParam
 

Public Type Index:

enum class  DecompileInfoType {
  LiteralConstant , OptimizationConstant , UnaryOp , BinaryOp ,
  Function , AutoCast , Subroutine
}
 
enum class  JumpType { Conditional , Unconditional }
 
enum class  OpCodes {
  Constant = 1 , Function = 2 , JumpIfFalse = 3 , Jump = 4 ,
  Subroutine = 5 , CmdMask = (1 << 16) - 1 , FlagEOC = (1 << 17)
}
 

Public Field Index:

DbgInformation DbgInfo
 
String DecompileSymbol
 
DecompileInfoType DecompileType
 
uinteger ExpressionPositions
 
OperationParam Operation
 
integer QtyFunctionArgs
 
Box ResultType
 

Public Method Index:

 Command (CallbackDecl callback, integer qtyFunctionArgs, const Box &resultType, const String &functionOrOp, bool isOperator, integer idxOriginal, integer idxNormalized)
 
 Command (const Box &value, bool isOptimization, integer idxOriginal, integer idxNormalized)
 
 Command (JumpType jumpType, integer idxOriginal, integer idxNormalized)
 
 Command (Program *program, const Box &resultType, const String &functionOrOp, integer idxOriginal, integer idxNormalized)
 
bool IsConditionalJump () const
 
bool IsConstant () const
 
void SetEndOfConditionalFlag ()
 
OpCodes Which () const
 

Enumeration Details:

◆ DecompileInfoType

enum class DecompileInfoType
strong

Denotes the type of decompilation 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.

Function 

Command results from a function call.

AutoCast 

Command results from an automatically inserted cast.

Subroutine 

Command results from a nested expression.

Definition at line 80 of file virtualmachine.hpp.

◆ JumpType

enum class JumpType
strong

Denotes the two different jump types (used as constructor parameter only.)

Enumerator
Conditional 

Denotes JumpIfFalse.

Unconditional 

Denotes Jump.

Definition at line 70 of file virtualmachine.hpp.

◆ OpCodes

enum class OpCodes
strong

The opcode type of VM commands. This is defined as a bitwise enum type as also flags may be set in addition to defining the type of operation.

Enumerator
Constant 

Pushes a constant to the stack.

Function 

Invokes a C++ callback function.

JumpIfFalse 

Jumps if top of the stack indicates false.

Jump 

Jumps.

Subroutine 

Invokes another program.

CmdMask 

Used to mask the command out of an opcode.

FlagEOC 

Flags a command to be the last of a conditional.

Definition at line 54 of file virtualmachine.hpp.

Field Details:

◆ DbgInfo

DbgInformation DbgInfo

Operation code of this command. Available only with debug builds.

Definition at line 195 of file virtualmachine.hpp.

◆ DecompileSymbol

String DecompileSymbol

The operator symbol or function name used with decompilation to recreate an expression string.

Definition at line 190 of file virtualmachine.hpp.

◆ DecompileType

DecompileInfoType DecompileType

Type of expression term used with decompilation.

Definition at line 186 of file virtualmachine.hpp.

◆ ExpressionPositions

uinteger ExpressionPositions

This encodes both, the position in the original and normalized expression string that resulted in this command. Used for generation of exception information and and debug listings.

Definition at line 182 of file virtualmachine.hpp.

◆ opcode

OpCodes opcode
protected

Operation code of this command.

Definition at line 152 of file virtualmachine.hpp.

◆ Operation

OperationParam Operation

The parameter of the operation.

Definition at line 156 of file virtualmachine.hpp.

◆ QtyFunctionArgs

integer QtyFunctionArgs

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 to differentiate between 0 and a negative number of arguments) is used when decompiling a program to back to an expression string. Hence, this piece of it logically belongs to DecompileType.

Definition at line 166 of file virtualmachine.hpp.

◆ ResultType

Box ResultType

The result type of a command. This is only needed during compilation. With debug builds of the library, it is furthermore used with VirtualMachine::DbgList . Hence for simplicity and shortness of the library code we keep it here, taking into account that after compilation each command is equipped with a then unnecessary box.

Definition at line 175 of file virtualmachine.hpp.

Constructor(s) / Destructor Details::

◆ Command() [1/4]

Command ( const Box & value,
bool isOptimization,
integer idxOriginal,
integer idxNormalized )
inline

Constructor creating a constant.

Parameters
valueThe constant to add.
isOptimizationDenotes if the constant results from an optimization or from a literal of the expression string.
idxOriginalExpression string index that imposed command.
idxNormalizedNormalized expression string index that imposed command.

Definition at line 206 of file virtualmachine.hpp.

◆ Command() [2/4]

Command ( CallbackDecl callback,
integer qtyFunctionArgs,
const Box & resultType,
const String & functionOrOp,
bool isOperator,
integer idxOriginal,
integer idxNormalized )
inline

Constructor creating a native function call exposed from an identifier, function or operator.

Parameters
callbackThe callback function.
qtyFunctionArgsThe number of arguments that the callback function expects.
resultTypeThe result type of the function.
functionOrOpThe identifier, function or operator name/symbol. This is used for decompilation of programs.
isOperatorIf true an unary operator was compiled, a binary operator otherwise.
idxOriginalExpression string index that imposed command.
idxNormalizedNormalized expression string index that imposed command.

Definition at line 231 of file virtualmachine.hpp.

◆ Command() [3/4]

Command ( Program * program,
const Box & resultType,
const String & functionOrOp,
integer idxOriginal,
integer idxNormalized )

Constructor creating a subroutine call.

Parameters
programThe program to call.
resultTypeThe result type of the program.
functionOrOpThe function or operator that created the nested call.
idxOriginalExpression string index that imposed command.
idxNormalizedNormalized expression string index that imposed command.

Definition at line 37 of file virtualmachine.cpp.

◆ Command() [4/4]

Command ( JumpType jumpType,
integer idxOriginal,
integer idxNormalized )
inline

Constructor creating a jump. Note, the address is usually not known yet, hence not provided. With debug builds, this constructor asserts that it is used for jump commands only.

Parameters
jumpTypeThe type of jump.
idxOriginalExpression string index that imposed command.
idxNormalizedNormalized expression string index that imposed command.

Definition at line 265 of file virtualmachine.hpp.

Method Details:

◆ IsConditionalJump()

bool IsConditionalJump ( ) const
inline

Returns true if the command represents a jump.

Returns
true if the command represents a jump, false otherwise.

Definition at line 288 of file virtualmachine.hpp.

◆ IsConstant()

bool IsConstant ( ) const
inline

Returns true if the command represents a constant value.

Returns
true if the command represents a constant value, false otherwise.

Definition at line 278 of file virtualmachine.hpp.

◆ SetEndOfConditionalFlag()

void SetEndOfConditionalFlag ( )
inline

Marks the command as the end of an conditional term.

Definition at line 297 of file virtualmachine.hpp.

◆ Which()

OpCodes Which ( ) const
inline

Returns the masked command part of the opcode.

Returns
The masked command part of the opcode.

Definition at line 306 of file virtualmachine.hpp.


The documentation for this class was generated from the following files: