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();
67int Func0Op(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
71int Func1Op(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
75int Func2Op(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
79int Func3Op(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
83int Func4Op(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
88int 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]]);
93int 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]]);
98int 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]];
106int Func1VOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
110int Func2VOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
115int Func1VVOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
117 double* out = &fp[opData[2]];
118 for (
int k = 0; k < 3; k++) out[k] = v[k];
121int Func2VVOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
123 double* out = &fp[opData[3]];
124 for (
int k = 0; k < 3; k++) out[k] = v[k];
127int FuncNVOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
130 for (
int k = 0; k < n; k++)
new (vals + k)
Vec3d(
Vec3dRef(&fp[opData[k + 2]]));
131 double* out = &fp[opData[n + 2]];
135int FuncNVVOp(
int* opData,
double* fp,
char** c, std::vector<int>& callStack) {
138 for (
int k = 0; k < n; k++)
new (vals + k)
Vec3d(
Vec3dRef(&fp[opData[k + 2]]));
139 double* out = &fp[opData[n + 2]];
141 for (
int k = 0; k < 3; k++) out[k] = val[k];
146 std::vector<int> argOps;
149 argOps.push_back(op);
153 int funcPtrLoc = interpreter->
allocPtr();
154 interpreter->
s[funcPtrLoc] = (
char*)
_func;
206 for (
int k = 0; k < node->
type().dim(); k++) {
207 interpreter->
addOp(op);
210 for (
size_t c = 0; c < argOps.size(); c++) {
217 interpreter->
endOp();
221 for (
size_t c = 0; c < argOps.size(); c++)
223 int promotedArgOp = interpreter->
allocFP(3);
227 interpreter->
endOp();
228 argOps[c] = promotedArgOp;
232 interpreter->
addOp(op);
235 for (
size_t c = 0; c < argOps.size(); c++) {
239 interpreter->
endOp();
242 std::cerr <<
"Interpreter dump" << std::endl;
243 interpreter->
print();
Node that calls a function.
virtual int buildInterpreter(const ExprFuncNode *node, Interpreter *interpreter) const
Build an interpreter to evaluate the expression.
Vec3d Func1vv(const Vec3d &)
double Func1v(const Vec3d &)
double Func2(double, double)
Vec3d Func2vv(const Vec3d &, const Vec3d &)
double Func5(double, double, double, double, double)
double Func6(double, double, double, double, double, double)
double Func2v(const Vec3d &, const Vec3d &)
double Func3(double, double, double)
double Func4(double, double, double, double)
virtual ExprType prep(ExprFuncNode *node, bool scalarWanted, ExprVarEnvBuilder &envBuilder) const
double Funcn(int n, double *params)
double Funcnv(int n, const Vec3d *params)
Vec3d Funcnvv(int n, const Vec3d *params)
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
int numChildren() const
Number of children.
const ExprNode * child(size_t i) const
Get 0 indexed child.
const ExprType & type() const
The type of the node.
bool checkIsFP(const ExprType &type, bool &error)
Checks if the type is a float[d] for any d.
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.
virtual ExprType prep(bool dontNeedScalar, ExprVarEnvBuilder &envBuilder)
ExprType & FP(int d)
Mutate this into a floating point type of dimension d.
bool isFP() const
Direct is predicate checks.
ExprType & setLifetime(const ExprType &a)
Assign the lifetime from type a to be my type.
ExprType & Error()
Mutate this into an error type.
Variable scope builder is used by the type checking and code gen to track visiblity of variables and ...
static bool debugging
Whether to debug expressions.
int allocFP(int n)
! Allocate a floating point set of data of dimension n
int addOp(OpF op)
! adds an operator to the program (pointing to the data at the current location)
int(*) OpF(int *, double *, char **, std::vector< int > &)
Op function pointer arguments are (int* currOpData,double* currD,char** c,std::stack<int>& callStacku...
int addOperand(int param)
! Adds an operand. Note this should be done after doing the addOp!
int allocPtr()
Allocate a pointer location (can be anything, but typically space for char*)
void endOp(bool execute=true)
std::vector< char * > s
constant and evaluated pointer data
void print(int pc=-1) const
Debug by printing program.
static Vec< double, d, false > copy(T2 *raw, INVALID_WITH_VECTOR_REFERENCE u=(TYPENAME my_enable_if<!ref, INVALID_WITH_VECTOR_REFERENCE >::TYPE()))
int Func1VVOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func5Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
int FuncNVOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func6Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func4Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func0Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
Vec< double, 3, false > Vec3d
int Func3Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func1VOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func2Op(int *opData, double *fp, char **c, std::vector< int > &callStack)
int FuncNVVOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
int FuncNOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
Vec< double, 3, true > Vec3dRef
int Func2VOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func2VVOp(int *opData, double *fp, char **c, std::vector< int > &callStack)
int Func1Op(int *opData, double *fp, char **c, std::vector< int > &callStack)