package bap-std
Visitor. Visits AST providing lots of hooks.
For each AST constructor C
the visitor provides three methods: enter_C
, visit_C
, leave_C
. The default implementation for enter_C
and leave_C
is to return its argument. The default implementation for visit_C
is the following: 1. call enter_C
2. visit all children 3. call leave_C
.
It is recommended to override enter_C
method if you only need to visit C
constructor without changing a way you're visiting the tree.
For example, to collect all resolved jumps one could write the following function:
let collect_calls bil = (object(self)
inherit [Word.t list] visitor
method! enter_int x js = if in_jmp then x :: js else js
end)#run bil []
The default entry point of the visitor is method run
, but you can use any other method as well, for example, if you do not have a statement at all and want to visit expression.
inherit 'a Exp.visitor
inherit state
Default entry point
method run : t list -> 'a -> 'a
Default entry point
method enter_stmt : t -> 'a -> 'a
Statements
method visit_stmt : t -> 'a -> 'a
method leave_stmt : t -> 'a -> 'a
method enter_jmp : exp -> 'a -> 'a
Jmp exp
method visit_jmp : exp -> 'a -> 'a
method leave_jmp : exp -> 'a -> 'a