ug4
ug::VMAdd Class Reference

--> documentation in vm.doxygen <–/// More...

#include <vm.h>

Public Member Functions

void adjust_jmp_pos (int iPos, int jmpPos)
 
void assign (int v)
 
void binary (int oper)
 
double call ()
 
double call (double *stack, int &SP)
 
double call (double a)
 
double call (double a, double b)
 
double call (double a, double b, double c)
 
void call (SmartPtr< VMAdd > subfunction)
 
double call_sub (double *stack, int &SP)
 
int execute (double *ret, const double *in)
 
void execute_binary (size_t &i, double *stack, int SP)
 
void execute_unary (size_t &i, double &v)
 
int get_pos ()
 
int jmp ()
 
int jmp_if_false ()
 
int jump (VMInstruction instr)
 
size_t num_in ()
 
size_t num_out ()
 
void print ()
 
void print_rec (int level)
 
void print_short ()
 
void push (double constant)
 
void push_var (int i)
 
void ret ()
 
void set_in_out (size_t nrIn, size_t nrOut)
 
void set_name (std::string name)
 
void set_nr_of_variables (size_t nr)
 
void unary (int oper)
 
 VMAdd ()
 

Private Types

enum  VMInstruction {
  PUSH_CONSTANT =0 , PUSH_VAR , JMP_IF_FALSE , JMP ,
  OP_UNARY , OP_BINARY , ASSIGN , OP_RETURN ,
  OP_CALL
}
 

Private Member Functions

void deserializeDouble (size_t &p, double &d)
 
void deserializeInt (size_t &p, int &i)
 
void deserializeVMInstr (size_t &p, VMInstruction &instr)
 
void print_op (size_t &i)
 
void print_unaryDouble (const char *desc, size_t &i)
 
void print_unaryInt (const char *desc, size_t &i)
 
void serializeChar (char c)
 
void serializeDouble (double d)
 
void serializeInt (int d)
 
void serializeVMInstr (VMInstruction inst)
 

Private Attributes

std::string m_name
 
size_t m_nrIn
 
size_t m_nrOut
 
std::vector< SmartPtr< VMAdd > > subfunctions
 
std::vector< double > variables
 
std::vector< char > vmBuf
 

Detailed Description

--> documentation in vm.doxygen <–///

Member Enumeration Documentation

◆ VMInstruction

Enumerator
PUSH_CONSTANT 
PUSH_VAR 
JMP_IF_FALSE 
JMP 
OP_UNARY 
OP_BINARY 
ASSIGN 
OP_RETURN 
OP_CALL 

Constructor & Destructor Documentation

◆ VMAdd()

ug::VMAdd::VMAdd ( )
inline

References m_name.

Member Function Documentation

◆ adjust_jmp_pos()

void ug::VMAdd::adjust_jmp_pos ( int  iPos,
int  jmpPos 
)
inline

References p, and vmBuf.

Referenced by ug::LUAParserClass::createVM().

◆ assign()

void ug::VMAdd::assign ( int  v)
inline

References ASSIGN, and serializeInt().

Referenced by ug::LUAParserClass::createVM().

◆ binary()

void ug::VMAdd::binary ( int  oper)
inline

References OP_BINARY, and serializeInt().

Referenced by ug::LUAParserClass::createVM().

◆ call() [1/6]

double ug::VMAdd::call ( )
inline

Referenced by call(), call_sub(), and execute().

◆ call() [2/6]

◆ call() [3/6]

double ug::VMAdd::call ( double  a)
inline

References call(), m_nrIn, m_nrOut, UG_ASSERT, and variables.

◆ call() [4/6]

double ug::VMAdd::call ( double  a,
double  b 
)
inline

References call(), m_nrIn, m_nrOut, UG_ASSERT, and variables.

◆ call() [5/6]

double ug::VMAdd::call ( double  a,
double  b,
double  c 
)
inline

References call(), m_nrIn, m_nrOut, UG_ASSERT, and variables.

◆ call() [6/6]

void ug::VMAdd::call ( SmartPtr< VMAdd subfunction)
inline

◆ call_sub()

double ug::VMAdd::call_sub ( double *  stack,
int &  SP 
)
inline

References call(), m_nrIn, and variables.

◆ deserializeDouble()

void ug::VMAdd::deserializeDouble ( size_t &  p,
double &  d 
)
inlineprivate

References p, and vmBuf.

Referenced by call(), and print_unaryDouble().

◆ deserializeInt()

void ug::VMAdd::deserializeInt ( size_t &  p,
int &  i 
)
inlineprivate

