package bap-std
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=631fc58628418e4856709a0cfc923a65e00c9494fbd28d444c633d11194831de
md5=3db9deac8d429b9b8a8ec9aec54987b1
doc/bap/Bap/Std/Stmt/class-visitor/index.html
Class Stmt.visitor
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.visitorinherit stateDefault entry point
method run : t list -> 'a -> 'aDefault entry point
method enter_stmt : t -> 'a -> 'aStatements
method visit_stmt : t -> 'a -> 'amethod leave_stmt : t -> 'a -> 'amethod enter_jmp : exp -> 'a -> 'aJmp exp
method visit_jmp : exp -> 'a -> 'amethod leave_jmp : exp -> 'a -> 'a