81 int i = *((
int*)&
vmBuf[
p]);
93 char *tmp = (
char*)&d;
94 for(
size_t i=0; i<
sizeof(d); i++)
106 char *tmp = (
char*)&d;
107 for(
size_t i=0; i<
sizeof(d); i++)
113 d = *((
double*)&
vmBuf[
p]);
122 UG_LOG(desc <<
" " << t <<
"\n");
128 UG_LOG(desc <<
" " << t <<
"\n");
146 case '+':
UG_LOG(
"+\n");
break;
147 case '-':
UG_LOG(
"-\n");
break;
148 case '*':
UG_LOG(
"*\n");
break;
149 case '/':
UG_LOG(
"/\n");
break;
150 case '<':
UG_LOG(
"<\n");
break;
151 case '>':
UG_LOG(
">\n");
break;
246 int *
p = (
int *)&
vmBuf[iPos];
268 if(level > 5) {
UG_LOG(
"\n... aborting recursion (potential infinite loop)\n"); }
271 for(
size_t i=0; i<
vmBuf.size(); )
314 UG_LOG(
"CALL to subfunction " << varI <<
": ");
321 UG_LOG(((
int)instr) <<
"?\n");
329 UG_LOG(
"---- SUBFUNCTION " << i <<
" of " <<
m_name <<
" ----\n");
378 double &a = stack[SP-2];
379 double &b = stack[SP-1];
386 case '+': a = b+a;
break;
387 case '-': a = b-a;
break;
388 case '*': a = b*a;
break;
389 case '/': a = b/a;
break;
390 case '<': a = (b < a) ? 1.0 : 0.0;
break;
391 case '>': a = (b > a) ? 1.0 : 0.0;
break;
396 case LUAPARSER_AND: a = (a != 0.0 && b != 0.0) ? 1.0 : 0.0;
break;
397 case LUAPARSER_OR: a = (a != 0 || b != 0) ? 1.0 : 0.0;
break;
404 double call(
double *stack,
int &SP)
479 sub->call_sub(stack, SP);
484 UG_ASSERT(0,
"IP: " << i <<
" op " << ((
int)instr) <<
" ?\n");
491 for(
size_t i=0; i<
m_nrIn; i++)
494 return call(stack, SP);
502 for(
size_t i=0;i<
m_nrIn; i++)
506 for(
size_t i=0; i<
m_nrOut; i++)
516 return call(stack, SP);
519 double call(
double a,
double b,
double c)
529 double call(
double a,
double b)
location name
Definition: checkpoint_util.lua:128
Definition: smart_pointer.h:108
--> documentation in vm.doxygen <–///
Definition: vm.h:49
std::vector< SmartPtr< VMAdd > > subfunctions
Definition: vm.h:55
int jump(VMInstruction instr)
Definition: vm.h:336
double call(double a, double b, double c)
Definition: vm.h:519
void deserializeDouble(size_t &p, double &d)
Definition: vm.h:111
std::vector< char > vmBuf
Definition: vm.h:51
size_t num_out()
Definition: vm.h:546
double call(double a, double b)
Definition: vm.h:529
void serializeInt(int d)
Definition: vm.h:91
int jmp()
Definition: vm.h:196
std::string m_name
Definition: vm.h:52
double call()
Definition: vm.h:512
void print_op(size_t &i)
Definition: vm.h:131
void print_rec(int level)
Definition: vm.h:266
void deserializeVMInstr(size_t &p, VMInstruction &instr)
Definition: vm.h:79
VMInstruction
Definition: vm.h:58
@ OP_CALL
Definition: vm.h:67
@ JMP_IF_FALSE
Definition: vm.h:61
@ ASSIGN
Definition: vm.h:65
@ PUSH_VAR
Definition: vm.h:60
@ OP_UNARY
Definition: vm.h:63
@ PUSH_CONSTANT
Definition: vm.h:59
@ OP_BINARY
Definition: vm.h:64
@ OP_RETURN
Definition: vm.h:66
void serializeDouble(double d)
Definition: vm.h:104
void print_unaryDouble(const char *desc, size_t &i)
Definition: vm.h:118
void push(double constant)
Definition: vm.h:174
void serializeChar(char c)
Definition: vm.h:86
void call(SmartPtr< VMAdd > subfunction)
Definition: vm.h:231
int execute(double *ret, const double *in)
Definition: vm.h:497
void unary(int oper)
Definition: vm.h:207
void binary(int oper)
Definition: vm.h:215
int get_pos()
Definition: vm.h:202
void set_nr_of_variables(size_t nr)
Definition: vm.h:352
void print_short()
Definition: vm.h:255
double call(double a)
Definition: vm.h:538
size_t m_nrOut
Definition: vm.h:54
double call(double *stack, int &SP)
Definition: vm.h:404
int jmp_if_false()
Definition: vm.h:190
size_t num_in()
Definition: vm.h:550
void ret()
Definition: vm.h:250
void execute_binary(size_t &i, double *stack, int SP)
Definition: vm.h:376
void print()
Definition: vm.h:261
void print_unaryInt(const char *desc, size_t &i)
Definition: vm.h:124
void set_name(std::string name)
Definition: vm.h:169
double call_sub(double *stack, int &SP)
Definition: vm.h:489
void adjust_jmp_pos(int iPos, int jmpPos)
Definition: vm.h:243
void serializeVMInstr(VMInstruction inst)
Definition: vm.h:72
size_t m_nrIn
Definition: vm.h:54
void set_in_out(size_t nrIn, size_t nrOut)
Definition: vm.h:347
void push_var(int i)
Definition: vm.h:182
VMAdd()
Definition: vm.h:165
void execute_unary(size_t &i, double &v)
Definition: vm.h:357
void deserializeInt(size_t &p, int &i)
Definition: vm.h:98
std::vector< double > variables
Definition: vm.h:53
void assign(int v)
Definition: vm.h:223
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_LOG(msg)
Definition: log.h:367
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
#define LUAPARSER_MATH_CEIL
Definition: parser.cpp:134
#define LUAPARSER_NE
Definition: parser.cpp:144
#define LUAPARSER_MATH_SQRT
Definition: parser.cpp:132
#define LUAPARSER_MATH_MAX
Definition: parser.cpp:136
#define LUAPARSER_MATH_COS
Definition: parser.cpp:127
#define LUAPARSER_MATH_LOG
Definition: parser.cpp:130
#define LUAPARSER_MATH_FLOOR
Definition: parser.cpp:133
#define LUAPARSER_MATH_EXP
Definition: parser.cpp:128
#define LUAPARSER_MATH_SIN
Definition: parser.cpp:126
#define LUAPARSER_MATH_POW
Definition: parser.cpp:135
#define LUAPARSER_OR
Definition: parser.cpp:142
#define LUAPARSER_EQ
Definition: parser.cpp:145
#define LUAPARSER_AND
Definition: parser.cpp:143
#define LUAPARSER_GE
Definition: parser.cpp:147
#define LUAPARSER_MATH_LOG10
Definition: parser.cpp:131
#define LUAPARSER_MATH_ABS
Definition: parser.cpp:129
#define LUAPARSER_MATH_MIN
Definition: parser.cpp:137
#define LUAPARSER_LE
Definition: parser.cpp:146