17 #ifndef _Interpreter_h_
18 #define _Interpreter_h_
30 static int f(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
31 int posIn = opData[0];
32 int posOut = opData[1];
33 for (
int k = posOut; k < posOut + d; k++) fp[k] = fp[posIn];
43 std::vector<double>
d;
50 typedef std::map<const ExprLocalVar*, int>
VarToLoc;
54 typedef int (*
OpF)(
int*,
double*,
char**, std::vector<int>&);
56 std::vector<std::pair<OpF, int> >
ops;
75 assert(
false &&
"addOp called within another addOp");
79 ops.push_back(std::make_pair(op,
opData.size()));
83 void endOp(
bool execute =
true) {
88 int pc =
ops.size() - 1;
89 const std::pair<OpF, int>& op =
ops[pc];
90 int* opCurr = &
opData[0] + op.second;
91 pc += op.first(opCurr, fp, str,
callStack);
106 for (
int k = 0; k < n; k++)
d.push_back(0);
120 void print(
int pc = -1)
const;
162 assert(
false &&
"Invalid dynamic parameter (not supported template)");
std::vector< int > callStack
int allocFP(int n)
! Allocate a floating point set of data of dimension n
A thread local evaluation context. Just allocate and fill in with data.
int nextPC()
Return the position that the next instruction will be placed at.
std::vector< char * > s
constant and evaluated pointer data
void print(int pc=-1) const
Debug by printing program.
T_FUNCTYPE getTemplatizedOp(int i)
Return the function f encapsulated in class T for the dynamic i converted to a static d...
with numParticles numAttributes A variable block contains variable names and types but doesn t care what the values are< pre > void f(const std::string &s, MyParticleData *p, int outputDim=3)
int allocPtr()
Allocate a pointer location (can be anything, but typically space for char*)
std::vector< std::pair< OpF, int > > ops
void eval(VarBlock *varBlock, bool debug=false)
Evaluate program.
int addOperand(int param)
! Adds an operand. Note this should be done after doing the addOp!
int addOp(OpF op)
! adds an operator to the program (pointing to the data at the current location)
std::map< const ExprLocalVar *, int > VarToLoc
Not needed for eval only building.
std::vector< double > d
Double data (constants and evaluated)
void endOp(bool execute=true)
std::vector< int > opData
Ooperands to op.
int(* OpF)(int *, double *, char **, std::vector< int > &)
Op function pointer arguments are (int* currOpData,double* currD,char** c,std::stack<int>& callStacku...
void setPCStart(int pcStart)