SeExpr
ExprNode.h
Go to the documentation of this file.
1/*
2 Copyright Disney Enterprises, Inc. All rights reserved.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License
6 and the following modification to it: Section 6 Trademarks.
7 deleted and replaced with:
8
9 6. Trademarks. This License does not grant permission to use the
10 trade names, trademarks, service marks, or product names of the
11 Licensor and its affiliates, except as required for reproducing
12 the content of the NOTICE file.
13
14 You may obtain a copy of the License at
15 http://www.apache.org/licenses/LICENSE-2.0
16*/
17
18#ifndef ExprNode_h
19#define ExprNode_h
20
21#include <cstdlib>
22
23// TODO: get rid of makedepends everywhere
24#ifndef MAKEDEPEND
25#include <string.h>
26#include <string>
27#include <vector>
28#endif
29
30#include "ExprConfig.h"
31#include "ExprLLVM.h"
32#include "Expression.h"
33#include "ExprType.h"
34#include "ExprEnv.h"
35#include "Vec.h"
36#include "Interpreter.h"
37
38namespace SeExpr2 {
39class ExprFunc;
40class ExprFuncX;
41
72class ExprNode {
73 public:
74 ExprNode(const Expression* expr);
75 ExprNode(const Expression* expr, const ExprType& type);
78 ExprNode(const Expression* expr, ExprNode* a, const ExprType& type);
84 virtual ~ExprNode();
85
87
91
93 virtual int buildInterpreter(Interpreter* interpreter) const;
95
97
99 bool isVec() const { return _isVec; }
100
102 const Expression* expr() const { return _expr; }
103
105 std::string toString() const {
106 return expr()->getExpr().substr(startPos(), length());
107 };
108
110
112 const ExprNode* parent() const { return _parent; }
114 int numChildren() const { return static_cast<int>(_children.size()); }
115
117 const ExprNode* child(size_t i) const { return _children[i]; }
118
120 ExprNode* child(size_t i) { return _children[i]; }
121
123 void swapChildren(size_t i, size_t j) {
124 assert(i != j && i < _children.size() && j < _children.size());
125 std::swap(_children[i], _children[j]);
126 }
127
130 if (_children.size()) {
131 delete _children.back();
132 _children.pop_back();
133 }
134 }
135
137 void addChild(ExprNode* child);
138
141
143
145 const ExprType& type() const {
146 return _type;
147 };
148
150
152 inline void setPosition(const short int startPos, const short int endPos) {
154 _endPos = endPos;
155 }
157 inline short int startPos() const { return _startPos; }
159 inline short int endPos() const { return _endPos; }
161 inline short int length() const {
162 return endPos() - startPos();
163 };
164
166
168 inline void addError(const std::string& error) const { _expr->addError(error, _startPos, _endPos); }
169
170 protected: /*protected functions*/
172 inline void setType(const ExprType& t) {
173 _type = t;
174 };
176 inline void setTypeWithChildLife(const ExprType& t) {
177 setType(t);
178 int num = numChildren();
179 if (num > 0) {
181 for (int i = 1; i < num; i++) _type.setLifetime(_type, child(i)->type());
182 } else // no children life is constant!
183 _type.Constant();
184 };
185
187
188 public:
190 inline bool checkCondition(bool check, const std::string& message, bool& error) {
191 if (!check) {
193 error = true;
194 }
195 return check;
196 };
198 bool checkIsValue(const ExprType& type, bool& error) {
199 return checkCondition(type.isValue(), "Expected String or Float[d]", error);
200 }
202 bool checkIsFP(const ExprType& type, bool& error) {
203 return checkCondition(type.isFP(), "Expected Float[d]", error);
204 }
206 bool checkIsFP(int d, const ExprType& type, bool& error) {
207 if (!type.isFP(d)) { // Defer creating expensive string creation unless error
208 std::stringstream s;
209 s << "Expected Float[" << d << "]" << std::endl;
210 return checkCondition(false, s.str(), error);
211 }
212 return false;
213 }
215 inline bool checkTypesCompatible(const ExprType& first, const ExprType& second, bool& error) {
217 return checkCondition(
218 false, "Type mismatch. First: " + first.toString() + " Second: " + second.toString(), error);
219 } else
220 return false;
221 }
223 protected: /*protected data members*/
226
229
231 std::vector<ExprNode*> _children;
232
234 bool _isVec;
235
236 // Type of node
239
241 unsigned short int _startPos, _endPos;
242};
243
253
256 public:
259
260 ExprPrototypeNode(const Expression* expr, const std::string& name)
262
264
267
268 inline void setReturnType(const ExprType& type) {
269 _retType = type;
270 _retTypeSet = true;
271 };
272
273 inline bool isReturnTypeSet() const {
274 return _retTypeSet;
275 };
276
277 inline ExprType returnType() const {
278 return (_retTypeSet ? _retType : ExprType().Error().Varying());
279 };
280
281 inline ExprType argType(int i) const {
282 return _argTypes[i];
283 };
284 inline const ExprNode* arg(int i) const {
285 return child(i);
286 };
287
288 const std::string& name() const { return _name; }
289
294 int interpreterOps(int c) const { return _interpreterOps.at(c); }
295
296 private:
297 std::string _name;
300 std::vector<ExprType> _argTypes;
301 mutable std::vector<int> _interpreterOps; // operands for interpreter // TODO: this sucks... maybe a better place
302 // for this.
303};
304
305class ExprFuncNode;
329
339
353
355class ExprAssignNode : public ExprNode {
356 public:
358 : ExprNode(expr, e), _name(name), _localVar(0) {}
359
361 virtual int buildInterpreter(Interpreter* interpreter) const;
362 // virtual void eval(Vec3d& result) const;
364
365 const std::string& name() const {
366 return _name;
367 };
368 const ExprType& assignedType() const {
369 return _assignedType;
370 };
371 const ExprLocalVar* localVar() const { return _localVar; }
372
373 private:
374 std::string _name;
377};
378
379// TODO three scalars? Or 2 to 16 scalars??
381class ExprVecNode : public ExprNode {
382 public:
384
386 virtual int buildInterpreter(Interpreter* interpreter) const;
388
389 Vec3d value() const;
390};
391
393class ExprUnaryOpNode : public ExprNode {
394 public:
397
399 virtual int buildInterpreter(Interpreter* interpreter) const;
401
402 char _op;
403};
404
406class ExprCondNode : public ExprNode {
407 public:
409
411 virtual int buildInterpreter(Interpreter* interpreter) const;
413};
414
424
427 public:
429
431 virtual int buildInterpreter(Interpreter* interpreter) const;
433
434 char _op;
435};
436
438class ExprCompareNode : public ExprNode {
439 public:
441
443 virtual int buildInterpreter(Interpreter* interpreter) const;
445
447 char _op;
448};
449
452 public:
455
457 virtual int buildInterpreter(Interpreter* interpreter) const;
459
460 char _op;
461 char* _out;
462};
463
465class ExprVarNode : public ExprNode {
466 public:
467 ExprVarNode(const Expression* expr, const char* name) : ExprNode(expr), _name(name), _localVar(0), _var(0) {}
468
469 ExprVarNode(const Expression* expr, const char* name, const ExprType& type)
470 : ExprNode(expr, type), _name(name), _localVar(0), _var(0) {}
471
473 virtual int buildInterpreter(Interpreter* interpreter) const;
475 const char* name() const { return _name.c_str(); }
476 const ExprLocalVar* localVar() const { return _localVar; }
477 const ExprVarRef* var() const { return _var; }
478
479 private:
480 std::string _name;
483};
484
486class ExprNumNode : public ExprNode {
487 public:
488 ExprNumNode(const Expression* expr, double val) : ExprNode(expr), _val(val) {}
489
491 virtual int buildInterpreter(Interpreter* interpreter) const;
493 double value() const {
494 return _val;
495 };
496
497 private:
498 double _val;
499};
500
502class ExprStrNode : public ExprNode {
503 public:
504 ExprStrNode(const Expression* expr, const char* str);
505
507 virtual int buildInterpreter(Interpreter* interpreter) const;
509 const char* str() const { return _str.c_str(); }
510 void str(const char* newstr) { _str = newstr; }
511
512 private:
513 std::string _str;
514};
515
517class ExprFuncNode : public ExprNode {
518 public:
519 ExprFuncNode(const Expression* expr, const char* name)
520 : ExprNode(expr), _name(name), _func(0), _localFunc(0), _data(0) {
521 expr->addFunc(name);
522 }
523 virtual ~ExprFuncNode() {
524 if (_data != nullptr && _data->_cleanup == true) {
525 delete _data;
526 }
527 }
528
530 virtual int buildInterpreter(Interpreter* interpreter) const;
532
533 const char* name() const { return _name.c_str(); }
535
536#if 0
537 virtual void eval(Vec3d& result) const;
538 void setIsVec(bool isVec) { _isVec = isVec; }
539
541 int nargs() const { return _nargs; }
542
543#if 0
544 double* scalarArgs() const { return &_scalarArgs[0]; }
545 Vec3d* vecArgs() const { return &_vecArgs[0]; }
546
548 Vec3d* evalArgs() const;
549
551 Vec3d evalArg(int n) const;
552
554 bool isStrArg(int n) const;
555
557 std::string getStrArg(int n) const;
558#endif
559
560#endif
561
562 // TODO: Remove those two methods.
564 std::string getStrArg(int n) const {
565 if (n < numChildren()) return static_cast<const ExprStrNode*>(child(n))->str();
566 return "";
567 }
568
570 struct Data {
571 Data(bool cleanup = false) : _cleanup(cleanup) {}
572 virtual ~Data() {}
574 };
575
577 /***
578 Use this to set data associated with the node. Equivalently this is data
579 associated with a specific evaluation point of a function.
580 Examples would be tokenized values,
581 sorted lists for binary searches in curve evaluation, etc. This should be done
582 in ExprFuncX::prep().
583 */
584 void setData(Data* data) const { _data = data; }
585
587 /***
588 Use this to get data associated in the prep() routine. This is typically
589 used from ExprFuncX::eval()
590 */
591 Data* getData() const { return _data; }
592 int promote(int i) const { return _promote[i]; }
593 const ExprFunc* func() const { return _func; }
594
595 private:
596 std::string _name;
598 const ExprLocalFunctionNode* _localFunc; // TODO: it is dirty to have to have both.
599 // int _nargs;
600 // mutable std::vector<double> _scalarArgs;
601 // mutable std::vector<Vec3d> _vecArgs;
602 mutable std::vector<int> _promote;
603 mutable Data* _data;
604};
605
608 typedef ExprNode Base;
609 // TODO: fix this once we switch to a c++11 compiler
610 // typedef std::unique_ptr<Base*> Ptr;
611
628};
629}
630
631#endif
virtual void eval(ArgHandle args)
double LLVM_BUILDER
Definition ExprLLVM.h:34
#define LLVM_BODY
Definition ExprLLVM.h:35
double LLVM_VALUE
Definition ExprLLVM.h:33
Node that compute a local variable assignment.
Definition ExprNode.h:355
const ExprType & assignedType() const
Definition ExprNode.h:368
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:307
ExprLocalVar * _localVar
Definition ExprNode.h:375
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
const ExprLocalVar * localVar() const
Definition ExprNode.h:371
ExprAssignNode(const Expression *expr, const char *name, ExprNode *e)
Definition ExprNode.h:357
const std::string & name() const
Definition ExprNode.h:365
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
Node that implements an binary operator.
Definition ExprNode.h:451
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:463
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)
Definition ExprNode.h:453
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
Node that computes local variables before evaluating expression.
Definition ExprNode.h:331
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)
Definition ExprNode.h:333
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:258
Node that implements a numeric/string comparison.
Definition ExprNode.h:426
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)
Definition ExprNode.h:428
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:420
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
Node that implements a numeric comparison.
Definition ExprNode.h:438
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
Definition ExprNode.h:447
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:441
ExprCompareNode(const Expression *expr, ExprNode *a, ExprNode *b, char op)
Definition ExprNode.h:440
Node that evaluates a conditional (if-then-else) expression.
Definition ExprNode.h:406
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:370
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
ExprCondNode(const Expression *expr, ExprNode *a, ExprNode *b, ExprNode *c)
Definition ExprNode.h:408
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
Node that calls a function.
Definition ExprNode.h:517
std::string _name
Definition ExprNode.h:596
virtual ~ExprFuncNode()
Definition ExprNode.h:523
Data * getData() const
get associated blind data (returns 0 if none)
Definition ExprNode.h:591
int promote(int i) const
Definition ExprNode.h:592
std::string getStrArg(int n) const
Definition ExprNode.h:564
bool isStrArg(int n) const
Definition ExprNode.h:563
const ExprLocalFunctionNode * _localFunc
Definition ExprNode.h:598
const char * name() const
Definition ExprNode.h:533
std::vector< int > _promote
Definition ExprNode.h:602
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
const ExprFunc * _func
Definition ExprNode.h:597
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:533
bool checkArg(int argIndex, ExprType type, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:578
void setData(Data *data) const
associate blind data with this node (subsequently owned by this object)
Definition ExprNode.h:584
ExprFuncNode(const Expression *expr, const char *name)
Definition ExprNode.h:519
const ExprFunc * func() const
Definition ExprNode.h:593
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
Definition ExprNode.cpp:568
Function Definition, used in parse tree and func table.
Definition ExprFunc.h:44
Node that computes local variables before evaluating expression.
Definition ExprNode.h:341
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:270
ExprIfThenElseNode(const Expression *expr, ExprNode *a, ExprNode *b, ExprNode *c)
Definition ExprNode.h:343
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
Node that contains local function.
Definition ExprNode.h:307
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Preps the definition of this site.
Definition ExprNode.cpp:188
const ExprPrototypeNode * prototype() const
TODO: Accessor for prototype (probably not needed when we use prep right)
Definition ExprNode.h:317
int buildInterpreter(Interpreter *interpreter) const
Build the interpreter.
ExprLocalFunctionNode(const Expression *expr, ExprPrototypeNode *prototype, ExprNode *block)
Definition ExprNode.h:309
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.
Definition ExprEnv.h:37
Node that contains entire program.
Definition ExprNode.h:245
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)
Definition ExprNode.cpp:127
ExprModuleNode(const Expression *expr)
Definition ExprNode.h:247
Policy which provides all the AST Types for the parser.
Definition ExprNode.h:607
ExprBinaryOpNode BinaryOp
Definition ExprNode.h:623
ExprLocalFunctionNode LocalFunction
Definition ExprNode.h:614
ExprAssignNode Assign
Definition ExprNode.h:617
ExprModuleNode Module
Definition ExprNode.h:612
ExprPrototypeNode Prototype
Definition ExprNode.h:613
ExprBlockNode Block
Definition ExprNode.h:615
ExprCompareNode Compare
Definition ExprNode.h:622
ExprUnaryOpNode UnaryOp
Definition ExprNode.h:619
ExprIfThenElseNode IfThenElse
Definition ExprNode.h:616
ExprCompareEqNode CompareEq
Definition ExprNode.h:621
void setTypeWithChildLife(const ExprType &t)
Set's the type to the argument but uses the children to determine lifetime.
Definition ExprNode.h:176
bool _isVec
True if node has a vector result.
Definition ExprNode.h:234
short int endPos() const
Access end position in input string.
Definition ExprNode.h:159
std::vector< ExprNode * > _children
List of children.
Definition ExprNode.h:231
bool isVec() const
True if node has a vector result.
Definition ExprNode.h:99
bool checkIsValue(const ExprType &type, bool &error)
Checks if the type is a value (i.e. string or float[d])
Definition ExprNode.h:198
void addChildren(ExprNode *surrogate)
Transfer children from surrogate parent (for parser use only)
Definition ExprNode.cpp:95
void removeLastChild()
Remove last child and delete the entry.
Definition ExprNode.h:129
short int length() const
Access length of input string.
Definition ExprNode.h:161
void addError(const std::string &error) const
Register error. This will allow users and sophisticated editors to highlight where in code problem wa...
Definition ExprNode.h:168
void addChild(ExprNode *child)
Add a child to the child list (for parser use only)
Definition ExprNode.cpp:90
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.
Definition ExprNode.h:172
int numChildren() const
Number of children.
Definition ExprNode.h:114
ExprNode * _parent
Parent node (null if this the the root)
Definition ExprNode.h:228
bool checkTypesCompatible(const ExprType &first, const ExprType &second, bool &error)
types match (true if they do)
Definition ExprNode.h:215
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
const Expression * expr() const
Access expression.
Definition ExprNode.h:102
const ExprNode * child(size_t i) const
Get 0 indexed child.
Definition ExprNode.h:117
void setPosition(const short int startPos, const short int endPos)
Remember the line and column position in the input string.
Definition ExprNode.h:152
unsigned short int _startPos
Position line and collumn.
Definition ExprNode.h:241
const ExprNode * parent() const
Access parent node - root node has no parent.
Definition ExprNode.h:112
void swapChildren(size_t i, size_t j)
Swap children, do not use unless you know what you are doing.
Definition ExprNode.h:123
short int startPos() const
Access start position in input string.
Definition ExprNode.h:157
ExprNode * child(size_t i)
Get 0 indexed child.
Definition ExprNode.h:120
std::string toString() const
Access to original string representation of current expression.
Definition ExprNode.h:105
bool checkIsFP(int d, const ExprType &type, bool &error)
Checks if the type is a float[d] for a specific d.
Definition ExprNode.h:206
const ExprType & type() const
The type of the node.
Definition ExprNode.h:145
const Expression * _expr
Owning expression (node can't modify)
Definition ExprNode.h:225
bool checkIsFP(const ExprType &type, bool &error)
Checks if the type is a float[d] for any d.
Definition ExprNode.h:202
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.
Definition ExprNode.h:190
virtual ~ExprNode()
Definition ExprNode.cpp:84
unsigned short int _endPos
Definition ExprNode.h:241
virtual ExprType prep(bool dontNeedScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:104
Node that stores a numeric constant.
Definition ExprNode.h:486
ExprNumNode(const Expression *expr, double val)
Definition ExprNode.h:488
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:520
double value() const
Definition ExprNode.h:493
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.
Definition ExprNode.h:255
ExprType returnType() const
Definition ExprNode.h:277
void addArgs(ExprNode *surrogate)
Definition ExprNode.cpp:173
void addArgTypes(ExprNode *surrogate)
Definition ExprNode.cpp:166
ExprPrototypeNode(const Expression *expr, const std::string &name)
Definition ExprNode.h:260
void setReturnType(const ExprType &type)
Definition ExprNode.h:268
const ExprNode * arg(int i) const
Definition ExprNode.h:284
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:139
bool isReturnTypeSet() const
Definition ExprNode.h:273
int buildInterpreter(Interpreter *interpreter) const
Build the interpreter.
std::vector< ExprType > _argTypes
Definition ExprNode.h:300
ExprPrototypeNode(const Expression *expr, const std::string &name, const ExprType &retType)
Definition ExprNode.h:257
const std::string & name() const
Definition ExprNode.h:288
ExprType argType(int i) const
Definition ExprNode.h:281
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
std::vector< int > _interpreterOps
Definition ExprNode.h:301
int interpreterOps(int c) const
Return op for interpreter.
Definition ExprNode.h:294
Node that stores a string.
Definition ExprNode.h:502
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:528
const char * str() const
Definition ExprNode.h:509
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
std::string _str
Definition ExprNode.h:513
void str(const char *newstr)
Definition ExprNode.h:510
Node that evaluates a component of a vector.
Definition ExprNode.h:416
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:400
ExprSubscriptNode(const Expression *expr, ExprNode *a, ExprNode *b)
Definition ExprNode.h:418
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
static bool valuesCompatible(const ExprType &a, const ExprType &b)
Checks if value types are compatible.
Definition ExprType.h:173
ExprType & setLifetime(const ExprType &a)
Assign the lifetime from type a to be my type.
Definition ExprType.h:136
ExprType & Error()
Mutate this into an error type.
Definition ExprType.h:102
ExprType & Varying()
Mutate this into a varying lifetime.
Definition ExprType.h:122
ExprType & Constant()
Mutate this into a constant lifetime.
Definition ExprType.h:112
NOde that computes with a single operand.
Definition ExprNode.h:393
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)
Definition ExprNode.cpp:357
ExprUnaryOpNode(const Expression *expr, ExprNode *a, char op)
Construct with specific op ('!x' is logical negation, '~x' is 1-x, '-x' is -x)
Definition ExprNode.h:396
Variable scope builder is used by the type checking and code gen to track visiblity of variables and ...
Definition ExprEnv.h:148
Variable scope for tracking variable lookup.
Definition ExprEnv.h:94
Node that references a variable.
Definition ExprNode.h:465
ExprVarNode(const Expression *expr, const char *name, const ExprType &type)
Definition ExprNode.h:469
const ExprLocalVar * localVar() const
Definition ExprNode.h:476
ExprLocalVar * _localVar
Definition ExprNode.h:481
const ExprVarRef * var() const
Definition ExprNode.h:477
std::string _name
Definition ExprNode.h:480
ExprVarNode(const Expression *expr, const char *name)
Definition ExprNode.h:467
ExprVarRef * _var
Definition ExprNode.h:482
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
const char * name() const
Definition ExprNode.h:475
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:485
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
abstract class for implementing variable references
Definition Expression.h:45
Node that constructs a vector from three scalars.
Definition ExprNode.h:381
ExprVecNode(const Expression *expr)
Definition ExprNode.h:383
virtual int buildInterpreter(Interpreter *interpreter) const
builds an interpreter. Returns the location index for the evaluated data
virtual ExprType prep(bool wantScalar, ExprVarEnvBuilder &envBuilder)
Definition ExprNode.cpp:324
virtual LLVM_VALUE codegen(LLVM_BUILDER) LLVM_BODY
Vec3d value() const
Definition ExprNode.cpp:342
main expression class
Definition Expression.h:76
Vec< double, 3, false > Vec3d
Definition Vec.h:384
base class for custom instance data
Definition ExprNode.h:570
Data(bool cleanup=false)
Definition ExprNode.h:571
Between a and b
Definition userdoc.txt:180
Defined as a *alpha b *alpha< br ></div >< br > float< b > float a
Definition userdoc.txt:174