◆ deserializeVMInstr()

void ug::VMAdd::deserializeVMInstr ( size_t &  p,
VMInstruction instr 
)
inlineprivate

References p, and vmBuf.

Referenced by call(), and print_rec().

◆ execute()

int ug::VMAdd::execute ( double *  ret,
const double *  in 
)
inline

References call(), m_nrIn, m_nrOut, ret(), UG_ASSERT, and variables.

◆ execute_binary()

void ug::VMAdd::execute_binary ( size_t &  i,
double *  stack,
int  SP 
)
inline

◆ execute_unary()

◆ get_pos()

int ug::VMAdd::get_pos ( )
inline

References vmBuf.

Referenced by ug::LUAParserClass::createVM(), and jump().

◆ jmp()

int ug::VMAdd::jmp ( )
inline

References JMP, and jump().

Referenced by ug::LUAParserClass::createVM().

◆ jmp_if_false()

int ug::VMAdd::jmp_if_false ( )
inline

References JMP_IF_FALSE, and jump().

Referenced by ug::LUAParserClass::createVM().

◆ jump()

int ug::VMAdd::jump ( VMInstruction  instr)
inline

References get_pos(), serializeInt(), and serializeVMInstr().

Referenced by jmp(), and jmp_if_false().

◆ num_in()

size_t ug::VMAdd::num_in ( )
inline

References m_nrIn.

◆ num_out()

size_t ug::VMAdd::num_out ( )
inline

References m_nrOut.

◆ print()

void ug::VMAdd::print ( )
inline

References print_rec().

Referenced by ug::bridge::convertVM().

◆ print_op()

◆ print_rec()

◆ print_short()

void ug::VMAdd::print_short ( )
inline

References m_name, m_nrIn, m_nrOut, subfunctions, UG_LOG, and variables.

Referenced by print_rec().

◆ print_unaryDouble()

void ug::VMAdd::print_unaryDouble ( const char *  desc,
size_t &  i 
)
inlineprivate

References deserializeDouble(), and UG_LOG.

Referenced by print_rec().

◆ print_unaryInt()

void ug::VMAdd::print_unaryInt ( const char *  desc,
size_t &  i 
)
inlineprivate

References deserializeInt(), and UG_LOG.

Referenced by print_rec().

◆ push()

void ug::VMAdd::push ( double  constant)
inline

◆ push_var()

void ug::VMAdd::push_var ( int  i)
inline

References PUSH_VAR, and serializeInt().

Referenced by ug::LUAParserClass::createVM().

◆ ret()

void ug::VMAdd::ret ( )
inline

References OP_RETURN, and serializeInt().

Referenced by ug::LUAParserClass::createVM(), and execute().

◆ serializeChar()

void ug::VMAdd::serializeChar ( char  c)
inlineprivate

References vmBuf.

Referenced by serializeDouble(), and serializeInt().

◆ serializeDouble()

void ug::VMAdd::serializeDouble ( double  d)
inlineprivate

References serializeChar().

Referenced by push().

◆ serializeInt()

void ug::VMAdd::serializeInt ( int  d)
inlineprivate

◆ serializeVMInstr()

void ug::VMAdd::serializeVMInstr ( VMInstruction  inst)
inlineprivate

References serializeInt().

Referenced by jump().

◆ set_in_out()

void ug::VMAdd::set_in_out ( size_t  nrIn,
size_t  nrOut 
)
inline

References m_nrIn, and m_nrOut.

Referenced by ug::LUAParserClass::createVMHeader().

◆ set_name()

void ug::VMAdd::set_name ( std::string  name)
inline

References m_name, and name.

Referenced by ug::LUAParserClass::createVM().

◆ set_nr_of_variables()

void ug::VMAdd::set_nr_of_variables ( size_t  nr)
inline

References variables.

Referenced by ug::LUAParserClass::createVMHeader().

◆ unary()

void ug::VMAdd::unary ( int  oper)
inline

References OP_UNARY, and serializeInt().

Referenced by ug::LUAParserClass::createVM().

Member Data Documentation

◆ m_name

std::string ug::VMAdd::m_name
private

◆ m_nrIn

size_t ug::VMAdd::m_nrIn
private

◆ m_nrOut

size_t ug::VMAdd::m_nrOut
private

◆ subfunctions

std::vector<SmartPtr<VMAdd> > ug::VMAdd::subfunctions
private

Referenced by call(), print_rec(), and print_short().

◆ variables

std::vector<double> ug::VMAdd::variables
private

◆ vmBuf

std::vector<char> ug::VMAdd::vmBuf
private

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