OpenVDB: AST.h Source File

OpenVDB 8.0.0

AST.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
26
27 #ifndef OPENVDB_AX_AST_HAS_BEEN_INCLUDED
28 #define OPENVDB_AX_AST_HAS_BEEN_INCLUDED
29
30 #include "Tokens.h"
31
32 #include <openvdb/version.h>
33
34 #include <memory>
35 #include <utility>
36 #include <vector>
37
38 namespace openvdb {
39 OPENVDB_USE_VERSION_NAMESPACE
40 namespace OPENVDB_VERSION_NAME {
41
42 namespace ax {
43 namespace ast {
44
50 struct Tree;
51
54
87
90
101 struct Node
102 {
103 using Ptr = std::shared_ptr<Node>;
104 using UniquePtr = std::unique_ptr<Node>;
105
117 enum NodeType {
118 TreeNode,
119 StatementListNode,
120 BlockNode,
121 ConditionalStatementNode,
122 CommaOperatorNode,
123 LoopNode,
124 KeywordNode,
125 AssignExpressionNode,
126 CrementNode,
127 UnaryOperatorNode,
128 BinaryOperatorNode,
129 TernaryOperatorNode,
130 CastNode,
131 AttributeNode,
132 FunctionCallNode,
133 ExternalVariableNode,
134 DeclareLocalNode,
135 ArrayPackNode,
136 ArrayUnpackNode,
137 LocalNode,
138 ValueBoolNode,
139 ValueInt16Node,
140 ValueInt32Node,
141 ValueInt64Node,
142 ValueFloatNode,
143 ValueDoubleNode,
144 ValueStrNode
145 };
146
147 Node() = default;
148 virtual ~Node() = default;
149
152 virtual Node* copy() const = 0;
153
156
160 virtual NodeType nodetype() const = 0;
161
164 virtual const char* nodename() const = 0;
165
168 virtual const char* subname() const = 0;
169
175 virtual const Node* basetype() const { return nullptr; }
176
183 template <typename NodeT>
184 inline bool isType() const {
185 return dynamic_cast<const NodeT*>(this);
186 }
187
189
192
196 virtual size_t children() const = 0;
197
205 virtual const Node* child(const size_t index) const = 0;
206
211 inline int64_t childidx() const
212 {
213 const Node* p = this->parent();
214 if (!p) return -1;
215 size_t i = 0;
216 const size_t count = p->children();
217 for (; i < count; ++i) {
218 if (p->child(i) == this) break;
219 }
220 if (i == count) return -1;
221 return static_cast<int64_t>(i);
222 }
223
225
228
247 inline bool replace(Node* node)
248 {
249 const int64_t idx = this->childidx();
250 if (idx == -1) return false; // avoid second vcall
251 return this->parent()->replacechild(idx, node);
252 }
253
260 inline virtual bool replacechild(const size_t index, Node* node);
261
263
266
271 inline const Node* parent() const { return mParent; }
272
276 inline void setParent(Node* parent) {
277 #ifndef NDEBUG
278 bool hasChild = false;
279 for (size_t i = 0; i < parent->children(); ++i)
280 hasChild |= parent->child(i) == this;
281 assert(hasChild);
282 #endif
283 mParent = parent;
284 }
285
286 private:
292 inline Node* parent() { return mParent; }
293
295
296 Node* mParent = nullptr;
297 };
298
299 inline bool Node::replacechild(const size_t, Node*) { return false; }
300
301
304
306
311 struct Statement : public Node
312 {
313 using UniquePtr = std::unique_ptr<Statement>;
314 ~Statement() override = default;
315 virtual Statement* copy() const override = 0;
316 const Node* basetype() const override { return this; }
317 };
318
325 struct Expression : public Statement
326 {
327 using UniquePtr = std::unique_ptr<Expression>;
328 ~Expression() override = default;
329 virtual Expression* copy() const override = 0;
330 const Statement* basetype() const override { return this; }
331 };
332
336 struct Variable : public Expression
337 {
338 using UniquePtr = std::unique_ptr<Variable>;
339
340 Variable(const std::string& name)
341 : Expression(), mName(name) {}
342 Variable(const Variable& other)
343 : Expression(), mName(other.mName) {}
344 ~Variable() override = default;
345
346 virtual Variable* copy() const override = 0;
347 const Expression* basetype() const override { return this; }
348 //
349 size_t children() const override { return 0; }
350 const Node* child(const size_t) const override { return nullptr; }
351 //
352 inline const std::string& name() const { return mName; }
353
354 private:
355 const std::string mName;
356 };
357
360 struct ValueBase : public Expression
361 {
362 using UniquePtr = std::unique_ptr<ValueBase>;
363 ~ValueBase() override = default;
364 virtual Expression* copy() const override = 0;
365 const Expression* basetype() const override { return this; }
366 //
367 size_t children() const override { return 0; }
368 const Node* child(const size_t) const override { return nullptr; }
369 };
370
371
374
376
385 struct StatementList : public Statement
386 {
387 using UniquePtr = std::unique_ptr<StatementList>;
388
390 StatementList() : mList() {}
396 StatementList(Statement* statement)
397 : mList() {
398 this->addStatement(statement);
399 }
405 StatementList(const std::vector<Statement*>& statements)
406 : mList() {
407 for (Statement* statement : statements) {
408 this->addStatement(statement);
409 }
410 }
415 StatementList(const StatementList& other) : mList() {
416 for (const Statement::UniquePtr& stmnt : other.mList) {
417 this->addStatement(stmnt->copy());
418 }
419 }
420 ~StatementList() override = default;
421
423 StatementList* copy() const override { return new StatementList(*this); }
425 NodeType nodetype() const override { return Node::StatementListNode; }
427 const char* nodename() const override { return "statement list"; }
429 const char* subname() const override { return "stml"; }
431 const Statement* basetype() const override { return this; }
432
434 size_t children() const override final { return this->size(); }
436 const Statement* child(const size_t i) const override final {
437 if (i >= mList.size()) return nullptr;
438 return mList[i].get();
439 }
441 inline bool replacechild(const size_t i, Node* node) override final {
442 if (mList.size() <= i) return false;
443 Expression* expr = dynamic_cast<Expression*>(node);
444 if (!expr) return false;
445 mList[i].reset(expr);
446 mList[i]->setParent(this);
447 return true;
448 }
449
451 inline size_t size() const { return mList.size(); }
455 inline void addStatement(Statement* stmnt) {
456 if (stmnt) {
457 mList.emplace_back(stmnt);
458 stmnt->setParent(this);
459 }
460 }
461 private:
462 std::vector<Statement::UniquePtr> mList;
463 };
464
475 struct Block : public Statement
476 {
477 using UniquePtr = std::unique_ptr<Block>;
478
480 Block() : mList() {}
486 Block(Statement* statement)
487 : mList() {
488 this->addStatement(statement);
489 }
495 Block(const std::vector<Statement*>& statements)
496 : mList() {
497 for (Statement* statement : statements) {
498 this->addStatement(statement);
499 }
500 }
504 Block(const Block& other) : mList() {
505 for (const Statement::UniquePtr& stmnt : other.mList) {
506 this->addStatement(stmnt->copy());
507 }
508 }
509 ~Block() override = default;
510
512 Block* copy() const override final { return new Block(*this); }
514 NodeType nodetype() const override { return Node::BlockNode; }
516 const char* nodename() const override { return "scoped block"; }
518 const char* subname() const override { return "blk"; }
520 const Statement* basetype() const override { return this; }
521
523 size_t children() const override final { return this->size(); }
525 const Statement* child(const size_t i) const override final {
526 if (i >= mList.size()) return nullptr;
527 return mList[i].get();
528 }
530 inline bool replacechild(const size_t i, Node* node) override final {
531 if (mList.size() <= i) return false;
532 Expression* expr = dynamic_cast<Expression*>(node);
533 if (!expr) return false;
534 mList[i].reset(expr);
535 mList[i]->setParent(this);
536 return true;
537 }
538
540 inline size_t size() const { return mList.size(); }
544 inline void addStatement(Statement* stmnt) {
545 if (stmnt) {
546 mList.emplace_back(stmnt);
547 stmnt->setParent(this);
548 }
549 }
550 private:
551 std::vector<Statement::UniquePtr> mList;
552 };
553
561 struct Tree : public Node
562 {
563 using Ptr = std::shared_ptr<Tree>;
564 using ConstPtr = std::shared_ptr<const Tree>;
565 using UniquePtr = std::unique_ptr<Tree>;
566
571 Tree(Block* block = new Block())
572 : mBlock(block) {
573 mBlock->setParent(this);
574 }
578 Tree(const Tree& other)
579 : mBlock(new Block(*other.mBlock)) {
580 mBlock->setParent(this);
581 }
582 ~Tree() override = default;
583
585 Tree* copy() const override final { return new Tree(*this); }
587 NodeType nodetype() const override { return Node::TreeNode; }
589 const char* nodename() const override { return "tree"; }
591 const char* subname() const override { return "tree"; }
593 const Node* basetype() const override { return this; }
594
596 size_t children() const override final { return 1; }
598 const Block* child(const size_t i) const override final {
599 if (i == 0) return mBlock.get();
600 return nullptr;
601 }
602 private:
603 Block::UniquePtr mBlock;
604 };
605
606 struct CommaOperator : public Expression
607 {
608 using UniquePtr = std::unique_ptr<CommaOperator>;
609
611 CommaOperator() : mExpressions() {}
617 CommaOperator(Expression* expression)
618 : mExpressions() {
619 this->append(expression);
620 }
626 CommaOperator(const std::vector<Expression*>& expressions)
627 : mExpressions() {
628 mExpressions.reserve(expressions.size());
629 for (Expression* expression : expressions) {
630 this->append(expression);
631 }
632 }
637 CommaOperator(const CommaOperator& other)
638 : mExpressions() {
639 mExpressions.reserve(other.mExpressions.size());
640 for (const Expression::UniquePtr& expr : other.mExpressions) {
641 this->append(expr->copy());
642 }
643 }
644 ~CommaOperator() override = default;
645
647 CommaOperator* copy() const override final {
648 return new CommaOperator(*this);
649 }
651 NodeType nodetype() const override { return Node::CommaOperatorNode; }
653 const char* nodename() const override { return "comma"; }
655 const char* subname() const override { return "comma"; }
657 const Expression* basetype() const override { return this; }
658
660 size_t children() const override final { return this->size(); }
662 const Expression* child(const size_t i) const override final {
663 if (i >= mExpressions.size()) return nullptr;
664 return mExpressions[i].get();
665 }
667 inline bool replacechild(const size_t i, Node* node) override final {
668 if (mExpressions.size() <= i) return false;
669 Expression* expr = dynamic_cast<Expression*>(node);
670 mExpressions[i].reset(expr);
671 mExpressions[i]->setParent(this);
672 return true;
673 }
674
676 inline size_t size() const { return mExpressions.size(); }
679 inline bool empty() const { return mExpressions.empty(); }
683 inline void append(Expression* expr) {
684 if (expr) {
685 mExpressions.emplace_back(expr);
686 expr->setParent(this);
687 }
688 }
689 private:
690 std::vector<Expression::UniquePtr> mExpressions;
691 };
692
707 struct Loop : public Statement
708 {
709 using UniquePtr = std::unique_ptr<Loop>;
710
722 Loop(const tokens::LoopToken loopType,
723 Statement* condition,
724 Block* body,
725 Statement* init = nullptr,
726 Expression* iter = nullptr)
727 : mLoopType(loopType)
728 , mConditional(condition)
729 , mBody(body)
730 , mInitial(init)
731 , mIteration(iter) {
732 assert(mConditional);
733 assert(mBody);
734 mConditional->setParent(this);
735 mBody->setParent(this);
736 if (mInitial) {
737 assert(mLoopType == tokens::LoopToken::FOR);
738 mInitial->setParent(this);
739 }
740 if (mIteration) {
741 assert(mLoopType == tokens::LoopToken::FOR);
742 mIteration->setParent(this);
743 }
744 }
749 Loop(const Loop& other)
750 : mLoopType(other.mLoopType)
751 , mConditional(other.mConditional->copy())
752 , mBody(other.mBody->copy())
753 , mInitial(other.hasInit() ? other.mInitial->copy() : nullptr)
754 , mIteration(other.hasIter() ? other.mIteration->copy() : nullptr) {
755 mConditional->setParent(this);
756 mBody->setParent(this);
757 if (mInitial) {
758 assert(mLoopType == tokens::LoopToken::FOR);
759 mInitial->setParent(this);
760 }
761 if (mIteration) {
762 assert(mLoopType == tokens::LoopToken::FOR);
763 mIteration->setParent(this);
764 }
765 }
766 ~Loop() override = default;
767
769 Loop* copy() const override final { return new Loop(*this); }
771 NodeType nodetype() const override { return Node::LoopNode; }
773 const char* nodename() const override { return "loop"; }
775 const char* subname() const override { return "loop"; }
777 const Statement* basetype() const override { return this; }
778
780 size_t children() const override final { return 4; }
782 const Statement* child(const size_t i) const override final {
783 if (i == 0) return mConditional.get();
784 if (i == 1) return mBody.get();
785 if (i == 2) return mInitial.get();
786 if (i == 3) return mIteration.get();
787 return nullptr;
788 }
790 inline bool replacechild(const size_t i, Node* node) override final
791 {
792 if (i == 0 || i == 2) {
793 Statement* stmt = dynamic_cast<Statement*>(node);
794 if (!stmt) return false;
795 if (i == 0) {
796 mConditional.reset(stmt);
797 mConditional->setParent(this);
798 }
799 else {
800 mInitial.reset(stmt);
801 mInitial->setParent(this);
802 }
803 return true;
804 }
805 else if (i == 1) {
806 Block* blk = dynamic_cast<Block*>(node);
807 if (!blk) return false;
808 mBody.reset(blk);
809 mBody->setParent(this);
810 return true;
811 }
812 else if (i == 3) {
813 Expression* expr = dynamic_cast<Expression*>(node);
814 if (!expr) return false;
815 mIteration.reset(expr);
816 mIteration->setParent(expr);
817 return true;
818 }
819 return false;
820 }
821
824 inline tokens::LoopToken loopType() const { return mLoopType; }
827 inline bool hasInit() const { return static_cast<bool>(this->initial()); }
830 inline bool hasIter() const { return static_cast<bool>(this->iteration()); }
834 const Statement* condition() const { return mConditional.get(); }
837 const Block* body() const { return mBody.get(); }
841 const Statement* initial() const { return mInitial.get(); }
844 const Expression* iteration() const { return mIteration.get(); }
845
846 private:
847 const tokens::LoopToken mLoopType;
848 Statement::UniquePtr mConditional;
849 Block::UniquePtr mBody;
850 Statement::UniquePtr mInitial;
851 Expression::UniquePtr mIteration;
852 };
853
863 struct ConditionalStatement : public Statement
864 {
865 using UniquePtr = std::unique_ptr<ConditionalStatement>;
866
877 ConditionalStatement(Expression* conditional,
878 Block* trueBlock,
879 Block* falseBlock = nullptr)
880 : mConditional(conditional)
881 , mTrueBranch(trueBlock)
882 , mFalseBranch(falseBlock) {
883 assert(mConditional);
884 assert(mTrueBranch);
885 mConditional->setParent(this);
886 mTrueBranch->setParent(this);
887 if (mFalseBranch) mFalseBranch->setParent(this);
888 }
894 ConditionalStatement(const ConditionalStatement& other)
895 : mConditional(other.mConditional->copy())
896 , mTrueBranch(other.mTrueBranch->copy())
897 , mFalseBranch(other.hasFalse() ? other.mFalseBranch->copy() : nullptr) {
898 mConditional->setParent(this);
899 mTrueBranch->setParent(this);
900 if (mFalseBranch) mFalseBranch->setParent(this);
901 }
902 ~ConditionalStatement() override = default;
903
905 ConditionalStatement* copy() const override final {
906 return new ConditionalStatement(*this);
907 }
909 NodeType nodetype() const override { return Node::ConditionalStatementNode; }
911 const char* nodename() const override { return "conditional statement"; }
913 const char* subname() const override { return "cond"; }
915 const Statement* basetype() const override { return this; }
916
918 size_t children() const override final { return 3; }
920 const Statement* child(const size_t i) const override final {
921 if (i == 0) return this->condition();
922 if (i == 1) return this->trueBranch();
923 if (i == 2) return this->falseBranch();
924 return nullptr;
925 }
927 inline bool replacechild(const size_t i, Node* node) override final
928 {
929 if (i == 0) {
930 Expression* expr = dynamic_cast<Expression*>(node);
931 if (!expr) return false;
932 mConditional.reset(expr);
933 mConditional->setParent(this);
934 return true;
935 }
936 else if (i == 1 || i == 2) {
937 Block* blk = dynamic_cast<Block*>(node);
938 if (!blk) return false;
939 if (i == 1) {
940 mTrueBranch.reset(blk);
941 mTrueBranch->setParent(this);
942 }
943 else {
944 mFalseBranch.reset(blk);
945 mFalseBranch->setParent(this);
946 }
947 return true;
948 }
949 return false;
950 }
951
954 inline bool hasFalse() const {
955 return static_cast<bool>(this->falseBranch());
956 }
960 size_t branchCount() const {
961 return this->hasFalse() ? 2 : 1;
962 }
966 const Expression* condition() const { return mConditional.get(); }
970 const Block* trueBranch() const { return mTrueBranch.get(); }
974 const Block* falseBranch() const { return mFalseBranch.get(); }
975 private:
976 Expression::UniquePtr mConditional;
977 Block::UniquePtr mTrueBranch;
978 Block::UniquePtr mFalseBranch;
979 };
980
987 struct BinaryOperator : public Expression
988 {
989 using UniquePtr = std::unique_ptr<BinaryOperator>;
990
999 BinaryOperator(Expression* left,
1000 Expression* right,
1001 const tokens::OperatorToken op)
1002 : mLeft(left)
1003 , mRight(right)
1004 , mOperation(op) {
1005 assert(mLeft);
1006 assert(mRight);
1007 mLeft->setParent(this);
1008 mRight->setParent(this);
1009 }
1015 BinaryOperator(Expression* left,
1016 Expression* right,
1017 const std::string& op)
1018 : BinaryOperator(left, right, tokens::operatorTokenFromName(op)) {}
1023 BinaryOperator(const BinaryOperator& other)
1024 : mLeft(other.mLeft->copy())
1025 , mRight(other.mRight->copy())
1026 , mOperation(other.mOperation) {
1027 mLeft->setParent(this);
1028 mRight->setParent(this);
1029 }
1030 ~BinaryOperator() override = default;
1031
1033 BinaryOperator* copy() const override final {
1034 return new BinaryOperator(*this);
1035 }
1037 NodeType nodetype() const override { return Node::BinaryOperatorNode; }
1039 const char* nodename() const override { return "binary"; }
1041 const char* subname() const override { return "bin"; }
1043 const Expression* basetype() const override { return this; }
1045 size_t children() const override final { return 2; }
1047 const Expression* child(const size_t i) const override final {
1048 if (i == 0) return mLeft.get();
1049 if (i == 1) return mRight.get();
1050 return nullptr;
1051 }
1053 inline bool replacechild(const size_t i, Node* node) override final {
1054 if (i > 1) return false;
1055 Expression* expr = dynamic_cast<Expression*>(node);
1056 if (!expr) return false;
1057 if (i == 0) {
1058 mLeft.reset(expr);
1059 mLeft->setParent(this);
1060 }
1061 else if (i == 1) {
1062 mRight.reset(expr);
1063 mRight->setParent(this);
1064 }
1065 return true;
1066 }
1067
1070 inline tokens::OperatorToken operation() const { return mOperation; }
1074 const Expression* lhs() const { return mLeft.get(); }
1078 const Expression* rhs() const { return mRight.get(); }
1079 private:
1080 Expression::UniquePtr mLeft;
1081 Expression::UniquePtr mRight;
1082 const tokens::OperatorToken mOperation;
1083 };
1084
1091 struct TernaryOperator : public Expression
1092 {
1093 using UniquePtr = std::unique_ptr<TernaryOperator>;
1094
1104 TernaryOperator(Expression* conditional,
1105 Expression* trueExpression,
1106 Expression* falseExpression)
1107 : mConditional(conditional)
1108 , mTrueBranch(trueExpression)
1109 , mFalseBranch(falseExpression) {
1110 assert(mConditional);
1111 assert(mFalseBranch);
1112 mConditional->setParent(this);
1113 if (mTrueBranch) mTrueBranch->setParent(this);
1114 mFalseBranch->setParent(this);
1115 }
1120 TernaryOperator(const TernaryOperator& other)
1121 : mConditional(other.mConditional->copy())
1122 , mTrueBranch(other.hasTrue() ? other.mTrueBranch->copy() : nullptr)
1123 , mFalseBranch(other.mFalseBranch->copy()) {
1124 mConditional->setParent(this);
1125 if (mTrueBranch) mTrueBranch->setParent(this);
1126 mFalseBranch->setParent(this);
1127 }
1128 ~TernaryOperator() override = default;
1129
1131 TernaryOperator* copy() const override final {
1132 return new TernaryOperator(*this);
1133 }
1135 NodeType nodetype() const override { return Node::TernaryOperatorNode; }
1137 const char* nodename() const override { return "ternary"; }
1139 const char* subname() const override { return "tern"; }
1141 const Expression* basetype() const override { return this; }
1143 size_t children() const override final { return 3; }
1145 const Expression* child(const size_t i) const override final {
1146 if (i == 0) return mConditional.get();
1147 if (i == 1) return mTrueBranch.get();
1148 if (i == 2) return mFalseBranch.get();
1149 return nullptr;
1150 }
1152 inline bool replacechild(const size_t i, Node* node) override final {
1153 if (i > 2) return false;
1154 Expression* expr = dynamic_cast<Expression*>(node);
1155 if (!expr) return false;
1156 if (i == 0) {
1157 mConditional.reset(expr);
1158 mConditional->setParent(this);
1159 }
1160 else if (i == 1) {
1161 mTrueBranch.reset(expr);
1162 mTrueBranch->setParent(this);
1163 }
1164 else if (i == 2) {
1165 mFalseBranch.reset(expr);
1166 mFalseBranch->setParent(this);
1167 }
1168 return true;
1169 }
1170
1172 bool hasTrue() const { return static_cast<bool>(this->trueBranch()); }
1176 const Expression* condition() const { return mConditional.get(); }
1180 const Expression* trueBranch() const { return mTrueBranch.get(); }
1184 const Expression* falseBranch() const { return mFalseBranch.get(); }
1185 private:
1186 Expression::UniquePtr mConditional;
1187 Expression::UniquePtr mTrueBranch;
1188 Expression::UniquePtr mFalseBranch;
1189 };
1190
1197 struct AssignExpression : public Expression
1198 {
1199 using UniquePtr = std::unique_ptr<AssignExpression>;
1200
1207 AssignExpression(Expression* lhs, Expression* rhs,
1208 const tokens::OperatorToken op = tokens::EQUALS)
1209 : mLHS(lhs)
1210 , mRHS(rhs)
1211 , mOperation(op) {
1212 assert(mLHS);
1213 assert(mRHS);
1214 mLHS->setParent(this);
1215 mRHS->setParent(this);
1216 }
1222 AssignExpression(const AssignExpression& other)
1223 : mLHS(other.mLHS->copy())
1224 , mRHS(other.mRHS->copy())
1225 , mOperation(other.mOperation) {
1226 mLHS->setParent(this);
1227 mRHS->setParent(this);
1228 }
1229 ~AssignExpression() override = default;
1230
1232 AssignExpression* copy() const override final {
1233 return new AssignExpression(*this);
1234 }
1236 NodeType nodetype() const override { return Node::AssignExpressionNode; }
1238 const char* nodename() const override { return "assignment expression"; }
1240 const char* subname() const override { return "asgn"; }
1242 const Expression* basetype() const override { return this; }
1244 size_t children() const override final { return 2; }
1246 const Expression* child(const size_t i) const override final {
1247 if (i == 0) return this->lhs();
1248 if (i == 1) return this->rhs();
1249 return nullptr;
1250 }
1252 inline bool replacechild(const size_t i, Node* node) override final {
1253 if (i > 1) return false;
1254 Expression* expr = dynamic_cast<Expression*>(node);
1255 if (!expr) return false;
1256 if (i == 0) {
1257 mLHS.reset(expr);
1258 mLHS->setParent(this);
1259 }
1260 else if (i == 1) {
1261 mRHS.reset(expr);
1262 mRHS->setParent(this);
1263 }
1264 return true;
1265 }
1266
1271 inline bool isCompound() const { return mOperation != tokens::EQUALS; }
1275 inline tokens::OperatorToken operation() const { return mOperation; }
1279 const Expression* lhs() const { return mLHS.get(); }
1283 const Expression* rhs() const { return mRHS.get(); }
1284 private:
1285 Expression::UniquePtr mLHS;
1286 Expression::UniquePtr mRHS;
1287 const tokens::OperatorToken mOperation;
1288 };
1289
1293 struct Crement : public Expression
1294 {
1295 using UniquePtr = std::unique_ptr<Crement>;
1296
1298 enum Operation {
1299 Increment,
1300 Decrement
1301 };
1302
1310 Crement(Expression* expr, const Operation op, bool post)
1311 : mExpression(expr)
1312 , mOperation(op)
1313 , mPost(post) {
1314 mExpression->setParent(this);
1315 }
1320 Crement(const Crement& other)
1321 : mExpression(other.mExpression->copy())
1322 , mOperation(other.mOperation)
1323 , mPost(other.mPost) {
1324 mExpression->setParent(this);
1325 }
1326 ~Crement() override = default;
1327
1329 Crement* copy() const override final { return new Crement(*this); }
1331 NodeType nodetype() const override { return Node::CrementNode; }
1333 const char* nodename() const override { return "crement"; }
1335 const char* subname() const override { return "crmt"; }
1337 const Expression* basetype() const override { return this; }
1338 //
1340 size_t children() const override final { return 1; }
1342 const Expression* child(const size_t i) const override final {
1343 if (i == 0) return this->expression();
1344 return nullptr;
1345 }
1347 inline bool replacechild(const size_t i, Node* node) override final {
1348 if (i != 0) return false;
1349 Expression* expr = dynamic_cast<Expression*>(node);
1350 if (!expr) return false;
1351 mExpression.reset(expr);
1352 mExpression->setParent(this);
1353 return true;
1354 }
1355
1360 inline Operation operation() const { return mOperation; }
1363 inline bool increment() const { return mOperation == Increment; }
1366 inline bool decrement() const { return mOperation == Decrement; }
1369 inline bool pre() const { return !mPost; }
1372 inline bool post() const { return mPost; }
1376 const Expression* expression() const { return mExpression.get(); }
1377 private:
1378 Expression::UniquePtr mExpression;
1379 const Operation mOperation;
1380 const bool mPost;
1381 };
1382
1388 struct UnaryOperator : public Expression
1389 {
1390 using UniquePtr = std::unique_ptr<UnaryOperator>;
1391
1397 UnaryOperator(Expression* expr, const tokens::OperatorToken op)
1398 : mExpression(expr)
1399 , mOperation(op) {
1400 assert(mExpression);
1401 mExpression->setParent(this);
1402 }
1407 UnaryOperator(Expression* expr, const std::string& op)
1408 : UnaryOperator(expr, tokens::operatorTokenFromName(op)) {}
1413 UnaryOperator(const UnaryOperator& other)
1414 : mExpression(other.mExpression->copy())
1415 , mOperation(other.mOperation) {
1416 mExpression->setParent(this);
1417 }
1418 ~UnaryOperator() override = default;
1419
1421 UnaryOperator* copy() const override final { return new UnaryOperator(*this); }
1423 NodeType nodetype() const override { return Node::UnaryOperatorNode; }
1425 const char* nodename() const override { return "unary"; }
1427 const char* subname() const override { return "unry"; }
1429 const Expression* basetype() const override { return this; }
1431 size_t children() const override final { return 1; }
1433 const Expression* child(const size_t i) const override final {
1434 if (i == 0) return this->expression();
1435 return nullptr;
1436 }
1438 inline bool replacechild(const size_t i, Node* node) override final {
1439 if (i != 0) return false;
1440 Expression* expr = dynamic_cast<Expression*>(node);
1441 if (!expr) return false;
1442 mExpression.reset(expr);
1443 mExpression->setParent(this);
1444 return true;
1445 }
1446
1449 inline tokens::OperatorToken operation() const { return mOperation; }
1453 const Expression* expression() const { return mExpression.get(); }
1454 private:
1455 Expression::UniquePtr mExpression;
1456 const tokens::OperatorToken mOperation;
1457 };
1458
1463 struct Cast : public Expression
1464 {
1465 using UniquePtr = std::unique_ptr<Cast>;
1466
1472 Cast(Expression* expr, const tokens::CoreType type)
1473 : Expression()
1474 , mType(type)
1475 , mExpression(expr) {
1476 assert(mExpression);
1477 mExpression->setParent(this);
1478 }
1483 Cast(const Cast& other)
1484 : Expression()
1485 , mType(other.mType)
1486 , mExpression(other.mExpression->copy()) {
1487 mExpression->setParent(this);
1488 }
1489 ~Cast() override = default;
1490
1492 Cast* copy() const override final { return new Cast(*this); }
1494 NodeType nodetype() const override { return Node::CastNode; }
1496 const char* nodename() const override { return "cast"; }
1498 const char* subname() const override { return "cast"; }
1500 const Expression* basetype() const override { return this; }
1502 size_t children() const override final { return 1; }
1504 const Expression* child(const size_t i) const override final {
1505 if (i == 0) return this->expression();
1506 return nullptr;
1507 }
1509 inline bool replacechild(const size_t i, Node* node) override final {
1510 if (i != 0) return false;
1511 Expression* expr = dynamic_cast<Expression*>(node);
1512 if (!expr) return false;
1513 mExpression.reset(expr);
1514 mExpression->setParent(this);
1515 return true;
1516 }
1517
1520 inline tokens::CoreType type() const { return mType; }
1525 inline std::string typestr() const {
1526 return ast::tokens::typeStringFromToken(mType);
1527 }
1531 const Expression* expression() const { return mExpression.get(); }
1532 private:
1533 const tokens::CoreType mType;
1534 Expression::UniquePtr mExpression;
1535 };
1536
1540 struct FunctionCall : public Expression
1541 {
1542 using UniquePtr = std::unique_ptr<FunctionCall>;
1543
1550 FunctionCall(const std::string& function,
1551 Expression* argument = nullptr)
1552 : mFunctionName(function)
1553 , mArguments() {
1554 this->append(argument);
1555 }
1562 FunctionCall(const std::string& function,
1563 const std::vector<Expression*>& arguments)
1564 : mFunctionName(function)
1565 , mArguments() {
1566 mArguments.reserve(arguments.size());
1567 for (Expression* arg : arguments) {
1568 this->append(arg);
1569 }
1570 }
1575 FunctionCall(const FunctionCall& other)
1576 : mFunctionName(other.mFunctionName)
1577 , mArguments() {
1578 mArguments.reserve(other.mArguments.size());
1579 for (const Expression::UniquePtr& expr : other.mArguments) {
1580 this->append(expr->copy());
1581 }
1582 }
1583 ~FunctionCall() override = default;
1584
1586 FunctionCall* copy() const override final { return new FunctionCall(*this); }
1588 NodeType nodetype() const override { return Node::FunctionCallNode; }
1590 const char* nodename() const override { return "function call"; }
1592 const char* subname() const override { return "call"; }
1594 const Expression* basetype() const override { return this; }
1596 size_t children() const override final { return this->size(); }
1598 const Expression* child(const size_t i) const override final {
1599 if (i >= mArguments.size()) return nullptr;
1600 return mArguments[i].get();
1601 }
1603 inline bool replacechild(const size_t i, Node* node) override final {
1604 if (mArguments.size() <= i) return false;
1605 Expression* expr = dynamic_cast<Expression*>(node);
1606 mArguments[i].reset(expr);
1607 mArguments[i]->setParent(this);
1608 return true;
1609 }
1610
1613 inline const std::string& name() const { return mFunctionName; }
1616 inline size_t numArgs() const { return mArguments.size(); }
1617
1619 inline size_t size() const { return mArguments.size(); }
1622 inline bool empty() const { return mArguments.empty(); }
1626 inline void append(Expression* expr) {
1627 if (expr) {
1628 mArguments.emplace_back(expr);
1629 expr->setParent(this);
1630 }
1631 }
1632 private:
1633 const std::string mFunctionName;
1634 std::vector<Expression::UniquePtr> mArguments;
1635 };
1636
1640 struct Keyword : public Statement
1641 {
1642 using UniquePtr = std::unique_ptr<Keyword>;
1643
1646 Keyword(const tokens::KeywordToken keyw)
1647 : mKeyword(keyw) {}
1650 Keyword(const Keyword& other)
1651 : mKeyword(other.mKeyword) {}
1652 ~Keyword() override = default;
1653
1655 Keyword* copy() const override final { return new Keyword(*this); }
1657 NodeType nodetype() const override { return Node::KeywordNode; }
1659 const char* nodename() const override { return "keyword"; }
1661 const char* subname() const override { return "keyw"; }
1663 const Statement* basetype() const override { return this; }
1665 size_t children() const override final { return 0; }
1667 const Node* child(const size_t) const override final {
1668 return nullptr;
1669 }
1672 inline tokens::KeywordToken keyword() const { return mKeyword; }
1673
1674 private:
1675 const tokens::KeywordToken mKeyword;
1676 };
1677
1685 struct ArrayUnpack : public Expression
1686 {
1687 using UniquePtr = std::unique_ptr<ArrayUnpack>;
1688
1698 ArrayUnpack(Expression* expr,
1699 Expression* component0,
1700 Expression* component1 = nullptr)
1701 : mIdx0(component0)
1702 , mIdx1(component1)
1703 , mExpression(expr) {
1704 assert(mIdx0);
1705 assert(mExpression);
1706 mIdx0->setParent(this);
1707 if(mIdx1) mIdx1->setParent(this);
1708 mExpression->setParent(this);
1709 }
1714 ArrayUnpack(const ArrayUnpack& other)
1715 : ArrayUnpack(other.mExpression->copy(),
1716 other.mIdx0->copy(),
1717 other.mIdx1 ? other.mIdx1->copy() : nullptr) {}
1718
1719 ~ArrayUnpack() override = default;
1720
1722 ArrayUnpack* copy() const override final { return new ArrayUnpack(*this); }
1724 NodeType nodetype() const override { return Node::ArrayUnpackNode; }
1726 const char* nodename() const override { return "array unpack"; }
1728 const char* subname() const override { return "unpk"; }
1730 const Expression* basetype() const override { return this; }
1732 size_t children() const override final { return 3; }
1734 const Statement* child(const size_t i) const override final {
1735 if (i == 0) return this->component0();
1736 if (i == 1) return this->component1();
1737 if (i == 2) return this->expression();
1738 return nullptr;
1739 }
1741 inline bool replacechild(const size_t i, Node* node) override final {
1742 if (i > 2) return false;
1743 Expression* expr = dynamic_cast<Expression*>(node);
1744 if (!expr) return false;
1745 if (i == 0) mIdx0.reset(expr);
1746 if (i == 1) mIdx1.reset(expr);
1747 if (i == 2) mExpression.reset(expr);
1748 expr->setParent(this);
1749 return true;
1750 }
1751
1755 inline const Expression* component0() const { return mIdx0.get(); }
1760 inline const Expression* component1() const { return mIdx1.get(); }
1764 inline const Expression* expression() const { return mExpression.get(); }
1773 inline bool isMatrixIndex() const {
1774 // assumes that component0 is always valid
1775 return static_cast<bool>(this->component1());
1776 }
1777 private:
1778 Expression::UniquePtr mIdx0, mIdx1;
1779 Expression::UniquePtr mExpression;
1780 };
1781
1784 struct ArrayPack : public Expression
1785 {
1786 using UniquePtr = std::unique_ptr<ArrayPack>;
1787
1793 ArrayPack(Expression* expression)
1794 : mExpressions() {
1795 this->append(expression);
1796 }
1801 ArrayPack(const std::vector<Expression*>& arguments)
1802 : mExpressions() {
1803 mExpressions.reserve(arguments.size());
1804 for (Expression* arg : arguments) {
1805 this->append(arg);
1806 }
1807 }
1811 ArrayPack(const ArrayPack& other)
1812 : mExpressions() {
1813 mExpressions.reserve(other.mExpressions.size());
1814 for (const Expression::UniquePtr& expr : other.mExpressions) {
1815 this->append(expr->copy());
1816 }
1817 }
1818 ~ArrayPack() override = default;
1819
1821 ArrayPack* copy() const override final { return new ArrayPack(*this); }
1823 NodeType nodetype() const override { return Node::ArrayPackNode; }
1825 const char* nodename() const override { return "array pack"; }
1827 const char* subname() const override { return "pack"; }
1829 const Expression* basetype() const override { return this; }
1831 size_t children() const override final { return this->size(); }
1833 const Expression* child(const size_t i) const override final {
1834 if (i >= mExpressions.size()) return nullptr;
1835 return mExpressions[i].get();
1836 }
1838 inline bool replacechild(const size_t i, Node* node) override final {
1839 if (mExpressions.size() <= i) return false;
1840 Expression* expr = dynamic_cast<Expression*>(node);
1841 mExpressions[i].reset(expr);
1842 mExpressions[i]->setParent(this);
1843 return true;
1844 }
1845
1847 inline size_t size() const { return mExpressions.size(); }
1850 inline bool empty() const { return mExpressions.empty(); }
1854 inline void append(Expression* expr) {
1855 if (expr) {
1856 mExpressions.emplace_back(expr);
1857 expr->setParent(this);
1858 }
1859 }
1860 private:
1861 std::vector<Expression::UniquePtr> mExpressions;
1862 };
1863
1873 struct Attribute : public Variable
1874 {
1875 using UniquePtr = std::unique_ptr<Attribute>;
1876
1884 Attribute(const std::string& name, const tokens::CoreType type,
1885 const bool inferred = false)
1886 : Variable(name)
1887 , mType(type)
1888 , mTypeInferred(inferred) {}
1896 Attribute(const std::string& name, const std::string& token,
1897 const bool inferred = false)
1898 : Attribute(name, tokens::tokenFromTypeString(token), inferred) {}
1903 Attribute(const Attribute& other)
1904 : Variable(other)
1905 , mType(other.mType)
1906 , mTypeInferred(other.mTypeInferred) {}
1907 ~Attribute() override = default;
1908
1910 Attribute* copy() const override final { return new Attribute(*this); }
1912 NodeType nodetype() const override { return Node::AttributeNode; }
1914 const char* nodename() const override { return "attribute"; }
1916 const char* subname() const override { return "atr"; }
1918 const Variable* basetype() const override { return this; }
1919
1923 inline bool inferred() const { return mTypeInferred; }
1926 inline tokens::CoreType type() const { return mType; }
1931 inline std::string typestr() const {
1932 return ast::tokens::typeStringFromToken(mType);
1933 }
1937 inline std::string tokenname() const {
1938 return Attribute::tokenFromNameType(this->name(), this->type());
1939 }
1940
1944 static inline char symbolseparator() { return '@'; }
1957 static inline std::string
1958 tokenFromNameType(const std::string& name, const tokens::CoreType type) {
1959 return ast::tokens::typeStringFromToken(type) +
1960 Attribute::symbolseparator() + name;
1961 }
1973 static inline bool
1974 nametypeFromToken(const std::string& token, std::string* name, std::string* type) {
1975 const size_t at = token.find(symbolseparator());
1976 if (at == std::string::npos) return false;
1977 if (type) {
1978 *type = token.substr(0, at);
1979 if (type->empty()) {
1980 *type = ast::tokens::typeStringFromToken(tokens::CoreType::FLOAT);
1981 }
1982 }
1983 if (name) *name = token.substr(at + 1, token.size());
1984 return true;
1985 }
1986 private:
1987 const tokens::CoreType mType;
1988 const bool mTypeInferred;
1989 };
1990
2001 struct ExternalVariable : public Variable
2002 {
2003 using UniquePtr = std::unique_ptr<ExternalVariable>;
2004
2008 ExternalVariable(const std::string& name, const tokens::CoreType type)
2009 : Variable(name)
2010 , mType(type) {}
2016 ExternalVariable(const std::string& name, const std::string& token)
2017 : ExternalVariable(name, tokens::tokenFromTypeString(token)) {}
2023 ExternalVariable(const ExternalVariable& other)
2024 : Variable(other)
2025 , mType(other.mType) {}
2026 ~ExternalVariable() override = default;
2027
2029 ExternalVariable* copy() const override final {
2030 return new ExternalVariable(*this);
2031 }
2033 NodeType nodetype() const override { return Node::ExternalVariableNode; }
2035 const char* nodename() const override { return "external"; }
2037 const char* subname() const override { return "ext"; }
2039 const Variable* basetype() const override { return this; }
2040
2043 inline tokens::CoreType type() const { return mType; }
2048 inline std::string typestr() const {
2049 return ast::tokens::typeStringFromToken(mType);
2050 }
2054 inline const std::string tokenname() const {
2055 return ExternalVariable::tokenFromNameType(this->name(), this->type());
2056 }
2057
2061 static inline char symbolseparator() { return '$'; }
2074 static inline std::string
2075 tokenFromNameType(const std::string& name, const tokens::CoreType type) {
2076 return ast::tokens::typeStringFromToken(type) +
2077 ExternalVariable::symbolseparator() + name;
2078 }
2090 static inline bool
2091 nametypeFromToken(const std::string& token, std::string* name, std::string* type) {
2092 const size_t at = token.find(symbolseparator());
2093 if (at == std::string::npos) return false;
2094 if (type) {
2095 *type = token.substr(0, at);
2096 if (type->empty()) {
2097 *type = ast::tokens::typeStringFromToken(tokens::CoreType::FLOAT);
2098 }
2099 }
2100 if (name) *name = token.substr(at + 1, token.size());
2101 return true;
2102 }
2103 private:
2104 const tokens::CoreType mType;
2105 };
2106
2111 struct Local : public Variable
2112 {
2113 using UniquePtr = std::unique_ptr<Local>;
2114
2117 Local(const std::string& name)
2118 : Variable(name) {}
2119 ~Local() override = default;
2120
2122 Local* copy() const override final { return new Local(*this); }
2124 NodeType nodetype() const override { return Node::LocalNode; }
2126 const char* nodename() const override { return "local"; }
2128 const char* subname() const override { return "lcl"; }
2130 const Variable* basetype() const override { return this; }
2131 };
2132
2138 struct DeclareLocal : public Statement
2139 {
2140 using UniquePtr = std::unique_ptr<DeclareLocal>;
2141
2146 DeclareLocal(const tokens::CoreType type, Local* local, Expression* init = nullptr)
2147 : mType(type)
2148 , mLocal(local)
2149 , mInit(init) {
2150 assert(mLocal);
2151 mLocal->setParent(this);
2152 if (mInit) mInit->setParent(this);
2153 }
2158 DeclareLocal(const DeclareLocal& other)
2159 : mType(other.mType)
2160 , mLocal(other.mLocal->copy())
2161 , mInit(other.hasInit() ? other.mInit->copy() : nullptr) {
2162 mLocal->setParent(this);
2163 if (mInit) mInit->setParent(this);
2164 }
2165 ~DeclareLocal() override = default;
2166
2168 DeclareLocal* copy() const override final { return new DeclareLocal(*this); }
2170 NodeType nodetype() const override { return Node::DeclareLocalNode; }
2172 const char* nodename() const override { return "declaration"; }
2174 const char* subname() const override { return "dcl"; }
2176 const Statement* basetype() const override { return this; }
2178 size_t children() const override final { return 2; }
2180 const Expression* child(const size_t i) const override final {
2181 if (i == 0) return this->local();
2182 if (i == 1) return this->init();
2183 return nullptr;
2184 }
2186 inline bool replacechild(const size_t i, Node* node) override final {
2187 if (i > 1) return false;
2188 if (i == 0) {
2189 Local* local = dynamic_cast<Local*>(node);
2190 if (!local) return false;
2191 mLocal.reset(local);
2192 mLocal->setParent(this);
2193 }
2194 else {
2195 Expression* init = dynamic_cast<Expression*>(node);
2196 if (!init) return false;
2197 mInit.reset(init);
2198 mInit->setParent(this);
2199 }
2200 return true;
2201 }
2202
2206 inline tokens::CoreType type() const { return mType; }
2211 inline std::string typestr() const {
2212 return ast::tokens::typeStringFromToken(mType);
2213 }
2216 inline bool hasInit() const { return static_cast<bool>(this->init()); }
2217
2220 const Local* local() const { return mLocal.get(); }
2223 const Expression* init() const { return mInit.get(); }
2224
2225 private:
2226 const tokens::CoreType mType;
2227 Local::UniquePtr mLocal; // could be Variable for attribute declaration
2228 Expression::UniquePtr mInit;
2229 };
2230
2231
2251 template <typename T>
2252 struct Value : public ValueBase
2253 {
2254 using UniquePtr = std::unique_ptr<Value<T>>;
2255
2256 using Type = T;
2260 using ContainerType = typename std::conditional<
2261 std::is_integral<T>::value, uint64_t, T>::type;
2262
2265 static constexpr bool IsSupported =
2266 std::is_same<T, bool>::value ||
2267 std::is_same<T, int16_t>::value ||
2268 std::is_same<T, int32_t>::value ||
2269 std::is_same<T, int64_t>::value ||
2270 std::is_same<T, float>::value ||
2271 std::is_same<T, double>::value;
2272 static_assert(IsSupported, "Incompatible ast::Value node instantiated.");
2273
2277 Value(const ContainerType value)
2278 : mValue(value) {}
2283 Value(const Value<T>& other)
2284 : mValue(other.mValue) {}
2285 ~Value() override = default;
2286
2288 Value<Type>* copy() const override final { return new Value<Type>(*this); }
2290 NodeType nodetype() const override {
2291 if (std::is_same<T, bool>::value) return Node::ValueBoolNode;
2292 if (std::is_same<T, int16_t>::value) return Node::ValueInt16Node;
2293 if (std::is_same<T, int32_t>::value) return Node::ValueInt32Node;
2294 if (std::is_same<T, int64_t>::value) return Node::ValueInt64Node;
2295 if (std::is_same<T, float>::value) return Node::ValueFloatNode;
2296 if (std::is_same<T, double>::value) return Node::ValueDoubleNode;
2297 }
2299 const char* nodename() const override {
2300 if (std::is_same<T, bool>::value) return "boolean literal";
2301 if (std::is_same<T, int16_t>::value) return "int16 literal";
2302 if (std::is_same<T, int32_t>::value) return "int32 literal";
2303 if (std::is_same<T, int64_t>::value) return "int64 literal";
2304 if (std::is_same<T, float>::value) return "float (32bit) literal";
2305 if (std::is_same<T, double>::value) return "double (64bit) literal";
2306 }
2308 const char* subname() const override {
2309 if (std::is_same<T, bool>::value) return "bool";
2310 if (std::is_same<T, int16_t>::value) return "i16";
2311 if (std::is_same<T, int32_t>::value) return "i32";
2312 if (std::is_same<T, int64_t>::value) return "i64";
2313 if (std::is_same<T, float>::value) return "flt";
2314 if (std::is_same<T, double>::value) return "dbl";
2315 }
2317 const ValueBase* basetype() const override { return this; }
2318
2321 inline ContainerType asContainerType() const { return mValue; }
2324 inline T value() const { return static_cast<T>(mValue); }
2325
2326 private:
2327 // A container of a max size defined by LiteralValueContainer to hold values
2328 // which may be out of scope. This is only used for warnings
2329 const ContainerType mValue;
2330 };
2331
2333 template <>
2334 struct Value<std::string> : public ValueBase
2335 {
2336 using UniquePtr = std::unique_ptr<Value<std::string>>;
2337
2338 using Type = std::string;
2341 Value(const Type& value) : mValue(value) {}
2346 Value(const Value<Type>& other) : mValue(other.mValue) {}
2347 ~Value() override = default;
2348
2349 Value<Type>* copy() const override final { return new Value<Type>(*this); }
2350 NodeType nodetype() const override { return Node::ValueStrNode; }
2351 const char* nodename() const override { return "string value"; }
2352 const char* subname() const override { return "str"; }
2353 const ValueBase* basetype() const override { return this; }
2354
2357 inline const std::string& value() const { return mValue; }
2358 private:
2359 const Type mValue;
2360 };
2361
2362 // fwd declaration for backwards compatibility, see Parse.h/.cc for definition
2363 openvdb::ax::ast::Tree::Ptr parse(const char* code);
2364
2365 } // namespace ast
2366 } // namespace ax
2367
2368 } // namespace OPENVDB_VERSION_NAME
2369 } // namespace openvdb
2370
2371 #endif // OPENVDB_AX_AST_HAS_BEEN_INCLUDED
2372
openvdb::v8_2::ax::ast::ConditionalStatement::branchCount
size_t branchCount() const
Query the number of branches held by this ConditionalStatement. This is only ever 1 or 2.
Definition: AST.h:960
openvdb::v8_2::ax::ast::ConditionalStatement::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:927
openvdb::v8_2::ax::ast::Attribute::Attribute
Attribute(const Attribute &other)
Deep copy constructor for a Attribute.
Definition: AST.h:1903
openvdb::v8_2::ax::ast::Node::ValueInt16Node
@ ValueInt16Node
Definition: AST.h:139
openvdb::v8_2::ax::ast::Variable::basetype
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:347
openvdb::v8_2::ax::ast::ConditionalStatement::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:911
openvdb::v8_2::ax::ast::Value::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:2308
openvdb::v8_2::ax::ast::Variable::Variable
Variable(const Variable &other)
Definition: AST.h:342
openvdb::v8_2::ax::ast::Keyword
Keywords represent keyword statements defining changes in execution. These include those that define ...
Definition: AST.h:1641
openvdb::v8_2::ax::ast::Crement::pre
bool pre() const
Query if this Crement node represents a pre crement ++a.
Definition: AST.h:1369
openvdb::v8_2::ax::ast::ExternalVariable::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:2033
openvdb::v8_2::ax::ast::tokens::OperatorToken
OperatorToken
Definition: Tokens.h:151
openvdb::v8_2::ax::ast::ArrayUnpack::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1741
openvdb::v8_2::ax::ast::CommaOperator::size
size_t size() const
Alias for CommaOperator::children.
Definition: AST.h:676
openvdb::v8_2::ax::ast::StatementList::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:434
openvdb::v8_2::ax::ast::BinaryOperator::copy
BinaryOperator * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1033
openvdb::v8_2::ax::ast::Node::ExternalVariableNode
@ ExternalVariableNode
Definition: AST.h:133
openvdb::v8_2::ax::ast::ExternalVariable::symbolseparator
static char symbolseparator()
Static method returning the symbol associated with an ExternalVariable access as defined by AX Gramma...
Definition: AST.h:2061
openvdb::v8_2::ax::ast::Loop::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:790
openvdb::v8_2::ax::ast::CommaOperator::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:667
openvdb::v8_2::ax::ast::ArrayPack::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1825
openvdb::v8_2::ax::ast::BinaryOperator::child
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1047
openvdb::v8_2::ax::ast::ArrayPack::child
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1833
openvdb::v8_2::ax::ast::Local
Local AST nodes represent a single accesses to a local variable. The only store the name of the varia...
Definition: AST.h:2112
openvdb::v8_2::ax::ast::DeclareLocal::typestr
std::string typestr() const
Get the declaration type as a front end AX type/token string.
Definition: AST.h:2211
openvdb::v8_2::ax::ast::Node::ArrayPackNode
@ ArrayPackNode
Definition: AST.h:135
openvdb::v8_2::ax::ast::Loop::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:771
openvdb::v8_2::ax::ast::UnaryOperator::UnaryOperator
UnaryOperator(Expression *expr, const tokens::OperatorToken op)
Construct a new UnaryOperator with a given tokens::OperatorToken and a valid expression,...
Definition: AST.h:1397
openvdb::v8_2::ax::ast::Value< std::string >::Value
Value(const Type &value)
Construct a new Value string from a string.
Definition: AST.h:2341
openvdb::v8_2::ax::ast::ArrayPack::size
size_t size() const
Alias for ArrayPack::children.
Definition: AST.h:1847
openvdb::v8_2::ax::ast::Loop::hasIter
bool hasIter() const
Query if this Loop has a valid iteration expression list.
Definition: AST.h:830
openvdb::v8_2::ax::ast::Node::CastNode
@ CastNode
Definition: AST.h:130
openvdb::v8_2::ax::ast::Node::child
virtual const Node * child(const size_t index) const =0
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
openvdb::v8_2::ax::ast::Node::ArrayUnpackNode
@ ArrayUnpackNode
Definition: AST.h:136
openvdb::v8_2::ax::ast::Node::basetype
virtual const Node * basetype() const
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:175
openvdb::v8_2::ax::ast::ConditionalStatement::basetype
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:915
openvdb::v8_2::ax::ast::ExternalVariable::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:2035
openvdb::v8_2::ax::ast::DeclareLocal::child
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:2180
openvdb::v8_2::ax::ast::Loop::Loop
Loop(const Loop &other)
Deep copy constructor for an Loop, performing a deep copy on the condition, body and initial Statemen...
Definition: AST.h:749
openvdb::v8_2::ax::ast::Crement::operation
Operation operation() const
Query the type of the Crement operation. This does not hold post or pre-crement information.
Definition: AST.h:1360
openvdb::v8_2::ax::ast::Expression
Expressions are comprised of full or potentially partial parts of a full statement that may not neces...
Definition: AST.h:326
openvdb::v8_2::ax::ast::Node::ValueDoubleNode
@ ValueDoubleNode
Definition: AST.h:143
openvdb::v8_2::ax::ast::Attribute::Attribute
Attribute(const std::string &name, const tokens::CoreType type, const bool inferred=false)
Construct a new Attribute with a given name and type. Optionally also mark it as inferred type creati...
Definition: AST.h:1884
openvdb::v8_2::ax::ast::ArrayPack::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1827
openvdb::v8_2::ax::ast::CommaOperator::CommaOperator
CommaOperator(const CommaOperator &other)
Deep copy constructor for an CommaOperator, performing a deep copy on every held expression,...
Definition: AST.h:637
openvdb::v8_2::ax::ast::Node::subname
virtual const char * subname() const =0
Virtual method for accessing node name information.
openvdb::v8_2::ax::ast::Node::setParent
void setParent(Node *parent)
Set this node's parent. This is used during construction of an AST and should not be used.
Definition: AST.h:276
openvdb::v8_2::ax::ast::ArrayUnpack::component1
const Expression * component1() const
Access a const pointer to the second component being used as an abstract Expression.
Definition: AST.h:1760
openvdb::v8_2::ax::ast::Node::ValueInt32Node
@ ValueInt32Node
Definition: AST.h:140
openvdb::v8_2::ax::ast::Node::children
virtual size_t children() const =0
Virtual method for accessing child information. Returns the number of children a given AST node owns.
openvdb::v8_2::ax::ast::ArrayUnpack::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1732
openvdb::v8_2::ax::ast::BinaryOperator::basetype
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1043
openvdb::v8_2::ax::ast::Keyword::copy
Keyword * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1655
openvdb::v8_2::ax::ast::Block
A Block node represents a scoped list of statements. It may comprise of 0 or more statements,...
Definition: AST.h:476
openvdb::v8_2::ax::ast::StatementList::StatementList
StatementList(const StatementList &other)
Deep copy constructor for a StatementList, performing a deep copy on every held statement,...
Definition: AST.h:415
openvdb::v8_2::ax::ast::Keyword::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1659
openvdb::v8_2::ax::ast::Value< std::string >::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:2351
openvdb::v8_2::ax::ast::Attribute::type
tokens::CoreType type() const
Access the type that was used to access this attribute.
Definition: AST.h:1926
openvdb::v8_2::ax::ast::ValueBase::child
const Node * child(const size_t) const override
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:368
openvdb::v8_2::ax::ast::ConditionalStatement::condition
const Expression * condition() const
Access a const pointer to the ConditionalStatements condition as an abstract expression.
Definition: AST.h:966
openvdb::v8_2::ax::ast::FunctionCall::size
size_t size() const
Alias for FunctionCall::children.
Definition: AST.h:1619
openvdb::v8_2::ax::ast::FunctionCall::child
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1598
openvdb::v8_2::ax::ast::Expression::basetype
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:330
openvdb::v8_2::ax::ast::Value< std::string >::basetype
const ValueBase * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:2353
openvdb::v8_2::ax::ast::Loop::initial
const Statement * initial() const
Access a const pointer to the Loop initial statement as an abstract statement.
Definition: AST.h:841
openvdb::v8_2::ax::ast::AssignExpression
AssignExpressions represents a similar object construction to a BinaryOperator. AssignExpressions can...
Definition: AST.h:1198
openvdb::v8_2::ax::ast::ArrayUnpack::component0
const Expression * component0() const
Access a const pointer to the first component being used as an abstract Expression.
Definition: AST.h:1755
openvdb::v8_2::ax::ast::Node::ValueInt64Node
@ ValueInt64Node
Definition: AST.h:141
openvdb::v8_2::ax::ast::FunctionCall::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1596
openvdb::v8_2::ax::ast::ArrayUnpack::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1726
openvdb::v8_2::ax::ast::Cast::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1494
openvdb::v8_2::ax::ast::Statement
Abstract (pure-virtual) AST nodes.
Definition: AST.h:312
openvdb::v8_2::ax::ast::ValueBase::children
size_t children() const override
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:367
openvdb::v8_2::ax::ast::Tree::Tree
Tree(const Tree &other)
Deep copy constructor for a Tree, performing a deep copy on the held Block, ensuring parent informati...
Definition: AST.h:578
FOR
@ FOR
Definition: axparser.h:63
openvdb::v8_2::ax::ast::Local::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:2128
openvdb::v8_2::ax::ast::ArrayPack::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1823
openvdb::v8_2::ax::ast::Block::Block
Block(const std::vector< Statement * > &statements)
Construct a new Block from a vector of statements, transferring ownership of all valid statements to ...
Definition: AST.h:495
openvdb::v8_2::ax::ast::Tree
A Tree is the highest concrete (non-abstract) node in the entire AX AST hierarchy....
Definition: AST.h:562
openvdb::v8_2::ax::ast::Node::TernaryOperatorNode
@ TernaryOperatorNode
Definition: AST.h:129
openvdb::v8_2::ax::ast::Loop::loopType
tokens::LoopToken loopType() const
Query the type of loop held on this node.
Definition: AST.h:824
openvdb::v8_2::ax::ast::TernaryOperator::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1139
openvdb::v8_2::ax::ast::tokens::typeStringFromToken
std::string typeStringFromToken(const CoreType type)
Definition: Tokens.h:118
openvdb::v8_2::ax::ast::ExternalVariable::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:2037
openvdb::v8_2::ax::ast::Block::~Block
~Block() override=default
openvdb::v8_2::ax::ast::ExternalVariable::typestr
std::string typestr() const
Get the access type as a front end AX type/token string.
Definition: AST.h:2048
openvdb::v8_2::ax::ast::Node::ValueBoolNode
@ ValueBoolNode
Definition: AST.h:138
openvdb::v8_2::ax::ast::Variable::Variable
Variable(const std::string &name)
Definition: AST.h:340
openvdb::v8_2::ax::ast::BinaryOperator::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1039
openvdb::v8_2::ax::ast::DeclareLocal::DeclareLocal
DeclareLocal(const tokens::CoreType type, Local *local, Expression *init=nullptr)
Construct a new DeclareLocal with a given name and type.
Definition: AST.h:2146
openvdb::v8_2::ax::ast::Cast::Cast
Cast(Expression *expr, const tokens::CoreType type)
Construct a new Cast with a valid expression and a target tokens::CoreType, transferring ownership of...
Definition: AST.h:1472
openvdb::v8_2::ax::ast::DeclareLocal::basetype
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:2176
openvdb::v8_2::ax::ast::ArrayUnpack::basetype
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1730
openvdb::v8_2::ax::ast::Attribute::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1916
openvdb::v8_2::ax::ast::ArrayUnpack::~ArrayUnpack
~ArrayUnpack() override=default
openvdb::v8_2::ax::ast::ArrayPack::copy
ArrayPack * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1821
openvdb::v8_2::ax::ast::ExternalVariable::tokenname
const std::string tokenname() const
Construct and return the full external token identifier. See ExternalVariable::tokenFromNameType.
Definition: AST.h:2054
openvdb::v8_2::ax::ast::Value< std::string >::value
const std::string & value() const
Access the string.
Definition: AST.h:2357
openvdb::v8_2::ax::ast::Expression::UniquePtr
std::unique_ptr< Expression > UniquePtr
Definition: AST.h:327
openvdb::v8_2::ax::ast::Value
A Value (literal) AST node holds either literal text or absolute value information on all numerical,...
Definition: AST.h:2253
openvdb::v8_2::ax::ast::Attribute::nametypeFromToken
static bool nametypeFromToken(const std::string &token, std::string *name, std::string *type)
Static method which splits a valid attribute token into its name and type counterparts....
Definition: AST.h:1974
openvdb::v8_2::ax::ast::Attribute::copy
Attribute * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1910
EQUALS
@ EQUALS
Definition: axparser.h:115
openvdb::v8_2::ax::ast::ExternalVariable::ExternalVariable
ExternalVariable(const ExternalVariable &other)
Deep copy constructor for a ExternalVariable.
Definition: AST.h:2023
openvdb::v8_2::ax::ast::CommaOperator::CommaOperator
CommaOperator(Expression *expression)
Construct a new CommaOperator with a single expression, transferring ownership of the expression to t...
Definition: AST.h:617
openvdb::v8_2::ax::ast::ValueBase::~ValueBase
~ValueBase() override=default
openvdb::v8_2::ax::ast::Attribute::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1914
openvdb::v8_2::ax::ast::Node::StatementListNode
@ StatementListNode
Definition: AST.h:119
openvdb::v8_2::ax::ast::FunctionCall::FunctionCall
FunctionCall(const std::string &function, const std::vector< Expression * > &arguments)
Construct a new FunctionCall with a given function identifier and optional argument list,...
Definition: AST.h:1562
openvdb::v8_2::ax::ast::Attribute::basetype
const Variable * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1918
openvdb::v8_2::ax::ast::DeclareLocal::copy
DeclareLocal * copy() const override final
The deep copy method for a Node.
Definition: AST.h:2168
openvdb::v8_2::ax::ast::ExternalVariable::~ExternalVariable
~ExternalVariable() override=default
openvdb::v8_2::ax::ast::Tree::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:591
version.h
Library and file format version numbers.
openvdb::v8_2::ax::ast::ConditionalStatement::ConditionalStatement
ConditionalStatement(const ConditionalStatement &other)
Deep copy constructor for an ConditionalStatement, performing a deep copy on the condition and both h...
Definition: AST.h:894
openvdb::v8_2::ax::ast::StatementList::StatementList
StatementList()
Construct a new StatementList with an empty list.
Definition: AST.h:390
openvdb::v8_2::ax::ast::Cast::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1496
openvdb::v8_2::ax::ast::ArrayPack::empty
bool empty() const
Query whether this Expression list holds any valid expressions.
Definition: AST.h:1850
openvdb::v8_2::ax::ast::Cast::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1509
openvdb::v8_2::ax::ast::Block::UniquePtr
std::unique_ptr< Block > UniquePtr
Definition: AST.h:477
openvdb::v8_2::ax::ast::StatementList::copy
StatementList * copy() const override
The deep copy method for a Node.
Definition: AST.h:423
openvdb::v8_2::ax::ast::TernaryOperator::child
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1145
openvdb::v8_2::ax::ast::ArrayPack::ArrayPack
ArrayPack(Expression *expression)
Construct a new ArrayPack with a single expression, transferring ownership of the expression to the A...
Definition: AST.h:1793
openvdb::v8_2::ax::ast::Local::copy
Local * copy() const override final
The deep copy method for a Node.
Definition: AST.h:2122
openvdb::v8_2::ax::ast::Tree::~Tree
~Tree() override=default
openvdb::v8_2::ax::ast::Local::basetype
const Variable * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:2130
openvdb::v8_2::ax::ast::TernaryOperator::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1143
openvdb::v8_2::ax::ast::Crement::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1331
openvdb::v8_2::ax::ast::ArrayPack::ArrayPack
ArrayPack(const ArrayPack &other)
Deep copy constructor for a ArrayPack, performing a deep copy on all held arguments,...
Definition: AST.h:1811
openvdb::v8_2::ax::ast::Value< std::string >::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:2352
openvdb::v8_2::ax::ast::CommaOperator::append
void append(Expression *expr)
Append an expression to this CommaOperator, transferring ownership to the CommaOperator and updating ...
Definition: AST.h:683
openvdb::v8_2::ax::ast::Node::AttributeNode
@ AttributeNode
Definition: AST.h:131
openvdb::v8_2::ax::ast::Variable::child
const Node * child(const size_t) const override
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:350
FLOAT
@ FLOAT
Definition: axparser.h:75
openvdb::v8_2::ax::ast::Node::LocalNode
@ LocalNode
Definition: AST.h:137
openvdb::v8_2::ax::ast::Node::ValueFloatNode
@ ValueFloatNode
Definition: AST.h:142
openvdb::v8_2::ax::ast::AssignExpression::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1238
openvdb::v8_2::ax::ast::Block::size
size_t size() const
Alias for Block::children.
Definition: AST.h:540
openvdb::v8_2::ax::ast::Attribute::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1912
openvdb::v8_2::ax::ast::UnaryOperator::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1438
openvdb::v8_2::ax::ast::DeclareLocal::type
tokens::CoreType type() const
Access the type that was specified at which to create the given local.
Definition: AST.h:2206
openvdb::v8_2::ax::ast::Variable
Variables are a base type for Locals, Attributes and ExternalVariables. Unlike other abstract types,...
Definition: AST.h:337
openvdb::v8_2::ax::ast::AssignExpression::child
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1246
openvdb::v8_2::ax::ast::Loop::~Loop
~Loop() override=default
openvdb::v8_2::ax::ast::Local::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:2124
openvdb::v8_2::ax::ast::AssignExpression::copy
AssignExpression * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1232
openvdb::v8_2::ax::ast::Block::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:518
openvdb::v8_2::ax::ast::ExternalVariable::tokenFromNameType
static std::string tokenFromNameType(const std::string &name, const tokens::CoreType type)
Static method returning the full unique external token identifier by consolidating its name and type ...
Definition: AST.h:2075
openvdb::v8_2::ax::ast::Local::~Local
~Local() override=default
openvdb::v8_2::ax::ast::TernaryOperator::~TernaryOperator
~TernaryOperator() override=default
openvdb::v8_2::ax::ast::ConditionalStatement::hasFalse
bool hasFalse() const
Query if this ConditionalStatement has a valid 'false' branch.
Definition: AST.h:954
openvdb::v8_2::ax::ast::Loop::hasInit
bool hasInit() const
Query if this Loop has a valid initial statement.
Definition: AST.h:827
openvdb::v8_2::ax::ast::TernaryOperator::condition
const Expression * condition() const
Access a const pointer to the TernaryOperator conditional as an abstract expression.
Definition: AST.h:1176
openvdb::v8_2::ax::ast::Tree::basetype
const Node * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:593
openvdb::v8_2::ax::ast::Attribute::Attribute
Attribute(const std::string &name, const std::string &token, const bool inferred=false)
Construct a new Attribute with a given name and type/token string, delegating construction to the abo...
Definition: AST.h:1896
openvdb::v8_2::ax::ast::Keyword::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1661
openvdb::v8_2::ax::ast::StatementList::child
const Statement * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:436
openvdb::v8_2::ax::ast::Block::copy
Block * copy() const override final
The deep copy method for a Node.
Definition: AST.h:512
openvdb::v8_2::ax::ast::ExternalVariable
ExternalVariable represent any access to external (custom) data, typically associated with the '$' sy...
Definition: AST.h:2002
openvdb::v8_2::ax::ast::ConditionalStatement::falseBranch
const Block * falseBranch() const
Access a const pointer to the ConditionalStatements 'false' branch as a Block.
Definition: AST.h:974
openvdb::v8_2::ax::ast::Crement
A Crement node represents a single increment '++' and decrement '–' operation. As well as it's cremen...
Definition: AST.h:1294
openvdb::v8_2::ax::ast::Tree::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:589
openvdb::v8_2::ax::ast::TernaryOperator::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1137
openvdb::v8_2::ax::ast::Statement::copy
virtual Statement * copy() const override=0
The deep copy method for a Node.
openvdb::v8_2::ax::ast::Loop::condition
const Statement * condition() const
Access a const pointer to the Loop condition as an abstract statement.
Definition: AST.h:834
openvdb::v8_2::ax::ast::ArrayUnpack::isMatrixIndex
bool isMatrixIndex() const
Query whether this ArrayUnpack operation must be a matrix indexing operation by checking the presence...
Definition: AST.h:1773
openvdb::v8_2::ax::ast::StatementList
Concrete AST nodes.
Definition: AST.h:386
openvdb::v8_2::ax::ast::FunctionCall::FunctionCall
FunctionCall(const std::string &function, Expression *argument=nullptr)
Construct a new FunctionCall with a given function identifier and an optional argument,...
Definition: AST.h:1550
openvdb::v8_2::ax::ast::ValueBase
ValueBases are a base class for anything that holds a value (literal). Derived classes store the actu...
Definition: AST.h:361
openvdb::v8_2::ax::ast::Loop::body
const Block * body() const
Access a const pointer to the Loop body as a Block.
Definition: AST.h:837
openvdb::v8_2::ax::ast::ExternalVariable::ExternalVariable
ExternalVariable(const std::string &name, const tokens::CoreType type)
Construct a new ExternalVariable with a given name and type.
Definition: AST.h:2008
openvdb::v8_2::ax::ast::Attribute::~Attribute
~Attribute() override=default
openvdb::v8_2::ax::ast::Node::LoopNode
@ LoopNode
Definition: AST.h:123
openvdb::v8_2::ax::ast::Value::value
T value() const
Access the value as its requested (templated) type.
Definition: AST.h:2324
openvdb::v8_2::ax::ast::Attribute
Attributes represent any access to a primitive value, typically associated with the '@' symbol syntax...
Definition: AST.h:1874
openvdb::v8_2::ax::ast::ArrayUnpack::expression
const Expression * expression() const
Access a const pointer to the expression being indexed as an abstract Expression.
Definition: AST.h:1764
openvdb::v8_2::ax::ast::DeclareLocal::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:2170
openvdb::v8_2::ax::ast::Node::Ptr
std::shared_ptr< Node > Ptr
Definition: AST.h:103
openvdb::v8_2::ax::ast::Tree::ConstPtr
std::shared_ptr< const Tree > ConstPtr
Definition: AST.h:564
openvdb::v8_2::ax::ast::Node::copy
virtual Node * copy() const =0
The deep copy method for a Node.
openvdb::v8_2::ax::ast::StatementList::StatementList
StatementList(Statement *statement)
Construct a new StatementList with a single statement, transferring ownership of the statement to the...
Definition: AST.h:396
openvdb::v8_2::ax::ast::ArrayPack::basetype
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1829
openvdb::v8_2::ax::ast::Value::Value
Value(const Value< T > &other)
Deep copy constructor for a Value.
Definition: AST.h:2283
openvdb::v8_2::ax::ast::ConditionalStatement::copy
ConditionalStatement * copy() const override final
The deep copy method for a Node.
Definition: AST.h:905
openvdb::v8_2::ax::ast::Statement::~Statement
~Statement() override=default
openvdb::v8_2::ax::ast::AssignExpression::AssignExpression
AssignExpression(Expression *lhs, Expression *rhs, const tokens::OperatorToken op=tokens::EQUALS)
Construct a new AssignExpression with valid LHS and RHS expressions, transferring ownership of the ex...
Definition: AST.h:1207
openvdb::v8_2::ax::ast::DeclareLocal::hasInit
bool hasInit() const
Query if this declaration has an initialiser.
Definition: AST.h:2216
openvdb::v8_2::ax::ast::UnaryOperator::copy
UnaryOperator * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1421
openvdb::v8_2::ax::ast::FunctionCall::numArgs
size_t numArgs() const
Query the total number of arguments stored on this function.
Definition: AST.h:1616
openvdb::v8_2::ax::ast::CommaOperator::basetype
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:657
openvdb::v8_2::ax::ast::TernaryOperator::trueBranch
const Expression * trueBranch() const
Access a const pointer to the TernaryOperator true expression as an abstract expression.
Definition: AST.h:1180
openvdb::v8_2::ax::ast::Node::CrementNode
@ CrementNode
Definition: AST.h:126
openvdb::v8_2::ax::ast::ConditionalStatement
ConditionalStatements represents all combinations of 'if', 'else' and 'else if' syntax and semantics....
Definition: AST.h:864
openvdb::v8_2::ax::ast::CommaOperator::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:651
openvdb::v8_2::ax::ast::Node::NodeType
NodeType
An enumerated list of node types for all concrete node types. These can be used for faster evaluation...
Definition: AST.h:117
openvdb::v8_2::ax::ast::Cast::Cast
Cast(const Cast &other)
Deep copy constructor for a Cast node, performing a deep copy on the underlying expressions,...
Definition: AST.h:1483
openvdb::v8_2::ax::ast::UnaryOperator::UnaryOperator
UnaryOperator(const UnaryOperator &other)
Deep copy constructor for a UnaryOperator, performing a deep copy on the underlying expressions,...
Definition: AST.h:1413
openvdb::v8_2::ax::ast::UnaryOperator::operation
tokens::OperatorToken operation() const
Query the type of unary operation held on this node.
Definition: AST.h:1449
openvdb::v8_2::ax::ast::Value< std::string >::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:2350
openvdb::v8_2::ax::ast::Loop::Loop
Loop(const tokens::LoopToken loopType, Statement *condition, Block *body, Statement *init=nullptr, Expression *iter=nullptr)
Construct a new Loop with the type defined by a tokens::LoopToken, a condition Statement,...
Definition: AST.h:722
openvdb::v8_2::ax::ast::AssignExpression::rhs
const Expression * rhs() const
Access a const pointer to the AssignExpression RHS as an.
Definition: AST.h:1283
openvdb::v8_2::ax::ast::Keyword::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1665
openvdb::v8_2::ax::ast::DeclareLocal
DeclareLocal AST nodes symbolize a single type declaration of a local variable. These store the local...
Definition: AST.h:2139
openvdb::v8_2::ax::ast::Loop::basetype
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:777
openvdb::v8_2::ax::ast::Loop
Loops represent for, while and do-while loop constructs. These all consist of a condition - evaluated...
Definition: AST.h:708
openvdb::v8_2::ax::ast::AssignExpression::lhs
const Expression * lhs() const
Access a const pointer to the AssignExpression LHS as an abstract expression.
Definition: AST.h:1279
openvdb::v8_2::ax::ast::Block::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:530
openvdb::v8_2::ax::ast::Crement::Operation
Operation
A simple enum representing the crement type.
Definition: AST.h:1298
openvdb::v8_2::ax::ast::CommaOperator::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:655
openvdb::v8_2::ax::ast::ArrayPack::~ArrayPack
~ArrayPack() override=default
openvdb::v8_2::ax::ast::Local::UniquePtr
std::unique_ptr< Local > UniquePtr
Definition: AST.h:2113
openvdb::v8_2::ax::ast::AssignExpression::operation
tokens::OperatorToken operation() const
Query the actual operational type of this AssignExpression. For simple (non-compound) AssignExpressio...
Definition: AST.h:1275
openvdb::v8_2::ax::ast::tokens::KeywordToken
KeywordToken
Definition: Tokens.h:315
openvdb::v8_2::ax::ast::Cast::copy
Cast * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1492
openvdb::v8_2::ax::ast::ConditionalStatement::child
const Statement * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:920
openvdb::v8_2::ax::ast::ArrayUnpack::copy
ArrayUnpack * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1722
openvdb::v8_2::ax::ast::UnaryOperator::UnaryOperator
UnaryOperator(Expression *expr, const std::string &op)
Construct a new UnaryOperator with a string, delegating construction to the above UnaryOperator const...
Definition: AST.h:1407
openvdb::v8_2::ax::ast::Crement::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1340
openvdb::v8_2::ax::ast::ArrayUnpack
ArrayUnpack represent indexing operations into AX container types, primarily vectors and matrices ind...
Definition: AST.h:1686
openvdb::v8_2::ax::ast::CommaOperator::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:653
openvdb::v8_2::ax::ast::Value::copy
Value< Type > * copy() const override final
The deep copy method for a Node.
Definition: AST.h:2288
openvdb::v8_2::ax::ast::Crement::~Crement
~Crement() override=default
openvdb::v8_2::ax::ast::Crement::basetype
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1337
openvdb::v8_2::ax::ast::Loop::copy
Loop * copy() const override final
The deep copy method for a Node.
Definition: AST.h:769
openvdb::v8_2::ax::ast::Node::FunctionCallNode
@ FunctionCallNode
Definition: AST.h:132
openvdb::v8_2::ax::ast::Node::KeywordNode
@ KeywordNode
Definition: AST.h:124
openvdb::v8_2::ax::ast::Block::Block
Block()
Construct a new Block with an empty list.
Definition: AST.h:480
openvdb::v8_2::ax::ast::StatementList::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:425
openvdb::v8_2::ax::ast::Node::DeclareLocalNode
@ DeclareLocalNode
Definition: AST.h:134
openvdb::v8_2::ax::ast::ValueBase::basetype
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:365
openvdb::v8_2::ax::ast::BinaryOperator::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1037
openvdb::v8_2::ax::ast::Loop::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:780
openvdb::v8_2::ax::ast::Block::addStatement
void addStatement(Statement *stmnt)
Adds a statement to this block, transferring ownership to the block and updating parent data on the s...
Definition: AST.h:544
openvdb::v8_2::ax::ast::BinaryOperator::BinaryOperator
BinaryOperator(Expression *left, Expression *right, const tokens::OperatorToken op)
Construct a new BinaryOperator with a given tokens::OperatorToken and a valid LHS and RHS expression,...
Definition: AST.h:999
openvdb::v8_2::ax::ast::Node::nodetype
virtual NodeType nodetype() const =0
Virtual method for accessing node type information.
openvdb::v8_2::ax::ast::Crement::decrement
bool decrement() const
Query if this Crement node represents an decrement –.
Definition: AST.h:1366
openvdb::v8_2::ax::ast::CommaOperator::copy
CommaOperator * copy() const override final
The deep copy method for a Node.
Definition: AST.h:647
openvdb::v8_2::ax::ast::Node::UnaryOperatorNode
@ UnaryOperatorNode
Definition: AST.h:127
openvdb::v8_2::ax::ast::ArrayUnpack::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1724
openvdb::v8_2::ax::ast::DeclareLocal::local
const Local * local() const
Access a const pointer to the Local.
Definition: AST.h:2220
openvdb::v8_2::ax::ast::TernaryOperator::hasTrue
bool hasTrue() const
Query whether or not this has an optional if-true branch.
Definition: AST.h:1172
openvdb::v8_2::ax::ast::Tree::child
const Block * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:598
openvdb::v8_2::ax::ast::UnaryOperator
A UnaryOperator represents a single unary operation on an expression. The operation type is stored as...
Definition: AST.h:1389
openvdb::v8_2::ax::ast::Crement::Crement
Crement(const Crement &other)
Deep copy constructor for a Crement, performing a deep copy on the underlying expressions,...
Definition: AST.h:1320
openvdb::v8_2::ax::ast::Block::Block
Block(Statement *statement)
Construct a new Block with a single statement, transferring ownership of the statement to the block a...
Definition: AST.h:486
openvdb::v8_2::ax::ast::UnaryOperator::basetype
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1429
openvdb::v8_2::ax::ast::StatementList::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:427
openvdb::v8_2::ax::ast::FunctionCall::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1590
openvdb::v8_2::ax::ast::Value::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:2299
openvdb::v8_2::ax::ast::Node::BinaryOperatorNode
@ BinaryOperatorNode
Definition: AST.h:128
openvdb::v8_2::ax::ast::Value::Type
T Type
Definition: AST.h:2256
openvdb::v8_2::ax::ast::Loop::iteration
const Expression * iteration() const
Access a const pointer to the Loop iteration Expression.
Definition: AST.h:844
openvdb::v8_2::ax::ast::Variable::children
size_t children() const override
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:349
openvdb::v8_2::ax::ast::CommaOperator
Definition: AST.h:607
openvdb::v8_2::ax::ast::BinaryOperator::~BinaryOperator
~BinaryOperator() override=default
openvdb::v8_2::ax::ast::CommaOperator::empty
bool empty() const
Query whether this Expression list holds any valid expressions.
Definition: AST.h:679
openvdb::v8_2::ax::ast::ConditionalStatement::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:913
openvdb::v8_2::ax::ast::ConditionalStatement::trueBranch
const Block * trueBranch() const
Access a const pointer to the ConditionalStatements 'true' branch as a Block.
Definition: AST.h:970
openvdb::v8_2::ax::ast::Node::UniquePtr
std::unique_ptr< Node > UniquePtr
Definition: AST.h:104
openvdb::v8_2::ax::ast::ArrayPack
ArrayPacks represent temporary container creations of arbitrary sizes, typically generated through th...
Definition: AST.h:1785
openvdb::v8_2::ax::ast::Node
The base abstract node which determines the interface and required methods for all derived concrete n...
Definition: AST.h:102
Tokens.h
Various function and operator tokens used throughout the AST and code generation.
openvdb::v8_2::ax::ast::Cast::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1498
openvdb::v8_2::ax::ast::Value::ContainerType
typename std::conditional< std::is_integral< T >::value, uint64_t, T >::type ContainerType
Integers and Floats store their value as ContainerType, which is guaranteed to be at least large enou...
Definition: AST.h:2261
openvdb::v8_2::ax::ast::tokens::tokenFromTypeString
CoreType tokenFromTypeString(const std::string &type)
Definition: Tokens.h:66
openvdb::v8_2::ax::ast::TernaryOperator::copy
TernaryOperator * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1131
openvdb::v8_2::ax::ast::Variable::name
const std::string & name() const
Definition: AST.h:352
openvdb::v8_2::ax::ast::UnaryOperator::child
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1433
openvdb::v8_2::ax::ast::StatementList::basetype
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:431
openvdb::v8_2::ax::ast::Keyword::keyword
tokens::KeywordToken keyword() const
Query the keyword held on this node.
Definition: AST.h:1672
openvdb::v8_2::ax::ast::ExternalVariable::type
tokens::CoreType type() const
Access the type that was used to access this external variable.
Definition: AST.h:2043
openvdb::v8_2::ax::ast::Cast::type
tokens::CoreType type() const
Access to the target type.
Definition: AST.h:1520
openvdb::v8_2::ax::ast::BinaryOperator::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1053
openvdb::v8_2::ax::ast::Attribute::tokenname
std::string tokenname() const
Construct and return the full attribute token identifier. See Attribute::tokenFromNameType.
Definition: AST.h:1937
openvdb::v8_2::ax::ast::Crement::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1347
openvdb::v8_2::ax::ast::ArrayPack::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1831
openvdb::v8_2::ax::ast::Statement::UniquePtr
std::unique_ptr< Statement > UniquePtr
Definition: AST.h:313
openvdb::v8_2::ax::ast::AssignExpression::basetype
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1242
openvdb::v8_2::ax::ast::FunctionCall::~FunctionCall
~FunctionCall() override=default
openvdb::v8_2::ax::ast::Expression::~Expression
~Expression() override=default
openvdb::v8_2::ax::ast::Node::AssignExpressionNode
@ AssignExpressionNode
Definition: AST.h:125
openvdb::v8_2::ax::ast::ArrayUnpack::child
const Statement * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1734
openvdb::v8_2::ax::ast::UnaryOperator::~UnaryOperator
~UnaryOperator() override=default
openvdb::v8_2::ax::ast::Value< std::string >::Type
std::string Type
Definition: AST.h:2338
openvdb::v8_2::ax::ast::Local::Local
Local(const std::string &name)
Construct a Local with a given name.
Definition: AST.h:2117
openvdb::v8_2::ax::ast::Block::child
const Statement * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:525
openvdb::v8_2::ax::ast::TernaryOperator::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1152
openvdb::v8_2::ax::ast::ArrayUnpack::ArrayUnpack
ArrayUnpack(Expression *expr, Expression *component0, Expression *component1=nullptr)
Construct a new ArrayUnpack with a valid expression, an initial component (as an expression) to the f...
Definition: AST.h:1698
openvdb::v8_2::ax::ast::Value< std::string >::copy
Value< Type > * copy() const override final
The deep copy method for a Node.
Definition: AST.h:2349
openvdb::v8_2::ax::ast::Loop::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:775
openvdb::v8_2::ax::ast::ArrayUnpack::ArrayUnpack
ArrayUnpack(const ArrayUnpack &other)
Deep copy constructor for a ArrayUnpack, performing a deep copy on the expression being indexed and a...
Definition: AST.h:1714
openvdb::v8_2::ax::ast::BinaryOperator::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1045
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:153
openvdb::v8_2::ax::ast::Loop::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:773
openvdb::v8_2::ax::ast::Cast::~Cast
~Cast() override=default
openvdb::v8_2::ax::ast::ArrayPack::append
void append(Expression *expr)
Appends an argument to this ArrayPack, transferring ownership to the ArrayPack and updating parent da...
Definition: AST.h:1854
openvdb::v8_2::ax::ast::Crement::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1335
openvdb::v8_2::ax::ast::ArrayPack::ArrayPack
ArrayPack(const std::vector< Expression * > &arguments)
Construct a new ArrayPack transferring ownership of any provided arguments to the ArrayPack and updat...
Definition: AST.h:1801
openvdb::v8_2::ax::ast::Tree::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:587
openvdb::v8_2::ax::ast::Value::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:2290
openvdb::v8_2::ax::ast::StatementList::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:441
openvdb::v8_2::ax::ast::Cast::basetype
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1500
openvdb::v8_2::ax::ast::TernaryOperator::TernaryOperator
TernaryOperator(Expression *conditional, Expression *trueExpression, Expression *falseExpression)
Construct a new TernaryOperator with a conditional expression and true (optional) and false expressio...
Definition: AST.h:1104
openvdb::v8_2::ax::ast::Block::Block
Block(const Block &other)
Deep copy constructor for a Block, performing a deep copy on every held statement,...
Definition: AST.h:504
openvdb::v8_2::ax::ast::tokens::CoreType
CoreType
Definition: Tokens.h:32
openvdb::v8_2::ax::ast::Attribute::inferred
bool inferred() const
Query whether this attribute was accessed via inferred syntax i.e. @P or @myattribute.
Definition: AST.h:1923
openvdb::v8_2::ax::ast::Node::CommaOperatorNode
@ CommaOperatorNode
Definition: AST.h:122
openvdb::v8_2::ax::ast::DeclareLocal::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:2178
openvdb::v8_2::ax::ast::FunctionCall::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1592
openvdb::v8_2::ax::ast::tokens::LoopToken
LoopToken
Definition: Tokens.h:297
openvdb::v8_2::ax::ast::TernaryOperator::falseBranch
const Expression * falseBranch() const
Access a const pointer to the TernaryOperator false expression as an abstract expression.
Definition: AST.h:1184
openvdb::v8_2::ax::ast::DeclareLocal::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:2172
openvdb::v8_2::ax::ast::AssignExpression::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1240
openvdb::v8_2::ax::ast::FunctionCall::name
const std::string & name() const
Access the function name/identifier.
Definition: AST.h:1613
openvdb::v8_2::ax::ast::Keyword::Keyword
Keyword(const Keyword &other)
Deep copy constructor for a Keyword.
Definition: AST.h:1650
openvdb::v8_2::ax::ast::Attribute::symbolseparator
static char symbolseparator()
Static method returning the symbol associated with an Attribute access as defined by AX Grammar.
Definition: AST.h:1944
openvdb::v8_2::ax::ast::parse
openvdb::ax::ast::Tree::Ptr parse(const char *code)
Construct an abstract syntax tree from a code snippet. A runtime exception will be thrown with the fi...
openvdb::v8_2::ax::ast::FunctionCall::empty
bool empty() const
Query whether this Expression list holds any valid expressions.
Definition: AST.h:1622
openvdb::v8_2::ax::ast::CommaOperator::child
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:662
std
Definition: Coord.h:587
openvdb::v8_2::ax::ast::StatementList::~StatementList
~StatementList() override=default
openvdb::v8_2::ax::ast::Crement::Crement
Crement(Expression *expr, const Operation op, bool post)
Construct a new Crement with a valid expression, transferring ownership of the expression to the Crem...
Definition: AST.h:1310
openvdb::v8_2::ax::ast::CommaOperator::CommaOperator
CommaOperator()
Construct a new CommaOperator with an expr set.
Definition: AST.h:611
openvdb::v8_2::ax::ast::ConditionalStatement::ConditionalStatement
ConditionalStatement(Expression *conditional, Block *trueBlock, Block *falseBlock=nullptr)
Construct a new ConditionalStatement with an Expression representing the primary condition,...
Definition: AST.h:877
openvdb::v8_2::ax::ast::Node::BlockNode
@ BlockNode
Definition: AST.h:120
openvdb::v8_2::ax::ast::Cast
Cast nodes represent the conversion of an underlying expression to a target type. Cast nodes are typi...
Definition: AST.h:1464
openvdb::v8_2::ax::ast::ValueBase::copy
virtual Expression * copy() const override=0
The deep copy method for a Node.
openvdb::v8_2::ax::ast::FunctionCall::FunctionCall
FunctionCall(const FunctionCall &other)
Deep copy constructor for a FunctionCall, performing a deep copy on all held function arguments,...
Definition: AST.h:1575
openvdb::v8_2::ax::ast::CommaOperator::~CommaOperator
~CommaOperator() override=default
openvdb::v8_2::ax::ast::DeclareLocal::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:2186
openvdb::v8_2::ax::ast::Crement::expression
const Expression * expression() const
Access a const pointer to the expression being crements as an abstract Expression.
Definition: AST.h:1376
openvdb::v8_2::ax::ast::Expression::copy
virtual Expression * copy() const override=0
The deep copy method for a Node.
openvdb::v8_2::ax::ast::Cast::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1502
openvdb::v8_2::ax::ast::Node::parent
const Node * parent() const
Access a const pointer to this nodes parent.
Definition: AST.h:271
openvdb::v8_2::ax::ast::BinaryOperator::rhs
const Expression * rhs() const
Access a const pointer to the BinaryOperator RHS as an abstract expression.
Definition: AST.h:1078
openvdb::v8_2::ax::ast::UnaryOperator::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1423
openvdb::v8_2::ax::ast::StatementList::StatementList
StatementList(const std::vector< Statement * > &statements)
Construct a new StatementList from a vector of statements, transferring ownership of all valid statem...
Definition: AST.h:405
openvdb::v8_2::ax::ast::AssignExpression::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1244
openvdb::v8_2::ax::ast::DeclareLocal::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:2174
openvdb::v8_2::ax::ast::DeclareLocal::init
const Expression * init() const
Access a const pointer to the initialiser.
Definition: AST.h:2223
openvdb::v8_2::ax::ast::ArrayPack::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1838
openvdb::v8_2::ax::ast::Value::asContainerType
ContainerType asContainerType() const
Access the value as its stored type.
Definition: AST.h:2321
openvdb::v8_2::ax::ast::FunctionCall::basetype
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1594
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:101
openvdb::v8_2::ax::ast::DeclareLocal::~DeclareLocal
~DeclareLocal() override=default
openvdb::v8_2::ax::ast::StatementList::addStatement
void addStatement(Statement *stmnt)
Adds a statement to this statement list, transferring ownership to the statement list and updating pa...
Definition: AST.h:455
openvdb::v8_2::ax::ast::BinaryOperator::BinaryOperator
BinaryOperator(Expression *left, Expression *right, const std::string &op)
Construct a new BinaryOperator with a string, delegating construction to the above BinaryOperator con...
Definition: AST.h:1015
openvdb::v8_2::ax::ast::FunctionCall::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1588
openvdb::v8_2::ax::ast::AssignExpression::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1236
openvdb::v8_2::ax::ast::ExternalVariable::copy
ExternalVariable * copy() const override final
The deep copy method for a Node.
Definition: AST.h:2029
openvdb::v8_2::ax::ast::Keyword::Keyword
Keyword(const tokens::KeywordToken keyw)
Construct a new Keyword with a given tokens::KeywordToken.
Definition: AST.h:1646
openvdb::v8_2::ax::ast::Loop::child
const Statement * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:782
openvdb::v8_2::ax::ast::Value< std::string >::~Value
~Value() override=default
openvdb::v8_2::ax::ast::TernaryOperator::TernaryOperator
TernaryOperator(const TernaryOperator &other)
Deep copy constructor for a TernaryOperator, performing a deep copy on held expressions,...
Definition: AST.h:1120
openvdb::v8_2::ax::ast::CommaOperator::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:660
openvdb::v8_2::ax::ast::Node::ConditionalStatementNode
@ ConditionalStatementNode
Definition: AST.h:121
openvdb::v8_2::ax::ast::DeclareLocal::DeclareLocal
DeclareLocal(const DeclareLocal &other)
Deep copy constructor for a DeclareLocal.
Definition: AST.h:2158
openvdb::v8_2::ax::ast::UnaryOperator::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1427
openvdb::v8_2::ax::ast::Node::TreeNode
@ TreeNode
Definition: AST.h:118
openvdb::v8_2::ax::ast::Keyword::child
const Node * child(const size_t) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1667
openvdb::v8_2::ax::ast::Block::basetype
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:520
openvdb::v8_2::ax::ast::FunctionCall::append
void append(Expression *expr)
Appends an argument to this function call, transferring ownership to the FunctionCall and updating pa...
Definition: AST.h:1626
openvdb::v8_2::ax::ast::Cast::typestr
std::string typestr() const
Get the target type as a front end AX type/token string.
Definition: AST.h:1525
openvdb::v8_2::ax::ast::FunctionCall::copy
FunctionCall * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1586
openvdb::v8_2::ax::ast::ExternalVariable::basetype
const Variable * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:2039
openvdb::v8_2::ax::ast::Node::~Node
virtual ~Node()=default
openvdb::v8_2::ax::ast::FunctionCall
FunctionCalls represent a single call to a function and any provided arguments. The argument list can...
Definition: AST.h:1541
openvdb::v8_2::ax::ast::Attribute::tokenFromNameType
static std::string tokenFromNameType(const std::string &name, const tokens::CoreType type)
Static method returning the full unique attribute token identifier by consolidating its name and type...
Definition: AST.h:1958
openvdb::v8_2::ax::ast::AssignExpression::AssignExpression
AssignExpression(const AssignExpression &other)
Deep copy constructor for an AssignExpression, performing a deep copy on both held expressions,...
Definition: AST.h:1222
openvdb::v8_2::ax::ast::tokens::operatorTokenFromName
OperatorToken operatorTokenFromName(const std::string &name)
Definition: Tokens.h:221
openvdb::v8_2::ax::ast::ConditionalStatement::~ConditionalStatement
~ConditionalStatement() override=default
openvdb::v8_2::ax::ast::Block::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:516
openvdb::v8_2::ax::ast::AssignExpression::~AssignExpression
~AssignExpression() override=default
openvdb::v8_2::ax::ast::ConditionalStatement::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:909
openvdb::v8_2::ax::ast::ExternalVariable::nametypeFromToken
static bool nametypeFromToken(const std::string &token, std::string *name, std::string *type)
Static method which splits a valid external token into its name and type counterparts....
Definition: AST.h:2091
openvdb::v8_2::ax::ast::Local::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:2126
openvdb::v8_2::ax::ast::Value::~Value
~Value() override=default
openvdb::v8_2::ax::ast::BinaryOperator::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1041
openvdb::v8_2::ax::ast::Crement::copy
Crement * copy() const override final
The deep copy method for a Node.
Definition: AST.h:1329
openvdb::v8_2::ax::ast::ExternalVariable::ExternalVariable
ExternalVariable(const std::string &name, const std::string &token)
Construct a new ExternalVariable with a given name and type/token string, delegating construction to ...
Definition: AST.h:2016
openvdb::v8_2::ax::ast::Crement::post
bool post() const
Query if this Crement node represents a post crement a++.
Definition: AST.h:1372
openvdb
Definition: openvdb/Exceptions.h:13
openvdb::v8_2::ax::ast::Value::Value
Value(const ContainerType value)
Directly construct a Value from a source integer, float or boolean, guaranteeing valid construction....
Definition: AST.h:2277
openvdb::v8_2::ax::ast::StatementList::size
size_t size() const
Alias for StatementList::children.
Definition: AST.h:451
openvdb::v8_2::ax::ast::Node::childidx
int64_t childidx() const
Returns the child index of this node in relation to its parent, or -1 if no valid index is found (usu...
Definition: AST.h:211
openvdb::v8_2::ax::ast::Variable::copy
virtual Variable * copy() const override=0
The deep copy method for a Node.
openvdb::v8_2::ax::ast::BinaryOperator::BinaryOperator
BinaryOperator(const BinaryOperator &other)
Deep copy constructor for a BinaryOperator, performing a deep copy on both held expressions,...
Definition: AST.h:1023
openvdb::v8_2::ax::ast::Crement::child
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1342
openvdb::v8_2::ax::ast::ConditionalStatement::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:918
openvdb::v8_2::ax::ast::Block::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:523
openvdb::v8_2::ax::ast::Tree::copy
Tree * copy() const override final
The deep copy method for a Node.
Definition: AST.h:585
openvdb::v8_2::ax::ast::Value< std::string >::Value
Value(const Value< Type > &other)
Deep copy constructor for a Value string.
Definition: AST.h:2346
openvdb::v8_2::ax::ast::Block::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:514
openvdb::v8_2::ax::ast::Crement::Increment
@ Increment
Definition: AST.h:1299
openvdb::v8_2::ax::ast::CommaOperator::CommaOperator
CommaOperator(const std::vector< Expression * > &expressions)
Construct a new CommaOperator from a vector of expression, transferring ownership of all valid expres...
Definition: AST.h:626
openvdb::v8_2::ax::ast::TernaryOperator::basetype
const Expression * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1141
openvdb::v8_2::ax::ast::TernaryOperator
A TernaryOperator represents a ternary (conditional) expression 'a ? b : c' which evaluates to 'b' if...
Definition: AST.h:1092
openvdb::v8_2::ax::ast::Cast::expression
const Expression * expression() const
Access a const pointer to the Cast node's expression as an abstract expression.
Definition: AST.h:1531
openvdb::v8_2::ax::ast::Variable::~Variable
~Variable() override=default
openvdb::v8_2::ax::ast::Node::Node
Node()=default
openvdb::v8_2::ax::ast::Crement::increment
bool increment() const
Query if this Crement node represents an incrementation ++.
Definition: AST.h:1363
openvdb::v8_2::ax::ast::Tree::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:596
openvdb::v8_2::ax::ast::Crement::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1333
openvdb::v8_2::ax::ast::AssignExpression::isCompound
bool isCompound() const
Query whether or not this is a compound AssignExpression. Compound AssignExpressions are assignments ...
Definition: AST.h:1271
openvdb::v8_2::ax::ast::FunctionCall::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1603
openvdb::v8_2::ax::ast::BinaryOperator
A BinaryOperator represents a single binary operation between a left hand side (LHS) and right hand s...
Definition: AST.h:988
openvdb::v8_2::ax::ast::UnaryOperator::expression
const Expression * expression() const
Access a const pointer to the UnaryOperator expression as an abstract expression.
Definition: AST.h:1453
openvdb::v8_2::ax::ast::ArrayUnpack::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:1728
openvdb::v8_2::ax::ast::Node::nodename
virtual const char * nodename() const =0
Virtual method for accessing node name information.
openvdb::v8_2::ax::ast::Statement::basetype
const Node * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:316
openvdb::v8_2::ax::ast::UnaryOperator::children
size_t children() const override final
Virtual method for accessing child information. Returns the number of children a given AST node owns.
Definition: AST.h:1431
openvdb::v8_2::ax::ast::Value::basetype
const ValueBase * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:2317
openvdb::v8_2::ax::ast::TernaryOperator::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1135
openvdb::v8_2::ax::ast::BinaryOperator::lhs
const Expression * lhs() const
Access a const pointer to the BinaryOperator LHS as an abstract expression.
Definition: AST.h:1074
openvdb::v8_2::ax::ast::Keyword::~Keyword
~Keyword() override=default
openvdb::v8_2::ax::ast::BinaryOperator::operation
tokens::OperatorToken operation() const
Query the type of binary operation held on this node.
Definition: AST.h:1070
openvdb::v8_2::ax::ast::Attribute::typestr
std::string typestr() const
Get the access type as a front end AX type/token string.
Definition: AST.h:1931
openvdb::v8_2::ax::ast::Cast::child
const Expression * child(const size_t i) const override final
Virtual method for accessing child information. Returns a const pointer to a child node at the given ...
Definition: AST.h:1504
openvdb::v8_2::ax::ast::Keyword::nodetype
NodeType nodetype() const override
Virtual method for accessing node type information.
Definition: AST.h:1657
openvdb::v8_2::ax::ast::UnaryOperator::nodename
const char * nodename() const override
Virtual method for accessing node name information.
Definition: AST.h:1425
openvdb::v8_2::ax::ast::Node::isType
bool isType() const
Query whether or not this node is of a specific (derived) type. This method should be used to check i...
Definition: AST.h:184
openvdb::v8_2::ax::ast::Keyword::basetype
const Statement * basetype() const override
Virtual method for accessing a node's base class. Note that if this is called explicitly on an instan...
Definition: AST.h:1663
openvdb::v8_2::ax::ast::StatementList::subname
const char * subname() const override
Virtual method for accessing node name information.
Definition: AST.h:429
openvdb::v8_2::ax::ast::Node::replace
bool replace(Node *node)
In place replacement. Attempts to replace this node at its specific location within its Abstract Synt...
Definition: AST.h:247
openvdb::v8_2::ax::ast::Tree::Tree
Tree(Block *block=new Block())
Construct a new Tree from a given Block, transferring ownership of the Block to the tree and updating...
Definition: AST.h:571
openvdb::v8_2::ax::ast::AssignExpression::replacechild
bool replacechild(const size_t i, Node *node) override final
Virtual method that attempted to replace a child at a given index with a provided node type.
Definition: AST.h:1252