30 bool multiInvoke = !scalarWanted;
34 int childDim = childType.
dim();
38 if (nonOneDim != 1 && childDim != nonOneDim) multiInvoke =
false;
43 return retType.
Error();
44 else if (multiInvoke && nonOneDim != 1)
45 return retType.
FP(nonOneDim);
53 int childDim = childType.
dim();
55 node->
child(c)->
checkCondition(childDim == 1 || childDim == 3,
"Expected float or FP[3]", error);
59 return retType.
Error();
67 int Func0Op(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
71 int Func1Op(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
75 int Func2Op(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
79 int Func3Op(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
83 int Func4Op(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
88 int Func5Op(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
90 fp[opData[1]], fp[opData[2]], fp[opData[3]], fp[opData[4]], fp[opData[5]]);
93 int Func6Op(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
95 fp[opData[1]], fp[opData[2]], fp[opData[3]], fp[opData[4]], fp[opData[5]], fp[opData[6]]);
98 int FuncNOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
100 double* vals =
static_cast<double*
>(alloca(n *
sizeof(
double)));
101 for (
int k = 0; k < n; k++) vals[k] = fp[opData[k + 2]];
102 double* out = &fp[opData[n + 2]];
106 int Func1VOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
110 int Func2VOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
114 int Func1VVOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
116 double* out = &fp[opData[2]];
117 for (
int k = 0; k < 3; k++) out[k] = v[k];
120 int Func2VVOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
122 double* out = &fp[opData[3]];
123 for (
int k = 0; k < 3; k++) out[k] = v[k];
126 int FuncNVOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
129 for (
int k = 0; k < n; k++)
new (vals+k)
Vec3d(
Vec3dRef(&fp[opData[k + 2]]));
130 double* out = &fp[opData[n + 2]];
134 int FuncNVVOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
137 for (
int k = 0; k < n; k++)
new (vals+k)
Vec3d(
Vec3dRef(&fp[opData[k + 2]]));
138 double* out = &fp[opData[n + 2]];
140 for (
int k = 0; k < 3; k++) out[k] = val[k];
145 std::vector<int> argOps;
148 argOps.push_back(op);
152 int funcPtrLoc = interpreter->
allocPtr();
153 interpreter->
s[funcPtrLoc] = (
char*)
_func;
205 for (
int k = 0; k < node->
type().
dim(); k++) {
206 interpreter->
addOp(op);
209 for (
size_t c = 0; c < argOps.size(); c++) {
216 interpreter->
endOp();
220 for (
size_t c = 0; c < argOps.size(); c++)
222 int promotedArgOp = interpreter->
allocFP(3);
226 interpreter->
endOp();
227 argOps[c] = promotedArgOp;
231 interpreter->
addOp(op);
234 for (
size_t c = 0; c < argOps.size(); c++) {
238 interpreter->
endOp();
241 std::cerr <<
"Interpreter dump" << std::endl;
242 interpreter->
print();
int allocFP(int n)
! Allocate a floating point set of data of dimension n
const ExprType & type() const
The type of the node.
static Vec< double, d, false > copy(T2 *raw, INVALID_WITH_VECTOR_REFERENCE u=(typename my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE >::TYPE()))
Initialize vector value using raw memory.
int Func3Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func1VVOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func2VVOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
double Func2v(const Vec3d &, const Vec3d &)
double Func3(double, double, double)
int FuncNVVOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
double Func1v(const Vec3d &)
std::vector< char * > s
constant and evaluated pointer data
bool isFP() const
Direct is predicate checks.
void print(int pc=-1) const
Debug by printing program.
double Funcnv(int n, const Vec3d *params)
Vec3d Funcnvv(int n, const Vec3d *params)
int FuncNOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
bool checkCondition(bool check, const std::string &message, bool &error)
Checks the boolean value and records an error string with node if it is false.
Vec3d Func1vv(const Vec3d &)
virtual ExprType prep(bool dontNeedScalar, ExprVarEnvBuilder &envBuilder)
double Func6(double, double, double, double, double, double)
Vec3d Func2vv(const Vec3d &, const Vec3d &)
int allocPtr()
Allocate a pointer location (can be anything, but typically space for char*)
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
ExprType & setLifetime(const ExprType &a)
Assign the lifetime from type a to be my type.
Vec< double, 3, true > Vec3dRef
Node that calls a function.
int FuncNVOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func4Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
static bool debugging
Whether to debug expressions.
Vec< double, 3, false > Vec3d
int addOperand(int param)
! Adds an operand. Note this should be done after doing the addOp!
int Func0Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func1VOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
virtual int buildInterpreter(const ExprFuncNode *node, Interpreter *interpreter) const
Build an interpreter to evaluate the expression.
int addOp(OpF op)
! adds an operator to the program (pointing to the data at the current location)
int Func6Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
double Funcn(int n, double *params)
int Func2Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
double Func5(double, double, double, double, double)
int numChildren() const
Number of children.
virtual ExprType prep(ExprFuncNode *node, bool scalarWanted, ExprVarEnvBuilder &envBuilder) const
void endOp(bool execute=true)
bool checkIsFP(const ExprType &type, bool &error)
Checks if the type is a float[d] for any d.
int Func1Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func5Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
double Func4(double, double, double, double)
const ExprNode * child(size_t i) const
Get 0 indexed child.
ExprType & FP(int d)
Mutate this into a floating point type of dimension d.
int Func2VOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
ExprType & Error()
Mutate this into an error type.
int(* OpF)(int *, double *, char **, std::vector< int > &)
Op function pointer arguments are (int* currOpData,double* currD,char** c,std::stack<int>& callStacku...
double Func2(double, double)
Variable scope builder is used by the type checking and code gen to track visiblity of variables and ...