15#include "ExprConfig.h"
33 std::cerr <<
"KSeExpr Debug Mode Enabled " <<
41#if defined(SEEXPR_ENABLE_LLVM)
79 std::cerr <<
"return slot " <<
_returnSlot << std::endl;
171#ifdef SEEXPR_PERFORMANCE
196 std::cerr <<
"Eval strategy is interpreter" << std::endl;
216 std::cerr <<
"Eval strategy is llvm" << std::endl;
233 std::vector<int>
lines;
237 if (*
p ==
'\n')
lines.push_back(
static_cast<int>(
p - start));
240 lines.push_back(
static_cast<int>(
p - start));
243 for (
unsigned int i = 0;
i <
_errors.size();
i++) {
254 std::cerr <<
"ending with isValid " <<
_isValid << std::endl;
255 std::cerr <<
"parse error \n" <<
_parseError << std::endl;
279 static double noCrash[16] = {};
292 varBlock->indirectIndex =
static_cast<int>(
i);
294 for (
int k = 0;
k < dim;
k++) {
static constexpr std::array< int, 514 > p
static void init()
call to define built-in funcs
virtual ExprType prep(bool dontNeedScalar, ExprVarEnvBuilder &envBuilder)
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.
void addError(const ErrorCode error, const std::vector< std::string > &ids={}) const
Register error. This will allow users and sophisticated editors to highlight where in code problem wa...
bool isVec() const
True if node has a vector result.
std::string toString() const
Stringify the type into a printable string.
ExprType & Error()
Mutate this into an error type.
bool isFP() const
Direct is predicate checks.
static bool valuesCompatible(const ExprType &a, const ExprType &b)
Checks if value types are compatible.
void reset()
Reset to factory state (one empty environment that is current)
const VarBlockCreator * _varBlockCreator
void evalMultiple(VarBlock *varBlock, int outputVarBlockOffset, size_t rangeStart, size_t rangeEnd) const
Evaluate multiple blocks.
ErrorCode _parseErrorCode
void setExpr(const std::string &e)
static bool debugging
Whether to debug expressions.
std::set< std::string > _vars
bool usesFunc(const std::string &name) const
void parseIfNeeded() const
EvaluationStrategy _evaluationStrategy
Expression(EvaluationStrategy be=Expression::defaultEvaluationStrategy)
void addError(const ErrorCode error, const std::vector< std::string > ids, const int startPos, const int endPos) const
std::set< std::string > _funcs
bool usesVar(const std::string &name) const
Interpreter * _interpreter
std::vector< std::string > _parseErrorIds
const double * evalFP(VarBlock *varBlock=nullptr) const
void prepIfNeeded() const
EvaluationStrategy
Types of evaluation strategies that are available.
void debugPrintParseTree() const
void setContext(const Context &context)
ExprVarEnvBuilder _envBuilder
void debugPrintInterpreter() const
const ExprType & returnType() const
std::vector< std::pair< int, int > > _comments
const Context & context() const
const char * evalStr(VarBlock *varBlock=nullptr) const
std::vector< Error > _errors
void setVarBlockCreator(const VarBlockCreator *varBlockCreator)
ExprType _desiredReturnType
std::vector< std::string > _threadUnsafeFunctionCalls
void setDesiredReturnType(const ExprType &type)
static EvaluationStrategy defaultEvaluationStrategy
What evaluation strategy to use by default.
void debugPrintLLVM() const
LLVMEvaluator * _llvmEvaluator
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< char * > s
constant and evaluated pointer data
int allocFP(int n)
! Allocate a floating point set of data of dimension n
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.
static bool prepLLVM(ExprNode *, ExprType)
static const double * evalFP(VarBlock *)
static const char * evalStr(VarBlock *)
static void evalMultiple(VarBlock *, int, size_t, size_t)
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.
static Expression::EvaluationStrategy chooseDefaultEvaluationStrategy()
bool ExprParse(KSeExpr::ExprNode *&parseTree, KSeExpr::ErrorCode &errorCode, std::vector< std::string > &errorIds, int &errorStart, int &errorEnd, std::vector< std::pair< int, int > > &_comments, const KSeExpr::Expression *expr, const char *str, bool wantVec=true)
@ ExpressionIncompatibleTypes
"Expression generated type " << _parseTree->type() << " incompatible with desired type " << _desiredR...