30#include "ExprConfig.h"
209 s <<
"Expected Float[" << d <<
"]" << std::endl;
218 false,
"Type mismatch. First: " +
first.toString() +
" Second: " +
second.toString(), error);
365 const std::string&
name()
const {
509 const char*
str()
const {
return _str.c_str(); }
541 int nargs()
const {
return _nargs; }
544 double* scalarArgs()
const {
return &_scalarArgs[0]; }
545 Vec3d* vecArgs()
const {
return &_vecArgs[0]; }
548 Vec3d* evalArgs()
const;
551 Vec3d evalArg(
int n)
const;
virtual void eval(ArgHandle args)
Node that compute a local variable assignment.
const ExprType & assignedType() const
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
const ExprLocalVar * localVar() const
ExprAssignNode(const Expression *expr, const char *name, ExprNode *e)
const std::string & name() const
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
Node that implements an binary operator.
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
ExprBinaryOpNode(const Expression *expr, ExprNode *a, ExprNode *b, char op)
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
virtual ~ExprBinaryOpNode()
Node that computes local variables before evaluating expression.
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
ExprBlockNode(const Expression *expr, ExprNode *a, ExprNode *b)
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Node that implements a numeric/string comparison.
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
ExprCompareEqNode(const Expression *expr, ExprNode *a, ExprNode *b, char op)
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
Node that implements a numeric comparison.
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
char _op
_op '<' less-than, 'l' less-than-eq, '>' greater-than, 'g' greater-than-eq
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
ExprCompareNode(const Expression *expr, ExprNode *a, ExprNode *b, char op)
Node that evaluates a conditional (if-then-else) expression.
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
ExprCondNode(const Expression *expr, ExprNode *a, ExprNode *b, ExprNode *c)
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
Node that calls a function.
Data * getData() const
get associated blind data (returns 0 if none)
std::string getStrArg(int n) const
bool isStrArg(int n) const
const ExprLocalFunctionNode * _localFunc
const char * name() const
std::vector< int > _promote
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
bool checkArg(int argIndex, ExprType type, ExprVarEnvBuilder &envBuilder)
void setData(Data *data) const
associate blind data with this node (subsequently owned by this object)
ExprFuncNode(const Expression *expr, const char *name)
const ExprFunc * func() const
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
Function Definition, used in parse tree and func table.
Node that computes local variables before evaluating expression.
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
ExprIfThenElseNode(const Expression *expr, ExprNode *a, ExprNode *b, ExprNode *c)
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
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)
int buildInterpreter(Interpreter *interpreter) const
Build the interpreter.
ExprLocalFunctionNode(const Expression *expr, ExprPrototypeNode *prototype, ExprNode *block)
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
int buildInterpreterForCall(const ExprFuncNode *callerNode, Interpreter *interpreter) const
Build interpreter if we are called.
ExprLocalVar reference, all local variables in seexpr are subclasses of this or this itself.
Node that contains entire program.
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
ExprModuleNode(const Expression *expr)
Policy which provides all the AST Types for the parser.
ExprBinaryOpNode BinaryOp
ExprLocalFunctionNode LocalFunction
ExprPrototypeNode Prototype
ExprIfThenElseNode IfThenElse
ExprCompareEqNode CompareEq
void setTypeWithChildLife(const ExprType &t)
Set's the type to the argument but uses the children to determine lifetime.
bool _isVec
True if node has a vector result.
short int endPos() const
Access end position in input string.
std::vector< ExprNode * > _children
List of children.
bool isVec() const
True if node has a vector result.
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 removeLastChild()
Remove last child and delete the entry.
short int length() const
Access length of input string.
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)
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
void setType(const ExprType &t)
Set type of parameter.
int numChildren() const
Number of children.
ExprNode * _parent
Parent node (null if this the the root)
bool checkTypesCompatible(const ExprType &first, const ExprType &second, bool &error)
types match (true if they do)
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
const Expression * expr() const
Access expression.
const ExprNode * child(size_t i) const
Get 0 indexed child.
void setPosition(const short int startPos, const short int endPos)
Remember the line and column position in the input string.
unsigned short int _startPos
Position line and collumn.
const ExprNode * parent() const
Access parent node - root node has no parent.
void swapChildren(size_t i, size_t j)
Swap children, do not use unless you know what you are doing.
short int startPos() const
Access start position in input string.
ExprNode * child(size_t i)
Get 0 indexed child.
std::string toString() const
Access to original string representation of current expression.
bool checkIsFP(int d, const ExprType &type, bool &error)
Checks if the type is a float[d] for a specific d.
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.
unsigned short int _endPos
virtual ExprType prep(bool dontNeedScalar, ExprVarEnvBuilder &envBuilder)
Node that stores a numeric constant.
ExprNumNode(const Expression *expr, double val)
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
Node that contains prototype of function.
ExprType returnType() const
void addArgs(ExprNode *surrogate)
void addArgTypes(ExprNode *surrogate)
ExprPrototypeNode(const Expression *expr, const std::string &name)
void setReturnType(const ExprType &type)
const ExprNode * arg(int i) const
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
bool isReturnTypeSet() const
int buildInterpreter(Interpreter *interpreter) const
Build the interpreter.
std::vector< ExprType > _argTypes
ExprPrototypeNode(const Expression *expr, const std::string &name, const ExprType &retType)
const std::string & name() const
ExprType argType(int i) const
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
std::vector< int > _interpreterOps
int interpreterOps(int c) const
Return op for interpreter.
Node that stores a string.
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
void str(const char *newstr)
Node that evaluates a component of a vector.
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
ExprSubscriptNode(const Expression *expr, ExprNode *a, ExprNode *b)
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
static bool valuesCompatible(const ExprType &a, const ExprType &b)
Checks if value types are compatible.
ExprType & setLifetime(const ExprType &a)
Assign the lifetime from type a to be my type.
ExprType & Error()
Mutate this into an error type.
ExprType & Varying()
Mutate this into a varying lifetime.
ExprType & Constant()
Mutate this into a constant lifetime.
NOde that computes with a single operand.
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
ExprUnaryOpNode(const Expression *expr, ExprNode *a, char op)
Construct with specific op ('!x' is logical negation, '~x' is 1-x, '-x' is -x)
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.
ExprVarNode(const Expression *expr, const char *name, const ExprType &type)
const ExprLocalVar * localVar() const
const ExprVarRef * var() const
ExprVarNode(const Expression *expr, const char *name)
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
const char * name() const
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
abstract class for implementing variable references
Node that constructs a vector from three scalars.
ExprVecNode(const Expression *expr)
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
Vec< double, 3, false > Vec3d
base class for custom instance data
Defined as a *alpha b *alpha< br ></div >< br > float< b > float a