20 static int f(
int* opData,
double* fp,
char**, std::vector<int>&) {
21 int posIn = opData[0];
22 int posOut = opData[1];
23 for (
int k = posOut; k < posOut + d; k++) fp[k] = fp[posIn];
33 std::vector<double>
d;
40 using VarToLoc = std::map<const ExprLocalVar *, int>;
44 using OpF = int (*)(
int *,
double *,
char **, std::vector<int> &);
46 std::vector<std::pair<OpF, int> >
ops;
60 int nextPC()
const {
return static_cast<int>(
ops.size()); }
65 assert(
false &&
"addOp called within another addOp");
68 int pc =
static_cast<int>(
ops.size());
69 ops.emplace_back(op,
static_cast<int>(
opData.size()));
73 void endOp(
bool execute =
true) {
78 int pc =
static_cast<int>(
ops.size()) - 1;
79 const std::pair<OpF, int>& op =
ops[pc];
80 int* opCurr = &
opData[0] + op.second;
81 pc += op.first(opCurr, fp, str,
callStack);
88 int ret =
static_cast<int>(
opData.size());
95 int ret =
static_cast<int>(
d.size());
96 for (
int k = 0; k < n; k++)
d.push_back(0);
102 int ret =
static_cast<int>(
s.size());
110 void print(
int pc = -1)
const;
152 assert(
false &&
"Invalid dynamic parameter (not supported template)");
std::vector< std::pair< OpF, int > > ops
std::vector< double > d
Double data (constants and evaluated)
int addOp(OpF op)
! adds an operator to the program (pointing to the data at the current location)
void eval(VarBlock *varBlock, bool debug=false)
Evaluate program.
void endOp(bool execute=true)
std::vector< int > callStack
void setPCStart(int pcStart)
std::map< const ExprLocalVar *, int > VarToLoc
Not needed for eval only building.
std::vector< char * > s
constant and evaluated pointer data
int allocFP(int n)
! Allocate a floating point set of data of dimension n
int(*)(int *, double *, char **, std::vector< int > &) OpF
Op function pointer arguments are (int* currOpData,double* currD,char** c,std::stack<int>& callStacku...
int nextPC() const
Return the position that the next instruction will be placed at.
int allocPtr()
Allocate a pointer location (can be anything, but typically space for char*)
std::vector< int > opData
Ooperands to op.
int addOperand(int param)
! Adds an operand. Note this should be done after doing the addOp!
void print(int pc=-1) const
Debug by printing program.
A thread local evaluation context. Just allocate and fill in with data.
T_FUNCTYPE getTemplatizedOp(int i)
Return the function f encapsulated in class T for the dynamic i converted to a static d.