25#include "ExprConfig.h"
48 std::cerr <<
"SeExpr2 Debug Mode Enabled " <<
56#ifdef SEEXPR_ENABLE_LLVM
84 std::cout <<
buf <<
"'" <<
examinee->toString() <<
"' " <<
typeid(*examinee).name()
85 <<
" type=" <<
examinee->type().toString() << std::endl;
92 _desiredReturnType(
ExprType().FP(3).Varying()), _parseTree(0), _isValid(0), _parsed(0), _prepped(0),
102 _desiredReturnType(type), _parseTree(0), _isValid(0), _parsed(0), _prepped(0), _interpreter(0),
115 std::cerr <<
"return slot " <<
_returnSlot << std::endl;
206#ifdef SEEXPR_PERFORMANCE
231 std::cerr <<
"Eval strategy is interpreter" << std::endl;
251 std::cerr <<
"Eval strategy is llvm" << std::endl;
268 std::vector<int>
lines;
272 if (*p ==
'\n')
lines.push_back(
static_cast<int>(p - start));
275 lines.push_back(
static_cast<int>(p - start));
278 for (
unsigned int i = 0;
i <
_errors.size();
i++) {
289 std::cerr <<
"ending with isValid " <<
_isValid << std::endl;
290 std::cerr <<
"parse error \n" <<
parseError() << std::endl;
314 static double noCrash[16] = {};
327 varBlock->indirectIndex =
static_cast<int>(
i);
329 for (
int k = 0;
k < dim;
k++) {
static void init()
call to define built-in funcs and load standard plugins
bool isVec() const
True if node has a vector result.
void addError(const std::string &error) const
Register error. This will allow users and sophisticated editors to highlight where in code problem wa...
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
const ExprType & type() const
The type of the node.
virtual ExprType prep(bool dontNeedScalar, ExprVarEnvBuilder &envBuilder)
static bool valuesCompatible(const ExprType &a, const ExprType &b)
Checks if value types are compatible.
std::string toString() const
Stringify the type into a printable string.
bool isFP() const
Direct is predicate checks.
ExprType & Error()
Mutate this into an error type.
void reset()
Reset to factory state (one empty environment that is current)
void parseIfNeeded() const
bool usesVar(const std::string &name) const
const Context & context() const
void setDesiredReturnType(const ExprType &type)
Interpreter * _interpreter
const VarBlockCreator * _varBlockCreator
std::vector< std::pair< int, int > > _comments
EvaluationStrategy
Types of evaluation strategies that are available.
Expression(EvaluationStrategy be=Expression::defaultEvaluationStrategy)
std::vector< Error > _errors
const char * evalStr(VarBlock *varBlock=nullptr) const
std::set< std::string > _funcs
EvaluationStrategy _evaluationStrategy
const ExprType & returnType() const
void setExpr(const std::string &e)
void addError(const std::string &error, const int startPos, const int endPos) const
LLVMEvaluator * _llvmEvaluator
bool usesFunc(const std::string &name) const
std::set< std::string > _vars
void setVarBlockCreator(const VarBlockCreator *varBlockCreator)
void evalMultiple(VarBlock *varBlock, int outputVarBlockOffset, size_t rangeStart, size_t rangeEnd) const
Evaluate multiple blocks.
const double * evalFP(VarBlock *varBlock=nullptr) const
void debugPrintLLVM() const
const std::string & parseError() const
void setContext(const Context &context)
ExprType _desiredReturnType
static EvaluationStrategy defaultEvaluationStrategy
What evaluation strategy to use by default.
void debugPrintInterpreter() const
static bool debugging
Whether to debug expressions.
void prepIfNeeded() const
std::vector< std::string > _threadUnsafeFunctionCalls
void debugPrintParseTree() const
ExprVarEnvBuilder _envBuilder
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)
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!
void endOp(bool execute=true)
std::vector< double > d
Double data (constants and evaluated)
std::vector< char * > s
constant and evaluated pointer data
void print(int pc=-1) const
Debug by printing program.
const char * evalStr(VarBlock *varBlock)
void evalMultiple(VarBlock *varBlock, int outputVarBlockOffset, size_t rangeStart, size_t rangeEnd)
bool prepLLVM(ExprNode *parseTree, ExprType desiredReturnType)
const double * evalFP(VarBlock *varBlock)
virtual bool examine(const SeExpr2::ExprNode *examinee)
A class that lets you register for the variables used by one or more expressions.
A thread local evaluation context. Just allocate and fill in with data.
SeExpr2::SPrintFuncX sprintf
static Expression::EvaluationStrategy chooseDefaultEvaluationStrategy()
bool ExprParse(SeExpr2::ExprNode *&parseTree, std::string &error, int &errorStart, int &errorEnd, std::vector< std::pair< int, int > > &_comments, const SeExpr2::Expression *expr, const char *str, bool wantVec=true)
If a scalar is used in a vector context
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)