Wolframe, 0.0.3

Instance of a program with statevariables. More...

#include <programInstance.hpp>

Inheritance diagram for _Wolframe::db::vm::ProgramInstance:
_Wolframe::db::vm::InstructionSet

Classes

class  ResultFlags
 Flags defined in the database command between DO and the statement (NONEMPTY,UNIQUE) More...
 
class  StackElement
 State stack element of the virtual machine executing a transaction. More...
 

Public Types

typedef void(* LogTraceCallBack )(const LogTraceContext *prgcontext, unsigned int ip_)
 
- Public Types inherited from _Wolframe::db::vm::InstructionSet
enum  OpCode {
  Op_EXIT, Op_RETURN, Op_GOTO, Op_OUTPUT_CONST,
  Op_OUTPUT_PATH, Op_OUTPUT_LOOPCNT, Op_OUTPUT_SEL_IDX, Op_OUTPUT_SEL_NAM,
  Op_OUTPUT_ITR_IDX, Op_OUTPUT_ITR_NAM, Op_OUTPUT_ITR_COLUMN, Op_OUTPUT_OPEN_ARRAY,
  Op_OUTPUT_OPEN_ELEM, Op_OUTPUT_OPEN, Op_OUTPUT_CLOSE_ARRAY, Op_OUTPUT_CLOSE_ELEM,
  Op_OUTPUT_CLOSE, Op_OUTPUT_ADD_SINK, Op_KEEP_RESULT, Op_SELECT_PARAMETER,
  Op_SELECT_LAST_RESULT, Op_SELECT_KEPT_RESULT, Op_OPEN_ITER_LAST_RESULT, Op_OPEN_ITER_KEPT_RESULT,
  Op_OPEN_ITER_PATH, Op_OPEN_ITER_TUPLESET, Op_NEXT, Op_SUB_FRAME_OPEN,
  Op_SUB_ARG_CONST, Op_SUB_ARG_PATH, Op_SUB_ARG_LOOPCNT, Op_SUB_ARG_SEL_IDX,
  Op_SUB_ARG_SEL_NAM, Op_SUB_ARG_ITR_IDX, Op_SUB_ARG_ITR_NAM, Op_SUB_FRAME_CLOSE,
  Op_SCOPE_OPEN, Op_SCOPE_CLOSE, Op_DBSTM_START, Op_DBSTM_BIND_CONST,
  Op_DBSTM_BIND_PATH, Op_DBSTM_BIND_LOOPCNT, Op_DBSTM_BIND_SEL_IDX, Op_DBSTM_BIND_SEL_NAM,
  Op_DBSTM_BIND_ITR_IDX, Op_DBSTM_BIND_ITR_NAM, Op_DBSTM_HINT, Op_DBSTM_EXEC,
  Op_RESULT_SET_INIT, Op_RESULT_CONSTRAINT_UNIQUE, Op_RESULT_CONSTRAINT_NONEMPTY, Op_NOP
}
 Implemented operation codes of the VM. More...
 
enum  ArgumentType {
  At_None, At_Address, At_Path, At_Constant,
  At_ColumnName, At_TagName, At_ResultName, At_Statement,
  At_Hint, At_SubroutineSignature, At_TupleSet, At_SelectedColumnIdx,
  At_IteratorColumnIdx
}
 Enumeration of argument types. More...
 
enum  CondCode { Co_ALWAYS, Co_IF_COND, Co_NOT_IF_COND }
 Enumeration of conditional codes. More...
 
enum  { Max_OpCode =((1<<BitCnt_OpCode)-1), Max_CondCode =((1<<BitCnt_CondCode)-1), Max_ArgumentIndex =((1<<BitCnt_ArgumentIndex)-1) }
 
typedef boost::uint32_t ArgumentIndex
 Index of an argument. More...
 
typedef boost::uint32_t Address
 Address in program code. More...
 
typedef boost::uint32_t Instruction
 Instruction. More...
 

