12#include "ExprConfig.h"
110 return static_cast<int>(
_children.size());
200 for (
int i = 1;
i <
num;
i++)
325 const std::string &
name()
const
427 const std::string &
name()
const
591 return _name.c_str();
680 return _name.c_str();
689 int nargs()
const {
return _nargs; }
692 double* scalarArgs()
const {
return &_scalarArgs[0]; }
693 Vec3d* vecArgs()
const {
return &_vecArgs[0]; }
696 Vec3d* evalArgs()
const;
699 Vec3d evalArg(
int n)
const;
782 using Ptr = std::unique_ptr<Base *>;
void eval(ArgHandle args) override
Node that compute a local variable assignment.
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
const std::string & name() const
ExprAssignNode(const Expression *expr, const char *name, ExprNode *e)
const ExprType & assignedType() const
const ExprLocalVar * localVar() const
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
Node that implements an binary operator.
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
ExprBinaryOpNode(const ExprBinaryOpNode &)=default
ExprBinaryOpNode & operator=(const ExprBinaryOpNode &)=default
ExprBinaryOpNode & operator=(ExprBinaryOpNode &&)=default
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
ExprBinaryOpNode(const Expression *expr, ExprNode *a, ExprNode *b, char op)
~ExprBinaryOpNode() override
ExprBinaryOpNode(ExprBinaryOpNode &&)=default
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
Node that computes local variables before evaluating expression.
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
ExprBlockNode(const Expression *expr, ExprNode *a, ExprNode *b)
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
Node that implements a numeric/string comparison.
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
ExprCompareEqNode(const Expression *expr, ExprNode *a, ExprNode *b, char op)
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
Node that implements a numeric comparison.
char _op
_op '<' less-than, 'l' less-than-eq, '>' greater-than, 'g' greater-than-eq
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
ExprCompareNode(const Expression *expr, ExprNode *a, ExprNode *b, char op)
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
Node that evaluates a conditional (if-then-else) expression.
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
ExprCondNode(const Expression *expr, ExprNode *a, ExprNode *b, ExprNode *c)
Node that calls a function.
bool isStrArg(int n) const
bool checkArg(int argIndex, const ExprType &type, ExprVarEnvBuilder &envBuilder)
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
void setData(Data *data) const
associate blind data with this node (subsequently owned by this object)
ExprFuncNode(const Expression *expr, const char *name)
ExprFuncNode & operator=(const ExprFuncNode &)=default
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
std::vector< int > _promote
Data * getData() const
get associated blind data (returns 0 if none)
ExprFuncNode(ExprFuncNode &&)=default
std::string getStrArg(int n) const
const ExprFunc * func() const
ExprFuncNode(const ExprFuncNode &)=default
const char * name() const
ExprFuncNode & operator=(ExprFuncNode &&)=default
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
const ExprLocalFunctionNode * _localFunc
Function Definition, used in parse tree and func table.
Node that computes local variables before evaluating expression.
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
ExprIfThenElseNode(const Expression *expr, ExprNode *a, ExprNode *b, ExprNode *c)
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
Node that contains local function.
int buildInterpreter(Interpreter *interpreter) const override
Build the interpreter.
int buildInterpreterForCall(const ExprFuncNode *callerNode, Interpreter *interpreter) const
Build interpreter if we are called.
const ExprPrototypeNode * prototype() const
TODO: Accessor for prototype (probably not needed when we use prep right)
ExprLocalFunctionNode(const Expression *expr, ExprPrototypeNode *prototype, ExprNode *block)
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
Preps the definition of this site.
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
ExprLocalVar reference, all local variables in seexpr are subclasses of this or this itself.
Node that contains entire program.
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
ExprModuleNode(const Expression *expr)
Policy which provides all the AST Types for the parser.
std::unique_ptr< Base * > Ptr
void addChildren(ExprNode *surrogate)
Transfer children from surrogate parent (for parser use only)
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BASE
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.
virtual ExprType prep(bool dontNeedScalar, ExprVarEnvBuilder &envBuilder)
void swapChildren(size_t i, size_t j)
Swap children, do not use unless you know what you are doing.
std::string toString() const
Access to original string representation of current expression.
unsigned short int endPos() const
Access end position in input string.
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
bool _isVec
True if node has a vector result.
ExprNode * child(size_t i)
Get 0 indexed child.
bool checkIsFP(const ExprType &type, bool &error) const
Checks if the type is a float[d] for any d.
void setTypeWithChildLife(const ExprType &t)
Set's the type to the argument but uses the children to determine lifetime.
unsigned short int startPos() const
Access start position in input string.
bool checkIsFP(int d, const ExprType &type, bool &error) const
Checks if the type is a float[d] for a specific d.
const ExprType & type() const
The type of the node.
int numChildren() const
Number of children.
bool checkCondition(bool check, const ErrorCode message, const std::vector< std::string > &ids, bool &error) const
Checks the boolean value and records an error string with node if it is false.
void removeLastChild()
Remove last child and delete the entry.
unsigned short int _endPos
std::vector< ExprNode * > _children
List of children.
bool checkIsValue(const ExprType &type, bool &error) const
Checks if the type is a value (i.e. string or float[d])
const ExprNode * child(size_t i) const
Get 0 indexed child.
const Expression * expr() const
Access expression.
bool checkTypesCompatible(const ExprType &first, const ExprType &second, bool &error) const
types match (true if they do)
const ExprNode * parent() const
Access parent node - root node has no parent.
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...
ExprNode * _parent
Parent node (null if this the the root)
const Expression * _expr
Owning expression (node can't modify)
void setType(const ExprType &t)
Set type of parameter.
bool isVec() const
True if node has a vector result.
void addChild(ExprNode *child)
Add a child to the child list (for parser use only)
unsigned short int length() const
Access length of input string.
Node that stores a numeric constant.
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
ExprNumNode(const Expression *expr, double val)
Node that contains prototype of function.
std::vector< ExprType > _argTypes
void addArgs(ExprNode *surrogate)
ExprType returnType() const
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
int interpreterOps(int c) const
Return op for interpreter.
ExprPrototypeNode(const Expression *expr, const std::string &name)
void setReturnType(const ExprType &type)
ExprType argType(int i) const
int buildInterpreter(Interpreter *interpreter) const override
Build the interpreter.
const ExprNode * arg(int i) const
void addArgTypes(ExprNode *surrogate)
bool isReturnTypeSet() const
const std::string & name() const
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
std::vector< int > _interpreterOps
ExprPrototypeNode(const Expression *expr, const std::string &name, const ExprType &retType)
Node that stores a string.
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
void str(const char *newstr)
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
Node that evaluates a component of a vector.
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
ExprSubscriptNode(const Expression *expr, ExprNode *a, ExprNode *b)
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
ExprType & Constant()
Mutate this into a constant lifetime.
ExprType & Varying()
Mutate this into a varying lifetime.
ExprType & setLifetime(const ExprType &a)
Assign the lifetime from type a to be my type.
ExprType & Error()
Mutate this into an error type.
static bool valuesCompatible(const ExprType &a, const ExprType &b)
Checks if value types are compatible.
NOde that computes with a single operand.
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
ExprUnaryOpNode(const Expression *expr, ExprNode *a, char op)
Construct with specific op ('!x' is logical negation, '~x' is 1-x, '-x' is -x)
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
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 ExprLocalVar * localVar() const
ExprVarNode(const Expression *expr, const char *name, const ExprType &type)
ExprVarNode(const Expression *expr, const char *name)
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
const ExprVarRef * var() const
const char * name() const
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
abstract class for implementing variable references
Node that constructs a vector from three scalars.
ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder) override
LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
ExprVecNode(const Expression *expr)
int buildInterpreter(Interpreter *interpreter) const override
builds an interpreter. Returns the location index for the evaluated data
@ ExpectedStringOrFloatAnyD
"Expected String or Float[d]"
@ ExpectedFloatAnyD
"Expected Float[d]"
@ ExpectedFloatD
"Expected Float[" << d << "]"
@ TypeMismatch12
"Type mismatch. First: " << first << " Second: " << second
Vec< double, 3, false > Vec3d
base class for custom instance data
Data & operator=(Data &&)=default
Data(const Data &)=default
Data & operator=(const Data &)=default