#include <iokernel/walker.h>
Inheritance diagram for Walker:
Public Types | |
enum | ApplyStatus { Continue, Stop, Abort, Truncate, Replaced } |
Status codes that can be returned by the operator(). More... | |
Public Methods | |
Walker (SuifEnv *the_env) | |
virtual | ~Walker () |
In case subclasses want to delete something. | |
virtual ApplyStatus | operator() (Address address, const MetaClass *_meta) = 0 |
Called by the walker to perform action on the data in address. More... | |
virtual bool | is_walkable (Address address, bool is_owned, const MetaClass *_meta) |
Determine if the tree rooted at the address should be walked Default implementation returns true iff is_owned is true. More... | |
virtual bool | is_visitable (Address address, const MetaClass *_meta) const |
Determine if operator() should be called on the data in address. More... | |
void | set_post_order () |
Set the order of walking to post_order. More... | |
void | set_pre_order () |
Set the order of walking to pre_order, which is the default. | |
bool | get_is_pre_order () const |
Get the order of walking. More... | |
void | set_address (Address new_address) |
Address | get_address () const |
SuifEnv* | get_env () const |
void | set_parent (Address addr) |
Address | get_parent () const |
virtual bool | get_makes_changes () const |
It is possible for nodes to be replaced during a walk. More... | |
virtual bool | is_changed (Address addr) const |
Should the node be ignored because it has been deleted or changed? This exists so that we do not need to try to develop the real meta class for a deleted object. More... |
This class is abstract. Generally, you will want to derive from SuifWalker found in suifkernel/suif_walker.h. The normal use of walkers is described in that file.
|
Status codes that can be returned by the operator().
The internal status should not be modified by the operator code.
Continue | Continue iteration. |
Stop | Stop iteration, normal termination. |
Abort | Stop with error condition. |
Truncate | Do not walk sub-objects of this object (pre-order only). |
Replaced |
Object has been replaced with a new object.
You must set the address of the new object by calling set_address before returning. |
|
|
In case subclasses want to delete something.
|
|
|
Get the order of walking.
|
It is possible for nodes to be replaced during a walk.
This is important when walking lists, as the contents of the list can change while the list is being walked.
So, if changes can occur, we must copy the list before walking it. get_makes_changes returns true if a walker changes the tree.
Reimplemented in ReplacingWalker.
|
|
Should the node be ignored because it has been deleted or changed? This exists so that we do not need to try to develop the real meta class for a deleted object.
Doing that will cause a seg fault
Reimplemented in ReplacingWalker.
|
Determine if operator() should be called on the data in address.
Default implementation always true.
address | points to the data. |
_meta | the meta class of the data pointed to by address. |
Reimplemented in SuifWalker.
|
Determine if the tree rooted at the address should be walked Default implementation returns true iff is_owned is true.
You can, for example, return false if you know that a node of interest cannot be contained inside a given node.
Notice the difference to is_visitable. The latter determines if the function operator should be called on a given node. This function controls walking of an entire subtree.
address | (a pointer to) a pointer. |
is_owned | true if the pointer pointed to by address is owned by this object. |
_meta | the meta class of the pointer in address. This meta class will be a subclass of PointerMetaClass. |
Reimplemented in AllWalker, and ReplacingWalker.
|
Called by the walker to perform action on the data in address.
Subclass must overwrite this method.
address | address of the data to be applied on. |
_meta | meta class of the data in address. |
Reimplemented in SuifWalker.
|
|
|
Set the order of walking to post_order.
Default is pre_order.
|
Set the order of walking to pre_order, which is the default.