Public Member Functions

 ProgramInstance ()
 Default constructor. More...
 
 ProgramInstance (const ProgramInstance &o)
 Copy constructor. More...
 
 ProgramInstance (const ProgramImage &program_, TransactionExecStatemachine *db_stm_, LogTraceCallBack logTraceCallBack_=0, const LogTraceContext *logTraceContext_=0)
 Constructor. More...
 
bool execute ()
 Execute the program. More...
 
const OutputRoutput () const
 Get the output of the executed program. More...
 
const DatabaseErrorlastError () const
 Get the last error of the executed program. More...
 
unsigned int ip () const
 Get the current IP of program execution (instruction pointer) More...
 

Private Member Functions

ValueTupleSetR keptResult (ArgumentIndex idx) const
 
ValueTupleSetR tupleSet (ArgumentIndex idx) const
 
const types::VariantconstArgument (ArgumentIndex idx) const
 
const std::string & statementArgument (ArgumentIndex argidx) const
 
const std::string & tagnameArgument (ArgumentIndex argidx) const
 
types::Variant loopcntArgument () const
 
ArgumentIndex columnIndex (const ValueTupleSet *valueset, ArgumentIndex nameidx) const
 
const types::VariantselectedArgument (ArgumentIndex idx) const
 
const types::VariantiteratorArgument (ArgumentIndex idx) const
 
void initValueIteraror (const ValueTupleSetR &valueset)
 
void initResult (const ValueTupleSetR &resultset)
 
void printIteratorColumn ()
 
ValueTupleSetR fetchDatabaseResult (std::size_t nofColumns)
 
void setDatabaseError ()
 

Private Attributes

ProgramImage m_program
 image of program to execute More...
 
TransactionExecStatemachinem_db_stm
 engine to process database instructions More...
 
Address m_ip
 instruction pointer More...
 
SubroutineFrame m_subroutine_frame
 prepared subroutine call parameter structure More...
 
bool m_cond
 current condition flag for conditional execution ('InstructionSet::CondCode') More...
 
std::vector< StackElementm_stack
 execution stack More...
 
OutputR m_output
 output More...
 
DatabaseError m_lastError
 last database error reported More...
 
LogTraceCallBack m_logTraceCallBack
 NULL or callback procedure for logging execution that is be called after every instruction executed. More...
 
const LogTraceContextm_logTraceContext
 Context for 'm_logTraceCallBack'. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from _Wolframe::db::vm::InstructionSet
static const char * opCodeName (OpCode i)
 
static const char * argumentTypeName (ArgumentType i)
 Get the name of an argument type. More...
 
static ArgumentType argumentType (OpCode i)
 get the argument type of an operation More...
 
static const char * condCodeName (CondCode i)
 Get the name of a conditional code. More...
 
static Instruction instruction (CondCode cond, OpCode opcode, unsigned int arg=0)
 Build an instruction from its parts. More...
 
static Instruction instruction (OpCode opcode, unsigned int arg=0)
 Build an instruction from its parts (no condition -> always executed) More...
 
static CondCode condCode (const Instruction &instr)
 Get the condition code of an instruction (defining on which condition the instruction is executed) More...
 
static OpCode opCode (const Instruction &instr)
 Get the operation code of an instruction (defining what is done on execution) More...
 
static ArgumentIndex argumentIndex (const Instruction &instr)
 Get the argument index of the instruction (addressing the argument depending on the argument type of the instruction) More...
 
static void printProgramRaw (std::ostream &out, const std::vector< Instruction > &prg)
 Print the program code without any symbolic information that is not available here. More...
 
static std::string instructionstr (const Instruction &instr)
 Get the instruction as string. More...
 

Detailed Description

Instance of a program with statevariables.

Member Typedef Documentation

typedef void(* _Wolframe::db::vm::ProgramInstance::LogTraceCallBack)(const LogTraceContext *prgcontext, unsigned int ip_)

Constructor & Destructor Documentation

