OpenVDB  9.0.1
Visitor.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
4 /// @file ast/Visitor.h
5 ///
6 /// @authors Nick Avramoussis
7 ///
8 /// @brief Contains the AX AST Node Visitor, providing default and
9 /// customizable traversal and visitation methods on a AST hierarchy.
10 /// Using the visitor pattern is the recommended way to implement
11 /// custom operations on AST nodes.
12 ///
13 
14 #ifndef OPENVDB_AX_AST_VISITOR_HAS_BEEN_INCLUDED
15 #define OPENVDB_AX_AST_VISITOR_HAS_BEEN_INCLUDED
16 
17 #include "AST.h"
18 #include "Tokens.h"
19 
20 #include <openvdb/version.h>
21 
22 #include <type_traits>
23 
24 namespace openvdb {
26 namespace OPENVDB_VERSION_NAME {
27 
28 namespace ax {
29 namespace ast {
30 
31 /// @brief The Visitor class uses the Curiously Recursive Template Pattern
32 /// (CRTP) to provide a customizable interface intended to be used by
33 /// clients wishing to perform custom operations over an AX Abstract
34 /// Syntax Tree (AST). By default the Visitor implements simple
35 /// traversal of all nodes, ensuring that each node on a well formed
36 /// AST is visited at least once. By deriving from the Visitor, users
37 /// are able to customize this default behavior and further manually
38 /// override specific node behavior to their needs. The function
39 /// options at the top of visitor can be overridden using CRTP to
40 /// control the prior default behavior, with the ability to override
41 /// the traverse() and visit() methods for the latter more granular
42 /// control.
43 ///
44 /// @details To commence a full visit of an AST, begin by calling traverse() on
45 /// a Node pointer. A visit is defined as one of the visit() methods
46 /// being called and accepting a Node type. Each node is is guaranteed
47 /// to be visited exactly once at its lowest concrete derived type.
48 /// Node inheritance hierarchies can also be visited (disable by
49 /// default, see Visitor::visitNodeHierarchies) The traverse() methods
50 /// define how each AST node accesses its children. The default
51 /// implementation is for each node to traverses its child pointers in
52 /// the order returned by the derived Node::child() method
53 /// (see Visitor::reverseChildVisits). You'll typically only require
54 /// overriding of the visit() methods for achieving most goals, however
55 /// you can utilize the traverse methods if you find that you require
56 /// more control over how the node hierarchy is accessed. The default
57 /// visit order is post order, where by nodes traverse and visit their
58 /// children first (see Visitor::postOrderNodes). Each visit method
59 /// returns a boolean value which, if false, allows for early
60 /// termination of the traversal. In the below example, we show a
61 /// Visitor capable of visiting every Local node type exactly once,
62 /// terminating if the Local variable is called "var".
63 ///
64 /// @par Example:
65 /// @code
66 /// struct LocalVisitor : public Visitor<LocalVisitor>
67 /// {
68 /// // Bring in all base methods to avoid hiding
69 /// using ast::Visitor<LocalVisitor>::traverse;
70 /// using ast::Visitor<LocalVisitor>::visit;
71 ///
72 /// // override the visit for Local AST nodes
73 /// inline bool visit(const Local* node) {
74 /// if (!node) return true;
75 /// if (node->name() == "var") return false;
76 /// return true;
77 /// }
78 /// };
79 ///
80 /// LocalVisitor visitor;
81 /// visitor.traverse(&tree);
82 /// @endcode
83 ///
84 /// @note The second template argument, ConstVisit, allows you to perform
85 /// non-const traversals over the AST. In this case, the visit and
86 /// traversal function signatures change to non-const pointers.
87 /// @note This design is heavily influenced by Clang's RecursiveVisitor.
88 ///
89 /// @tparam Derived The derived visitor to template on the base visitor,
90 /// using CRTP
91 /// @tparam ConstVisit Whether to visit const or non-const versions of the AST
92 /// nodes. Note that this value changes the class function
93 /// signatures.
94 template <typename Derived, bool ConstVisit=true>
95 struct Visitor
96 {
97  /// @brief Templated conditional which resolves to a const NodeT if
98  /// ConstVisit is true, or a non-const NodeT if ConstVisit is false
99  template <typename NodeT>
100  using NodeType = typename std::conditional<ConstVisit, const NodeT, NodeT>::type;
101 
102  /// @brief Accesses the derived class by static casting the current object.
103  /// Assumes use of the Curiously Recursive Template Pattern (CRTP).
104  inline Derived& derived() {
105  return *static_cast<Derived*>(this);
106  }
107 
108  /// @name Options
109  /// @{
110 
111  /// @brief Default behavior option. If true, this results in post-order
112  /// traversal, where node children are traversed and visited before
113  /// their parent node. If false, this results in pre-order
114  /// traversal, where by the current node is visited before the
115  /// node's children.
116  /// @details Post-order traversal (for each node):
117  /// 1. Traverse all children.
118  /// 2. Visit the current node.
119  /// Pre-order traversal (for each node):
120  /// 1. Visit the current node.
121  /// 2. Traverse all children.
122  inline bool postOrderNodes() const { return true; }
123 
124  /// @brief Default behavior option. Reverses the traversal order of child
125  /// nodes. If true, child nodes are accessed from last to first
126  /// index .i.e. Node::children() -> 0. If false, child nodes are
127  /// accessed from first to last .i.e. 0 -> Node::children()
128  inline bool reverseChildVisits() const { return false; }
129 
130  /// @brief Default behavior option. Controls whether nodes visit themselves
131  /// at each stage of their class hierarchy. If true, nodes perform
132  /// multiple visits on their potentially abstract base classes. If
133  /// false, only the concrete derived types are visited.
134  /// @details When disabled, abstract node visitor methods are never accessed
135  /// directly through the default Visitor implementation. These
136  /// types include Node, Statement, Expression, etc AST nodes.
137  /// If true, for each linearly inherited AST node, a visit is
138  /// performed on the entire hierarchy. For example, for a Local AST
139  /// node which derives from Variable -> Expression -> Statement ->
140  /// Node, 5 visits will be performed at each level.
141  inline bool visitNodeHierarchies() const { return false; }
142 
143  /// @brief Default behavior option. Reverses the traversal order of node
144  /// hierarchies. If true, hierarchical visits start at the very top
145  /// of their inheritance structure (always a Node AST node) and
146  /// visit downwards until the lowest derived concrete node is
147  /// reached. If false, hierarchical visits start at the lowest
148  /// derived concrete node and visit upwards until the very top of
149  /// their inheritance structure (always a Node AST node) is reached.
150  /// @note Has no effect if visitNodeHierarchies() is false
151  inline bool reverseHierarchyVisits() const { return false; }
152 
153  /// @}
154 
155  /// @name Traversals
156  /// @{
157 
158  /// @brief Default traversals for a given concrete AST node type
159  /// @return True if traversal should continue, false to terminate
160 
162  return this->defaultTraversal<ast::Tree>(tree);
163  }
164 
166  return this->defaultTraversal<ast::StatementList>(cond);
167  }
168 
170  return this->defaultTraversal<ast::Block>(block);
171  }
172 
174  return this->defaultTraversal<ast::CommaOperator>(comma);
175  }
176 
178  return this->defaultTraversal<ast::Loop>(loop);
179  }
180 
182  return this->defaultTraversal<ast::Keyword>(keyw);
183  }
184 
186  return this->defaultTraversal<ast::ConditionalStatement>(cond);
187  }
188 
190  return this->defaultTraversal<ast::AssignExpression>(asgn);
191  }
192 
194  return this->defaultTraversal<ast::Crement>(crmt);
195  }
196 
198  return this->defaultTraversal<ast::UnaryOperator>(unry);
199  }
200 
202  return this->defaultTraversal<ast::BinaryOperator>(bin);
203  }
204 
206  return this->defaultTraversal<ast::TernaryOperator>(tern);
207  }
208 
210  return this->defaultTraversal<ast::Cast>(cast);
211  }
212 
214  return this->defaultTraversal<ast::FunctionCall>(call);
215  }
216 
218  return this->defaultTraversal<ast::Attribute>(attr);
219  }
220 
222  return this->defaultTraversal<ast::ExternalVariable>(ext);
223  }
224 
226  return this->defaultTraversal<ast::DeclareLocal>(decl);
227  }
228 
230  return this->defaultTraversal<ast::Local>(loc);
231  }
232 
234  return this->defaultTraversal<ast::ArrayPack>(pack);
235  }
236 
238  return this->defaultTraversal<ast::ArrayUnpack>(pack);
239  }
240 
242  return this->defaultTraversal<ast::Value<bool>>(val);
243  }
244 
246  return this->defaultTraversal<ast::Value<int16_t>>(val);
247  }
248 
250  return this->defaultTraversal<ast::Value<int32_t>>(val);
251  }
252 
254  return this->defaultTraversal<ast::Value<int64_t>>(val);
255  }
256 
258  return this->defaultTraversal<ast::Value<float>>(val);
259  }
260 
262  return this->defaultTraversal<ast::Value<double>>(val);
263  }
264 
266  return this->defaultTraversal<ast::Value<std::string>>(val);
267  }
268 
269  /// @brief The default traversal method which is hit for all child
270  /// traversals. The correct derived traversal scheme is selected by
271  /// using the node enumerated type.
272  /// @note Only handles traversal on concrete node types.
274  if (!node) return true;
275  switch (node->nodetype()) {
276  case Node::TreeNode : return this->derived().traverse(static_cast<NodeType<ast::Tree>*>(node));
277  case Node::StatementListNode : return this->derived().traverse(static_cast<NodeType<ast::StatementList>*>(node));
278  case Node::BlockNode : return this->derived().traverse(static_cast<NodeType<ast::Block>*>(node));
279  case Node::CommaOperatorNode : return this->derived().traverse(static_cast<NodeType<ast::CommaOperator>*>(node));
280  case Node::LoopNode : return this->derived().traverse(static_cast<NodeType<ast::Loop>*>(node));
281  case Node::KeywordNode : return this->derived().traverse(static_cast<NodeType<ast::Keyword>*>(node));
282  case Node::ConditionalStatementNode : return this->derived().traverse(static_cast<NodeType<ast::ConditionalStatement>*>(node));
283  case Node::AssignExpressionNode : return this->derived().traverse(static_cast<NodeType<ast::AssignExpression>*>(node));
284  case Node::CrementNode : return this->derived().traverse(static_cast<NodeType<ast::Crement>*>(node));
285  case Node::UnaryOperatorNode : return this->derived().traverse(static_cast<NodeType<ast::UnaryOperator>*>(node));
286  case Node::BinaryOperatorNode : return this->derived().traverse(static_cast<NodeType<ast::BinaryOperator>*>(node));
287  case Node::TernaryOperatorNode : return this->derived().traverse(static_cast<NodeType<ast::TernaryOperator>*>(node));
288  case Node::CastNode : return this->derived().traverse(static_cast<NodeType<ast::Cast>*>(node));
289  case Node::AttributeNode : return this->derived().traverse(static_cast<NodeType<ast::Attribute>*>(node));
290  case Node::FunctionCallNode : return this->derived().traverse(static_cast<NodeType<ast::FunctionCall>*>(node));
291  case Node::ExternalVariableNode : return this->derived().traverse(static_cast<NodeType<ast::ExternalVariable>*>(node));
292  case Node::DeclareLocalNode : return this->derived().traverse(static_cast<NodeType<ast::DeclareLocal>*>(node));
293  case Node::ArrayPackNode : return this->derived().traverse(static_cast<NodeType<ast::ArrayPack>*>(node));
294  case Node::ArrayUnpackNode : return this->derived().traverse(static_cast<NodeType<ast::ArrayUnpack>*>(node));
295  case Node::LocalNode : return this->derived().traverse(static_cast<NodeType<ast::Local>*>(node));
296  case Node::ValueBoolNode : return this->derived().traverse(static_cast<NodeType<ast::Value<bool>>*>(node));
297  case Node::ValueInt16Node : return this->derived().traverse(static_cast<NodeType<ast::Value<int16_t>>*>(node));
298  case Node::ValueInt32Node : return this->derived().traverse(static_cast<NodeType<ast::Value<int32_t>>*>(node));
299  case Node::ValueInt64Node : return this->derived().traverse(static_cast<NodeType<ast::Value<int64_t>>*>(node));
300  case Node::ValueFloatNode : return this->derived().traverse(static_cast<NodeType<ast::Value<float>>*>(node));
301  case Node::ValueDoubleNode : return this->derived().traverse(static_cast<NodeType<ast::Value<double>>*>(node));
302  case Node::ValueStrNode : return this->derived().traverse(static_cast<NodeType<ast::Value<std::string>>*>(node));
303  default : return true;
304  }
305  }
306 
307  /// @}
308 
309  /// @name Visits
310  /// @{
311 
312  /// @brief Visits for abstract (pure-virtual) Node types.
313  /// @note These are only hit through the default behavior if
314  /// Visitor::visitNodeHierarchies is enabled.
315  /// @return True if traversal should continue, false to terminate
316  inline bool visit(NodeType<ast::Node>*) { return true; }
317  inline bool visit(NodeType<ast::Statement>*) { return true; }
318  inline bool visit(NodeType<ast::Expression>*) { return true; }
319  inline bool visit(NodeType<ast::Variable>*) { return true; }
320  inline bool visit(NodeType<ast::ValueBase>*) { return true; }
321 
322  /// @brief Visits for concrete Node types.
323  /// @return True if traversal should continue, false to terminate
324  inline bool visit(NodeType<ast::Tree>*) { return true; }
325  inline bool visit(NodeType<ast::StatementList>*) { return true; }
326  inline bool visit(NodeType<ast::Block>*) { return true; }
327  inline bool visit(NodeType<ast::CommaOperator>*) { return true; }
328  inline bool visit(NodeType<ast::Loop>*) { return true; }
329  inline bool visit(NodeType<ast::Keyword>*) { return true; }
330  inline bool visit(NodeType<ast::ConditionalStatement>*) { return true; }
331  inline bool visit(NodeType<ast::AssignExpression>*) { return true; }
332  inline bool visit(NodeType<ast::Crement>*) { return true; }
333  inline bool visit(NodeType<ast::UnaryOperator>*) { return true; }
334  inline bool visit(NodeType<ast::BinaryOperator>*) { return true; }
335  inline bool visit(NodeType<ast::TernaryOperator>*) { return true; }
336  inline bool visit(NodeType<ast::Cast>*) { return true; }
337  inline bool visit(NodeType<ast::FunctionCall>*) { return true; }
338  inline bool visit(NodeType<ast::Attribute>*) { return true; }
339  inline bool visit(NodeType<ast::ExternalVariable>*) { return true; }
340  inline bool visit(NodeType<ast::DeclareLocal>*) { return true; }
341  inline bool visit(NodeType<ast::Local>*) { return true; }
342  inline bool visit(NodeType<ast::ArrayPack>*) { return true; }
343  inline bool visit(NodeType<ast::ArrayUnpack>*) { return true; }
344  inline bool visit(NodeType<ast::Value<bool>>*) { return true; }
345  inline bool visit(NodeType<ast::Value<int16_t>>*) { return true; }
346  inline bool visit(NodeType<ast::Value<int32_t>>*) { return true; }
347  inline bool visit(NodeType<ast::Value<int64_t>>*) { return true; }
348  inline bool visit(NodeType<ast::Value<float>>*) { return true; }
349  inline bool visit(NodeType<ast::Value<double>>*) { return true; }
350  inline bool visit(NodeType<ast::Value<std::string>>*) { return true; }
351 
352  /// @}
353 
354 private:
355  /// @brief Enabled for const traversals, where by the node pointer is
356  /// returned
357  /// @param Const reference to an AST node
358  /// @return Const pointer to the node
359  template <bool V, typename NodeT>
360  inline typename std::enable_if<V, const NodeT*>::type
361  strip(const NodeT* node) {
362  return node;
363  }
364 
365  /// @brief Enabled for non-const traversals, where by a const stripped node
366  /// pointer is returned
367  /// @param Const reference to an AST node
368  /// @return Non-const pointer to the node
369  template <bool V, typename NodeT>
370  inline typename std::enable_if<!V, typename std::remove_const<NodeT>::type*>::type
371  strip(const NodeT* node) {
372  return const_cast<NodeT*>(node);
373  }
374 
375  /// @brief Implements recursive hierarchical visits to a given AST node
376  /// @tparam NodeT The node type
377  /// @param node The node to perform class hierarchy visits on
378  /// @return True if traversal should continue, false to terminate
379  template <typename NodeT>
380  bool hierarchyVisits(NodeT& node)
381  {
382  if (this->derived().reverseHierarchyVisits()) {
383  if (auto base = node.NodeT::basetype()) {
384  if (!hierarchyVisits(*base)) return false;
385  }
386  if (!this->derived().visit(this->strip<ConstVisit>(&node))) return false;
387  }
388  else {
389  if (!this->derived().visit(this->strip<ConstVisit>(&node))) return false;
390  if (auto base = node.NodeT::basetype()) {
391  return hierarchyVisits(*base);
392  }
393  }
394  return true;
395  }
396 
397  /// @brief Implements the default behavior for a traversal to a given AST
398  /// node
399  /// @tparam NodeT The node type
400  /// @param node The node to traverse
401  /// @return True if traversal should continue, false to terminate
402  template <typename NodeT>
403  inline bool defaultTraversal(NodeType<NodeT>* node)
404  {
405  if (!node) return true;
406  const size_t children = node->children();
407 
408  if (this->derived().postOrderNodes()) {
409  if (this->derived().reverseChildVisits()) {
410  if (children != 0) {
411  for (int64_t i = static_cast<int64_t>(children - 1); i >= 0; --i) {
412  auto child = this->strip<ConstVisit>(node->child(i));
413  if (!this->derived().traverse(child)) {
414  return false;
415  }
416  }
417  }
418  }
419  else {
420  for (size_t i = 0; i < children; ++i) {
421  auto child = this->strip<ConstVisit>(node->child(i));
422  if (!this->derived().traverse(child)) {
423  return false;
424  }
425  }
426  }
427  if (this->derived().visitNodeHierarchies()) {
428  return this->hierarchyVisits(*node);
429  }
430  else {
431  return this->derived().visit(node);
432  }
433  }
434  else {
435  if (this->derived().visitNodeHierarchies()) {
436  if (!this->hierarchyVisits(*node)) return false;
437  }
438  else {
439  if (!this->derived().visit(node)) return false;
440  }
441  if (this->derived().reverseChildVisits()) {
442  if (children != 0) {
443  for (int64_t i = static_cast<int64_t>(children - 1); i >= 0; --i) {
444  auto child = this->strip<ConstVisit>(node->child(i));
445  if (!this->derived().traverse(child)) {
446  return false;
447  }
448  }
449  }
450  }
451  else {
452  for (size_t i = 0; i < children; ++i) {
453  auto child = this->strip<ConstVisit>(node->child(i));
454  if (!this->derived().traverse(child)) {
455  return false;
456  }
457  }
458  }
459  return true;
460  }
461  }
462 };
463 
464 } // namespace ast
465 } // namespace ax
466 
467 } // namespace OPENVDB_VERSION_NAME
468 } // namespace openvdb
469 
470 #endif // OPENVDB_AX_AST_VISITOR_HAS_BEEN_INCLUDED
471 
bool traverse(NodeType< ast::Block > *block)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:169
bool visit(NodeType< ast::Value< bool >> *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:344
ChildT * child
Definition: GridBuilder.h:1286
Specialization of Values for strings.
Definition: AST.h:2334
bool traverse(NodeType< ast::Value< int32_t >> *val)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:249
Provides the definition for every abstract and concrete derived class which represent a particular ab...
bool traverse(NodeType< ast::TernaryOperator > *tern)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:205
bool visit(NodeType< ast::Value< int64_t >> *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:347
bool visit(NodeType< ast::Tree > *)
Visits for concrete Node types.
Definition: Visitor.h:324
bool visit(NodeType< ast::Value< double >> *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:349
bool visit(NodeType< ast::StatementList > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:325
typename std::conditional< true, const NodeT, NodeT >::type NodeType
Templated conditional which resolves to a const NodeT if ConstVisit is true, or a non-const NodeT if ...
Definition: Visitor.h:100
bool traverse(NodeType< ast::Keyword > *keyw)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:181
bool traverse(NodeType< ast::ExternalVariable > *ext)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:221
bool traverse(NodeType< ast::ArrayPack > *pack)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:233
bool visit(NodeType< ast::ArrayUnpack > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:343
bool traverse(NodeType< ast::DeclareLocal > *decl)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:225
bool visit(NodeType< ast::Variable > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:319
bool traverse(NodeType< ast::CommaOperator > *comma)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:173
A Value (literal) AST node holds either literal text or absolute value information on all numerical...
Definition: AST.h:2252
bool visit(NodeType< ast::Expression > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:318
bool visit(NodeType< ast::Attribute > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:338
bool visit(NodeType< ast::Statement > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:317
bool visit(NodeType< ast::BinaryOperator > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:334
bool visit(NodeType< ast::Value< int16_t >> *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:345
bool visit(NodeType< ast::TernaryOperator > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:335
bool traverse(NodeType< ast::BinaryOperator > *bin)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:201
The Visitor class uses the Curiously Recursive Template Pattern (CRTP) to provide a customizable inte...
Definition: Visitor.h:95
bool visitNodeHierarchies() const
Default behavior option. Controls whether nodes visit themselves at each stage of their class hierarc...
Definition: Visitor.h:141
bool traverse(NodeType< ast::Node > *node)
The default traversal method which is hit for all child traversals. The correct derived traversal sch...
Definition: Visitor.h:273
bool traverse(NodeType< ast::Attribute > *attr)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:217
bool visit(NodeType< ast::ValueBase > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:320
bool visit(NodeType< ast::Loop > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:328
bool visit(NodeType< ast::AssignExpression > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:331
bool visit(NodeType< ast::Value< int32_t >> *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:346
bool traverse(NodeType< ast::ConditionalStatement > *cond)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:185
bool traverse(NodeType< ast::AssignExpression > *asgn)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:189
Derived & derived()
Accesses the derived class by static casting the current object. Assumes use of the Curiously Recursi...
Definition: Visitor.h:104
bool reverseChildVisits() const
Default behavior option. Reverses the traversal order of child nodes. If true, child nodes are access...
Definition: Visitor.h:128
Definition: Exceptions.h:13
bool visit(NodeType< ast::CommaOperator > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:327
bool reverseHierarchyVisits() const
Default behavior option. Reverses the traversal order of node hierarchies. If true, hierarchical visits start at the very top of their inheritance structure (always a Node AST node) and visit downwards until the lowest derived concrete node is reached. If false, hierarchical visits start at the lowest derived concrete node and visit upwards until the very top of their inheritance structure (always a Node AST node) is reached.
Definition: Visitor.h:151
bool traverse(NodeType< ast::Value< int64_t >> *val)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:253
bool traverse(NodeType< ast::Loop > *loop)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:177
bool traverse(NodeType< ast::Value< bool >> *val)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:241
bool visit(NodeType< ast::Keyword > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:329
bool visit(NodeType< ast::ExternalVariable > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:339
bool visit(NodeType< ast::Block > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:326
bool traverse(NodeType< ast::StatementList > *cond)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:165
bool visit(NodeType< ast::Value< std::string >> *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:350
bool traverse(NodeType< ast::FunctionCall > *call)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:213
bool traverse(NodeType< ast::Value< double >> *val)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:261
bool traverse(NodeType< ast::Cast > *cast)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:209
bool visit(NodeType< ast::DeclareLocal > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:340
bool visit(NodeType< ast::Cast > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:336
bool traverse(NodeType< ast::Value< int16_t >> *val)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:245
bool visit(NodeType< ast::Local > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:341
bool traverse(NodeType< ast::Local > *loc)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:229
Various function and operator tokens used throughout the AST and code generation. ...
bool traverse(NodeType< ast::Value< std::string >> *val)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:265
bool visit(NodeType< ast::Crement > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:332
bool traverse(NodeType< ast::ArrayUnpack > *pack)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:237
bool visit(NodeType< ast::UnaryOperator > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:333
bool visit(NodeType< ast::Node > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:316
bool traverse(NodeType< ast::UnaryOperator > *unry)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:197
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
bool visit(NodeType< ast::FunctionCall > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:337
bool postOrderNodes() const
Default behavior option. If true, this results in post-order traversal, where node children are trave...
Definition: Visitor.h:122
bool visit(NodeType< ast::Value< float >> *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:348
bool traverse(NodeType< ast::Tree > *tree)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:161
bool traverse(NodeType< ast::Value< float >> *val)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:257
bool visit(NodeType< ast::ConditionalStatement > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:330
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202
bool visit(NodeType< ast::ArrayPack > *)
Visits for abstract (pure-virtual) Node types.
Definition: Visitor.h:342
bool traverse(NodeType< ast::Crement > *crmt)
Default traversals for a given concrete AST node type.
Definition: Visitor.h:193