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

List of all members.

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.
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.
int apply_to (citem_t *item, citem_t *parent)
 Traverse ctree.
int apply_to_exprs (citem_t *item, citem_t *parent)
 Traverse only expressions.
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.
virtual int visit_expr (cexpr_t *)
 Visit an expression.
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.
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.

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 1324 of file hexrays.hpp.


Constructor & Destructor Documentation

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 1367 of file hexrays.hpp.


Member Function Documentation

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:
item root of the ctree to traverse
parent parent of the specified item. can be specified as NULL.
Returns:
0 or a non-zero value returned by a visit_...() function

Definition at line 4288 of file hexrays.hpp.

References hexdsp.

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:
item root of the ctree to traverse
parent parent of the specified item. can be specified as NULL.
Returns:
0 or a non-zero value returned by a visit_...() function

Definition at line 4294 of file hexrays.hpp.

References hexdsp.

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 1423 of file hexrays.hpp.

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 1415 of file hexrays.hpp.

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 1354 of file hexrays.hpp.

References CV_PRUNE.

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 1407 of file hexrays.hpp.

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 1399 of file hexrays.hpp.