_Wolframe::db::vm::ProgramInstance::ProgramInstance ( )
inline

Default constructor.

_Wolframe::db::vm::ProgramInstance::ProgramInstance ( const ProgramInstance o)
inline

Copy constructor.

_Wolframe::db::vm::ProgramInstance::ProgramInstance ( const ProgramImage program_,
TransactionExecStatemachine db_stm_,
LogTraceCallBack  logTraceCallBack_ = 0,
const LogTraceContext logTraceContext_ = 0 
)

Constructor.

Member Function Documentation

ArgumentIndex _Wolframe::db::vm::ProgramInstance::columnIndex ( const ValueTupleSet valueset,
ArgumentIndex  nameidx 
) const
private
const types::Variant& _Wolframe::db::vm::ProgramInstance::constArgument ( ArgumentIndex  idx) const
private
bool _Wolframe::db::vm::ProgramInstance::execute ( )

Execute the program.

ValueTupleSetR _Wolframe::db::vm::ProgramInstance::fetchDatabaseResult ( std::size_t  nofColumns)
private
void _Wolframe::db::vm::ProgramInstance::initResult ( const ValueTupleSetR resultset)
private
void _Wolframe::db::vm::ProgramInstance::initValueIteraror ( const ValueTupleSetR valueset)
private
unsigned int _Wolframe::db::vm::ProgramInstance::ip ( ) const
inline

Get the current IP of program execution (instruction pointer)

const types::Variant& _Wolframe::db::vm::ProgramInstance::iteratorArgument ( ArgumentIndex  idx) const
private
ValueTupleSetR _Wolframe::db::vm::ProgramInstance::keptResult ( ArgumentIndex  idx) const
private
const DatabaseError* _Wolframe::db::vm::ProgramInstance::lastError ( ) const
inline

Get the last error of the executed program.

types::Variant _Wolframe::db::vm::ProgramInstance::loopcntArgument ( ) const
private
const OutputR& _Wolframe::db::vm::ProgramInstance::output ( ) const
inline

Get the output of the executed program.

void _Wolframe::db::vm::ProgramInstance::printIteratorColumn ( )
private
const types::Variant& _Wolframe::db::vm::ProgramInstance::selectedArgument ( ArgumentIndex  idx) const
private
void _Wolframe::db::vm::ProgramInstance::setDatabaseError ( )
private
const std::string& _Wolframe::db::vm::ProgramInstance::statementArgument ( ArgumentIndex  argidx) const
private
const std::string& _Wolframe::db::vm::ProgramInstance::tagnameArgument ( ArgumentIndex  argidx) const
private
ValueTupleSetR _Wolframe::db::vm::ProgramInstance::tupleSet ( ArgumentIndex  idx) const
private

Member Data Documentation

bool _Wolframe::db::vm::ProgramInstance::m_cond
private

current condition flag for conditional execution ('InstructionSet::CondCode')

TransactionExecStatemachine* _Wolframe::db::vm::ProgramInstance::m_db_stm
private

engine to process database instructions

Address _Wolframe::db::vm::ProgramInstance::m_ip
private

instruction pointer

DatabaseError _Wolframe::db::vm::ProgramInstance::m_lastError
private

last database error reported

LogTraceCallBack _Wolframe::db::vm::ProgramInstance::m_logTraceCallBack
private

NULL or callback procedure for logging execution that is be called after every instruction executed.

const LogTraceContext* _Wolframe::db::vm::ProgramInstance::m_logTraceContext
private

Context for 'm_logTraceCallBack'.

OutputR _Wolframe::db::vm::ProgramInstance::m_output
private

output

ProgramImage _Wolframe::db::vm::ProgramInstance::m_program
private

image of program to execute

std::vector<StackElement> _Wolframe::db::vm::ProgramInstance::m_stack
private

execution stack

SubroutineFrame _Wolframe::db::vm::ProgramInstance::m_subroutine_frame
private

prepared subroutine call parameter structure


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