44 d = std::move(other.d);
45 s = std::move(other.s);
57 double*&
Pointer(uint32_t variableOffset) {
return reinterpret_cast<double*&
>(
_dataPtrs[variableOffset]); }
58 char**&
CharPointer(uint32_t variableOffset) {
return reinterpret_cast<char**&
>(
_dataPtrs[variableOffset]); }
68 std::vector<double>
d;
96 void eval(
double*)
override { assert(
false); }
97 void eval(
const char**)
override { assert(
false); }
103 throw std::runtime_error(
"Already registered a variable named " + name);
107 _vars.insert(std::make_pair(name,
Ref(type, offset, type.
dim())));
128 if (
it !=
_vars.end())
return const_cast<Ref*
>(&
it->second);
abstract class for implementing variable references
virtual ExprType type() const
returns (current) type
Internally implemented var ref used by SeExpr.
void eval(const char **) override
Ref(const ExprType &type, uint32_t offset, uint32_t stride)
void eval(double *) override
returns this variable's value by setting result
A class that lets you register for the variables used by one or more expressions.
ExprVarRef * resolveVar(const std::string &name) const
Resolve the variable using anything in the data block (call from resolveVar in Expr subclass)
VarBlock create(bool makeThreadSafe=false)
int registerVariable(const std::string &name, const ExprType type)
Register a variable and return a handle.
std::map< std::string, Ref > _vars
A thread local evaluation context. Just allocate and fill in with data.
std::vector< double > d
copy of Interpreter's double data
int indirectIndex
indirect index to add to pointer based data
char ** data()
Raw data of the data block pointer (used by compiler)
double *& Pointer(uint32_t variableOffset)
Get a reference to the data block pointer which can be modified.
std::vector< char * > _dataPtrs
This stores double* or char** ptrs to variables.
char **& CharPointer(uint32_t variableOffset)
VarBlock & operator=(const VarBlock &)=delete
bool threadSafe
if true, interpreter's data will be copied to this instance before evaluation.
std::vector< char * > s
copy of Interpreter's str data
VarBlock(VarBlock &&other)
Move semantics is the only allowed way to change the structure.
VarBlock(int size, bool makeThreadSafe)
Allocate an VarBlock.
VarBlock(const VarBlock &)=delete
Don't allow copying and operator='ing'.
you may not use this file except in compliance with the License and the following modification to it