IDA C++ SDK 9.2
Loading...
Searching...
No Matches
ctree_visitor_t Struct Reference

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

#include <hexrays.hpp>

Inheritance diagram for ctree_visitor_t:
ctree_parentee_t cfunc_parentee_t

Public Member Functions

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

Public Attributes

int cv_flags
 Ctree visitor property bits
parents_t parents
 Vector of parents of the current item.
cblock_posvec_t bposvec
 Vector of block positions.

Detailed Description

A generic helper class that is used for ctree traversal.

When traversing the ctree, the currently visited ctree item and its children can be freely modified without interrupting the traversal. However, if a parent of the visited item is modified, the traversal must be immediately stopped by returning a non-zero value.

Constructor & Destructor Documentation

◆ ctree_visitor_t()

ctree_visitor_t::ctree_visitor_t ( int _flags)
inline

Constructor.

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

◆ ~ctree_visitor_t()

virtual ctree_visitor_t::~ctree_visitor_t ( )
inlinevirtual

Member Function Documentation

◆ maintain_parents()

bool ctree_visitor_t::maintain_parents ( ) const
inline

Should the parent information by maintained?

◆ must_prune()

bool ctree_visitor_t::must_prune ( ) const
inline

Should the traversal skip the children of the current item?

◆ must_restart()

bool ctree_visitor_t::must_restart ( ) const
inline

Should the traversal restart?

◆ is_postorder()

bool ctree_visitor_t::is_postorder ( ) const
inline

Should the leave...() functions be called?

◆ only_insns()

bool ctree_visitor_t::only_insns ( ) const
inline

Should all expressions be automatically pruned?

◆ prune_now()

void ctree_visitor_t::prune_now ( )
inline

Prune children.

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

◆ clr_prune()

void ctree_visitor_t::clr_prune ( )
inline

Do not prune children. This is an internal function, no need to call it.

◆ set_restart()

void ctree_visitor_t::set_restart ( )
inline

Restart the travesal. Meaningful only in apply_to_exprs()

◆ clr_restart()

void ctree_visitor_t::clr_restart ( )
inline

Do not restart. This is an internal function, no need to call it.

◆ apply_to()

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

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 nullptr.
Returns
0 or a non-zero value returned by a visit_...() function

◆ apply_to_exprs()

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

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 nullptr.
Returns
0 or a non-zero value returned by a visit_...() function

◆ parent_item()

citem_t * ctree_visitor_t::parent_item ( )
inline

Get parent of the current item as an item (statement or expression)

◆ parent_expr()

cexpr_t * ctree_visitor_t::parent_expr ( )
inline

Get parent of the current item as an expression.

◆ parent_insn()

cinsn_t * ctree_visitor_t::parent_insn ( )
inline

Get parent of the current item as a statement.

◆ visit_insn()

virtual int idaapi ctree_visitor_t::visit_insn ( cinsn_t * )
inlinevirtual

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.

◆ visit_expr()

virtual int idaapi ctree_visitor_t::visit_expr ( cexpr_t * )
inlinevirtual

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.

◆ leave_insn()

virtual int idaapi ctree_visitor_t::leave_insn ( cinsn_t * )
inlinevirtual

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.

◆ leave_expr()

virtual int idaapi ctree_visitor_t::leave_expr ( cexpr_t * )
inlinevirtual

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.

Member Data Documentation

◆ cv_flags

int ctree_visitor_t::cv_flags

◆ parents

parents_t ctree_visitor_t::parents

Vector of parents of the current item.

◆ bposvec

cblock_posvec_t ctree_visitor_t::bposvec

Vector of block positions.

Only cit_block and cit_try parents have the corresponding element in this vector.


The documentation for this struct was generated from the following file: