Go to the documentation of this file.
22 #ifndef BasicExpression_h
23 #define BasicExpression_h
36 void eval(
const char** result) { assert(
false); }
42 void eval(
double* result) {
43 for (
int k = 0; k < 3; k++) result[k] =
value[k];
45 void eval(
const char** result) {
59 for (
int i = 0; i < nargs; i++)
69 double* out = &args.
outFp;
70 for (
int i = 0; i < 3; i++) out[i] = 0.0;
79 typedef std::map<std::string, VectorRef*>
VARMAP;
81 typedef std::map<std::string, bool>
FUNCMAP;
89 void setExpr(
const std::string& str);
std::map< std::string, VectorRef * > VARMAP
virtual SeExpr2::ExprFuncNode::Data * evalConstant(const SeExpr2::ExprFuncNode *node, ArgHandle args) const
std::map< std::string, bool > FUNCMAP
ExprType & FP(int d)
Mutate this into a floating point type of dimension d.
void setExpr(const std::string &str)
int numChildren() const
Number of children.
SeExpr2::ExprFunc * resolveFunc(const std::string &name) const
virtual void eval(ArgHandle args)
ExprType & Varying()
Mutate this into a varying lifetime.
ExprType & Constant()
Mutate this into a constant lifetime.
Node that calls a function.
Function Definition, used in parse tree and func table.
BasicExpression::DummyFuncX dummyFuncX
SeExpr2::ExprFunc dummyFunc
ExprType & Error()
Mutate this into an error type.
void eval(const char **result)
Variable scope builder is used by the type checking and code gen to track visiblity of variables and ...
bool checkArg(int argIndex, ExprType type, ExprVarEnvBuilder &envBuilder)
ExprFuncSimple(const bool threadSafe)
virtual ~BasicExpression()
void eval(const char **result)
SeExpr2::ExprVarRef * resolveVar(const std::string &name) const
void eval(double *result)
returns this variable's value by setting result
virtual SeExpr2::ExprType prep(SeExpr2::ExprFuncNode *node, bool scalarWanted, SeExpr2::ExprVarEnvBuilder &envBuilder) const
base class for custom instance data
void eval(double *result)
returns this variable's value by setting result
abstract class for implementing variable references
</pre >< h3 > Binding our variable reference</h3 > If we now tried to use the variable would still not be found by our expressions To make it bindable we need to override the resolveVar() function as follows</pre >< h3 > Variable setting</h3 > Next we need to make a way of setting the variable As the controlling code will use the expression it will repeatedly alternate between setting the independent variables that are used and calling evaluate(). What it has to do depends very much on the application. In this case we only need to set the independent variable x as</pre >< h2 > Evaluating expressions</h2 > Evaluating an expression is pretty easy But before we can do that we need to make an instance< pre > GrapherExpr expr("x+x^2")
BasicExpression(const std::string &expr, const SeExpr2::ExprType &type=SeExpr2::ExprType().FP(3))