51 : _expr(
expr), _parent(0), _isVec(0), _type(type) {
63 : _expr(
expr), _parent(0), _isVec(0), _type(type) {
77 : _expr(
expr), _parent(0), _isVec(0), _type(type) {
86 std::vector<ExprNode*>::iterator
iter;
92 child->_parent =
this;
96 std::vector<ExprNode*>::iterator
iter;
152 std::cerr <<
"after create localvar phi " << localVar->
getPhi() << std::endl;
156 checkCondition(
false,
"Prototypes are currently not supported", error);
211 "In function result of block '" +
blockType.toString() +
212 "' does not match given return type " +
prototype->returnType().toString(),
226 checkCondition(
false,
"Local functions are currently not supported.", error);
242 "Incorrect number of arguments to function call",
253 callerNode->checkCondition(
false,
"Local functions are currently not supported.", error);
344 double first =
f->value();
346 double second = s->value();
348 double third =
t->value();
492 if (!
phi->_thenVar->type().isError() && !
phi->_elseVar->type().isError()) {
493 addError(std::string(
"Variable ") +
name() +
" defined in conditionals inconsistently.");
587 child(arg)->addError(
"Expected " +
type.toString() +
" for argument, got " +
childType.toString());
std::string unescapeString(const std::string &string)
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
const ExprLocalVar * localVar() const
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Node that calls a function.
const ExprLocalFunctionNode * _localFunc
std::vector< int > _promote
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
bool checkArg(int argIndex, ExprType type, ExprVarEnvBuilder &envBuilder)
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
Extension function spec, used for complicated argument custom functions.
virtual ExprType prep(ExprFuncNode *node, bool scalarWanted, ExprVarEnvBuilder &env) const =0
static const ExprFunc * lookup(const std::string &name)
Lookup a builtin function by name.
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Node that contains local function.
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Preps the definition of this site.
const ExprPrototypeNode * prototype() const
TODO: Accessor for prototype (probably not needed when we use prep right)
ExprLocalVar join (merge) references. Remembers which variables are possible assigners to this.
ExprLocalVar reference, all local variables in seexpr are subclasses of this or this itself.
const ExprLocalVar * getPhi() const
get the primary representative phi node (i.e. the global parent of a dependent phi node)
ExprType type() const
returns type of the variable
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
void setTypeWithChildLife(const ExprType &t)
Set's the type to the argument but uses the children to determine lifetime.
std::vector< ExprNode * > _children
List of children.
bool checkIsValue(const ExprType &type, bool &error)
Checks if the type is a value (i.e. string or float[d])
void addChildren(ExprNode *surrogate)
Transfer children from surrogate parent (for parser use only)
void addError(const std::string &error) const
Register error. This will allow users and sophisticated editors to highlight where in code problem wa...
void addChild(ExprNode *child)
Add a child to the child list (for parser use only)
void setType(const ExprType &t)
Set type of parameter.
int numChildren() const
Number of children.
bool checkTypesCompatible(const ExprType &first, const ExprType &second, bool &error)
types match (true if they do)
ExprNode(const Expression *expr)
const ExprNode * child(size_t i) const
Get 0 indexed child.
const ExprType & type() const
The type of the node.
const Expression * _expr
Owning expression (node can't modify)
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)
Node that stores a numeric constant.
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Node that contains prototype of function.
ExprType returnType() const
void addArgs(ExprNode *surrogate)
void addArgTypes(ExprNode *surrogate)
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
std::vector< ExprType > _argTypes
const std::string & name() const
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
ExprStrNode(const Expression *expr, const char *str)
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
static bool valuesCompatible(const ExprType &a, const ExprType &b)
Checks if value types are compatible.
ExprType & FP(int d)
Mutate this into a floating point type of dimension d.
std::string toString() const
Stringify the type into a printable string.
ExprType & String()
Mutate this into a string type.
ExprType & setLifetime(const ExprType &a)
Assign the lifetime from type a to be my type.
ExprType & Error()
Mutate this into an error type.
ExprType & Constant()
Mutate this into a constant lifetime.
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Variable scope builder is used by the type checking and code gen to track visiblity of variables and ...
Variable scope for tracking variable lookup.
Node that references a variable.
const char * name() const
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual ExprType type() const
returns (current) type
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
A class that lets you register for the variables used by one or more expressions.
Vec< double, 3, false > Vec3d
</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")
</pre > there might be errors in the expression you must check with isValid() before you can evaluate. Then you can print a parse error as well< pre > if(!expr.isValid())
Defined as a *alpha b *alpha< br ></div >< br > float< b > float a
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)