Legend:
Library
Module
Module type
Parameter
Class
Class type
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.