#include "ir.h"
#include "ir_hierarchical_visitor.h"
+ir_hierarchical_visitor::ir_hierarchical_visitor()
+{
+ this->callback = NULL;
+ this->data = NULL;
+}
+
ir_visitor_status
ir_hierarchical_visitor::visit(ir_variable *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit(ir_constant *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit(ir_loop_jump *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit(ir_dereference_variable *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_loop *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_function_signature *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_function *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_expression *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_texture *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_swizzle *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_dereference_array *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_dereference_record *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_assignment *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_call *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_return *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_if *ir)
{
- (void) ir;
+ if (this->callback != NULL)
+ this->callback(ir, this->data);
+
return visit_continue;
}
class ir_hierarchical_visitor {
public:
+ ir_hierarchical_visitor();
+
/**
* \name Visit methods for leaf-node classes
*/
* Utility function to process a linked list of instructions with a visitor
*/
void run(struct exec_list *instructions);
+
+protected:
+ /**
+ * Callback function that is invoked on entry to each node visited.
+ *
+ * \warning
+ * Visitor classes derived from \c ir_hierarchical_visitor \b may \b not
+ * invoke this function. This can be used, for example, to cause the
+ * callback to be invoked on every node type execpt one.
+ */
+ void (*callback)(class ir_instruction *ir, void *data);
+
+ /**
+ * Extra data parameter passed to the per-node callback function
+ */
+ void *data;
};
#endif /* IR_HIERARCHICAL_VISITOR_H */