ctree_visitor_t Struct Reference

A generic helper class that is used for ctree traversal. More...

Inheritance diagram for ctree_visitor_t:
ctree_parentee_t cfunc_parentee_t

Public Member Functions

bool maintain_parents (void) const
 Should the parent information by maintained?
 
bool must_prune (void) const
 Should the traversal skip the children of the current item?
 
bool must_restart (void) const
 Should the traversal restart?
 
bool is_postorder (void) const
 Should the leave...() functions be called?
 
bool only_insns (void) const
 Should all expressions be automatically pruned?
 
void prune_now (void)
 Prune children. More...
 
void clr_prune (void)
 Do not prune children. This is an internal function, no need to call it.
 
void set_restart (void)
 Restart the travesal. Meaningful only in apply_to_exprs()
 
void clr_restart (void)
 Do not restart. This is an internal function, no need to call it.
 
 ctree_visitor_t (int _flags)
 Constructor. More...
 
 DEFINE_VIRTUAL_DTOR (ctree_visitor_t)
 
int apply_to (citem_t *item, citem_t *parent)
 Traverse ctree. More...
 
int apply_to_exprs (citem_t *item, citem_t *parent)
 Traverse only expressions. More...
 
cexpr_tparent_expr (void)
 Get parent of the current item as an expression.
 
cinsn_tparent_insn (void)
 Get parent of the current item as a statement.
 
virtual int visit_insn (cinsn_t *)
 Visit a statement. More...
 
virtual int visit_expr (cexpr_t *)
 Visit an expression. More...
 
virtual int leave_insn (cinsn_t *)
 Visit a statement after having visited its children This is a visitor function which should be overridden by a derived class to do some useful work. More...
 
virtual int leave_expr (cexpr_t *)
 Visit an expression after having visited its children This is a visitor function which should be overridden by a derived class to do some useful work. More...
 

Public Attributes

int cv_flags
 Ctree visitor property bits
 
parents_t parents
 Vector of parents of the current item.
 

Detailed Description

A generic helper class that is used for ctree traversal.

Examples:
hexrays_sample2.cpp, hexrays_sample3.cpp, and hexrays_sample7.cpp.

Definition at line 3359 of file hexrays.hpp.

Constructor & Destructor Documentation

◆ ctree_visitor_t()

ctree_visitor_t::ctree_visitor_t ( int  _flags)

Constructor.

This constructor can be used with CV_FAST, CV_PARENTS combined with CV_POST, CV_ONLYINS

Examples:
hexrays_sample7.cpp.

Definition at line 3402 of file hexrays.hpp.

Member Function Documentation

◆ apply_to()

int ctree_visitor_t::apply_to ( citem_t item,
citem_t parent 
)

Traverse ctree.

The traversal will start at the specified item and continue until of one the visit_...() functions return a non-zero value.

Parameters
itemroot of the ctree to traverse
parentparent of the specified item. can be specified as NULL.
Returns
0 or a non-zero value returned by a visit_...() function

Definition at line 8403 of file hexrays.hpp.

References hexdsp.

◆ apply_to_exprs()

int ctree_visitor_t::apply_to_exprs ( citem_t item,
citem_t parent 
)

Traverse only expressions.

The traversal will start at the specified item and continue until of one the visit_...() functions return a non-zero value.

Parameters
itemroot of the ctree to traverse
parentparent of the specified item. can be specified as NULL.
Returns
0 or a non-zero value returned by a visit_...() function

Definition at line 8409 of file hexrays.hpp.

References hexdsp.

◆ leave_expr()

virtual int ctree_visitor_t::leave_expr ( cexpr_t )
virtual

Visit an expression after having visited its children This is a visitor function which should be overridden by a derived class to do some useful work.

This visitor performs post-order traserval, i.e. an item is visited after its children.

Returns
0 to continue the traversal, nonzero to stop.

Definition at line 3459 of file hexrays.hpp.

◆ leave_insn()

virtual int ctree_visitor_t::leave_insn ( cinsn_t )
virtual

Visit a statement after having visited its children This is a visitor function which should be overridden by a derived class to do some useful work.

This visitor performs post-order traserval, i.e. an item is visited after its children.

Returns
0 to continue the traversal, nonzero to stop.

Definition at line 3451 of file hexrays.hpp.

◆ prune_now()

void ctree_visitor_t::prune_now ( void  )

Prune children.

This function may be called by a visitor() to skip all children of the current item.

Definition at line 3389 of file hexrays.hpp.

References CV_PRUNE.

◆ visit_expr()

virtual int ctree_visitor_t::visit_expr ( cexpr_t )
virtual

Visit an expression.

This is a visitor function which should be overridden by a derived class to do some useful work. This visitor performs pre-order traserval, i.e. an item is visited before its children.

Returns
0 to continue the traversal, nonzero to stop.
Examples:
hexrays_sample2.cpp, and hexrays_sample5.cpp.

Definition at line 3443 of file hexrays.hpp.

◆ visit_insn()

virtual int ctree_visitor_t::visit_insn ( cinsn_t )
virtual

Visit a statement.

This is a visitor function which should be overridden by a derived class to do some useful work. This visitor performs pre-order traserval, i.e. an item is visited before its children.

Returns
0 to continue the traversal, nonzero to stop.
Examples:
hexrays_sample3.cpp, hexrays_sample5.cpp, and hexrays_sample7.cpp.

Definition at line 3435 of file hexrays.hpp.